I am new to AS3 and I know how my MouseEvent.MOUSE_MOVE
listener There is no user interaction.
I have created an animation that does the following: A solid line and some text appear above an image. After this is finished a mouse event is enabled which allows the user to move up and down row. When the user stops communicating with the line, the line disappears and the final animation of the animation is visible.
In the event that the user does not interact with the animation at all (the line never runs at all), I need to include some ways to remove the event listener, after which the last screen of animation is shown Will give I think adding a timer event
is what I want, this is the right way, but I'm not sure how to include it. It can not be the best or the right way.
Any help would be appreciated!
Here's my code:
Import com.greensock. *; // object on line_mc.y = 250; RaisingTxt.alpha = 0; Arrow_mc.alpha = 0; Final_mc.alpha = 0; Logo_mc.alpha = 1; // Line to move MC: 125 TweenLite.to (line_mc, 1, {y: 125}); TweenLite.to (raisingTxt, .5, {Alpha: 1, Delay: 1.2}); TweenLite.to (arrow_mc, .5, {alpha: 1, delay: 1.2, but full: followMouse}); // calls mouseover to follow on-to-function mouse () {stage.addEventListener (MouseEvent.MOUSE_MOVE, moveIt); } To move the function (E: MouseEvent): Zero {TVLlight. (Line_mc, 0.5, {y: this.mouseY}); TweenLite.to ([raisingTxt, arrow_mc], 0.5, {alpha: 0, succeed: final screen}); } // Last full screen of the mouseEvent function on the last screen call (TweenLite.to (line_mc, 0.5, {alpha: 0}); Tinlite (Last_mc, 0.5, {alpha: 1}); }
You completed it with the built in timer
Can Classroom I like a bit more than setTimeout function
because it's easy to manage.
First create a class wide variable (assuming you are doing this in Flash IDE, just create it near the top)
Wired timeout: timer;
Then :
in your followMouse (): private function followMouse (): zero {timeout = new timer (3000, 1); Timeout.addEventListener (TimerEvolution.imiccomplete, DeleteMoselestiner); Timeout.start (); Forum. AddEventListener (Mouse Event.MoEsmoOVI, move); }
removeMouseListener ()
:
Delete the private functionUse user (e: event = zero): zero {timeout} .removeEventListener (TimerEvolution.IMIM, Complement, DeleteMessSlister); Stage.removeEventListener (MouseEvent.MOUSE_MOVE, moveIt); }
If you want to reset the timer to the mouse every time you change your moveIt ()
:
timeout .reset (); Timeout.start ();
I have created an optional parameter near removeMouseListener ()
so that you can call it at any time regardless of the timer.
Hope this helps! Good luck!
Comments
Post a Comment