Share Posted October 22, 2014 Hello, Is there a way for the viewer to control an object with his mouse? First I want the object to enter the stage and stop. After the object stops I would like the viewer to be able to move it up and down on the y axis using his mouse. Any help would be appreciated! Link to comment Share on other sites More sharing options...
Share Posted October 23, 2014 create a new fla with an MovieClip named mc and use this code: import com.greensock.*; import com.greensock.easing.*; import flash.events.MouseEvent; //start mc at top left corner mc.x = mc.y = 0; //move mc to 200, 200 TweenLite.to(mc, 1, {x:200, y:200, onComplete:followMouse}); //call this function onComplete of tween function followMouse() { stage.addEventListener(MouseEvent.MOUSE_MOVE, moveIt); } function moveIt(e:MouseEvent):void { TweenLite.to(mc, 0.5, {x:this.mouseX, y:this.mouseY}); } Also there is a lot to learn by reading about these other approaches. Link to comment Share on other sites More sharing options...
Author Share Posted October 24, 2014 Thank you Carl! That worked perfectly. Thanks as well for the link to other approaches. In terms of ending the mouse event (moveIt), if the user interacts with the object I have figured out how to end it after a certain amount of time and move on to the final screen of the animation. Say, however, that the user does not interact with the object at all, but I still want to end the mouse event after a certain amount of time and move on to the final screen. Not sure how to incorporate that into the coding. (Use a timer?) Can you help? I've attached my zipped flash file. It looks super generic because I replaced the photos with simple graphic screens. testFile_gs.fla.zip Link to comment Share on other sites More sharing options...
Author Share Posted October 27, 2014 Carl, Please disregard my most recent question above. I was just able to figure out how to incorporate a timer class, which solved the problem. Thanks again for your help. 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now