Is there a way to add physics to static animations in AS3(Adobe Animate CC) - actionscript-3

I made a simple swing animation in adobe animate cc(AS 3.0) but the problem is that user needs to interact with it causing gravitational reactions.For e.g:When the user interacts with the object,the speed at which the object is moved results in the appropriate reactions such as oscillation.I'm fairly new to this cannot wrap my head around this.Can i get some help?i'm stuck and badly need this for a project.

Related

Is DragonBones compatible with libGDX?

I am trying to use DragonBone animations in my LibGDX game.
I am working on an endless runner game,so JSON levels will be loaded continuously and obstacles and coins get created each time level gets loaded.
Whenever I apply DragonBone animation for the obstacles,game is having a lag and white screen appears while executing code for collision.
Is DragonBone really compatible with LibGdx?
Or this problem occur because my code structure is not proper?(For each level,I am assigning DragonBone to each obstacles from a dragonBone array.Not able to use any loader for dragonBone also.Didn't get any code for that from net.)
Hope I will get some relevant suggestions.I am Really getting a hard time on this issue.

How do I create a simple on-mouse-click rotating object in flash

This question may get downvoted or go unanswered because it's not the greatest and incredible silly but anyway,
I'm taking an intro level Webanimation course this semester at UNI and had I know what their expectations are for our hand-in projects i would have never taken it up.
Basically the teacher taught us stuff to the extent of masking/tweening and very few mouse-event and basic function codes.
Now she is expecting us to make a god damn ENTIRE PIPE GAME. The one where there are a bunch of rotating pipes and you gotta rotate them in place before a timer runs out and then the water flows through them.
For this project I have to somehow figure out the following (even though she didn't teach any of this):
-creature a grid of rotate-able pipes (one mouse click I assume would do a 90 degree classic tween rotation of the object)
-creature some sort of logic hit-box value chain to make pipes decide when to fill with water (they fill with water (a.k.a turn blue inside as an animation) once they are connected to another water filled pipe, for example)
-creature multiple levels and a menu screen
-add a music track.
Now i know this site is for specific help only and you basically can't ask for help on an entire project, so for now if somebody could just help me out with the following:
How do I create a rotating pipe on mouseclick?
So I have my pipe movieclip created and I have my Mouse Event code ready but I don't have the faintest on how to make a tween within the pipe and connect it to the code so that it rotates on mouseclick.
So this far, let's say for one of the pipes, instance pipe_1, I want to do this:
pipe_1.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler);
function fl_MouseClickHandler(event:MouseEvent):void
{
trace("Mouse clicked");
}
I also have the simple tween of rotation already created within the instance of the pipe, but dunno how to connect it to code.
I'm supposed to figure out what to put inside the function but I honestly have no clue. Hours of googling have come up with nothing either except a 12 dollar purchasable source code for an even more complicated pipe game.
I hope somebody can at least help a bit, and thanks.
The way to rotate a clip is via it's rotation property. It defaults to 0.
If you were set the rotation property of your tile to 90, you'd rotate your pipe tile 90 degrees.
for example :
pipe_1.rotation += 90;
A tween is a means of changing a property of a given DisplayObject over time. So what you want to do is tween your rotation property 90 degrees over time.
Here is a tutorial on Tweening - http://www.republicofcode.com/tutorials/flash/as3tweenclass/
I think it'd be more beneficial for you to take the time to learn about it, than to have me just write a few lines of code to solve your problem.
StackOverflow is a place where you can ask a question, AFTER you have tried something and have hit an issue.
I have provided you with the basic concept of what you need to do, and if you take the time to learn about tweening, you'll be able to achieve your goal rather simply.
There are also tweening libraries such as TweenLite and TweenMax that simplify tweening. Not sure if your class will allow you to use them, but worthwhile to check out for your own benefit.
You can find TweenLite here :
http://www.greensock.com/tweenlite/
Are you talking about a frame by frame tween? or tweening with code?
for frame by frame tweening, you can try to do this:
pipe_1.addEventListener(MouseEvent.CLICK, f1_MouseClickHandler);
function f1_MouseClickHandler(e:MouseEvent) {
pipe_1.gotoAndPlay(2); //if the tween starts at frame 2
}
For code tweening, just call the tween function inside that handler function

How can I send control of the playhead back to a parent timeline from a movieclip using createJS?

I'm making a multi-part introductory animation for a game. It works when I preview in Flash, but not when I export using the CreateJS toolkit to get HTML5 output.
On my scene's timeline, I have this.stop(); on the first frame, as well as a movie clip that contains several seconds of animation (and which may have to change in length as we develop).
My second frame is labeled "sc2" and I would like the animation to pick up there when the first movieclip is finished. To accomplish this, I went into the first movie clip and put this on the last frame:
_parent.gotoAndPlay("sc2");
This works fine in Flash, but perhaps I can't use the _parent object in JS? Is there an alternative way to access the flow of control or another way to accomplish this? My goal is to avoid doing animation on the main timeline and to control the flow by scripting there so that if the length of the individual sections of animation changes, I don't have to change the start and end frames of the various sections in several places.

How to add an Object to the stage with nested code in AS3.0

I'm busy developing my first application using the AS3.0 language.
I built the full application in Flash Professional, it worked, but it lacked performance.
Now, I'm rebuilding it in Flash builder, so it's more optimised, and it's running great.
Although I've hit a snag.
In Flash Pro, it was very easy for me to add movieclips to the stage, with code nested inside them, so when I added the object, all the code worked like a charm.
In Flash Builder, I have NO clue on how to achieve the same effect... I'm so close to being finished but have no idea how to achieve this.
I've tried making external classes, but with no programming background, it's very hard to find a solution when I don't know where to begin...
SO in short:
HOw to you add objects to your stage using pure AS3 code,
I need to add a graphic object to my stage
And add simple mouse interactivity to it.
Any responses, links, chuckles at me, would be greatly appreciated
Shane
The following code would add a movieclip to the stage, with a line drawn from 0,0 to 100,100 . Provided you are writing this code in the Main class.
var mc:MovieClip = new MovieClip();
addChild(mc) ;
mc.moveTo(0,0)
mc.lineTo(100,100) ;

ActionScript 3 Best place to bind events

I am writing a small Flash game using air for android and have encountered a slight issue.
The game has 3 screens (excluding the game screen) which are main menu, load game & create new game. On the load game and create new game screens I want to add a button which take the user back to the main menu.
I know how to add event listeners to buttons but I am wondering where do I bind the event listener for back to main menu, binding in the constructor of my main class produces an error at run time and binding after going to the frame is knocking out the other buttons when back at the main screen.
At present the app is across multiple frames (probably a better structure to this instead of loading a single frame with each menu), I am new to actionscript so I am not entirely certain on best practices for this sort of thing.
Thanks.
I recommend you to use only one frame in your Fla, then use a Document Class. In that main Class, you should place all your display objects using ActionScript.
I hope you know how to instantiate Class as library clips.