Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Move with Keyboard Arrows
- Allows the specified symbol instance to be moved with the keyboard arrows.
- Instructions:
- 1. To increase or decrease the amount of movement, replace the number 5 below with the number of pixels you want the symbol instance to move with each key press.
- Note the number 5 appears four times in the code below.
- */
- var upPressed:Boolean = false;
- var downPressed:Boolean = false;
- var leftPressed:Boolean = false;
- var rightPressed:Boolean = false;
- var MCMspeed:Number = 5;
- MCM.addEventListener(Event.ENTER_FRAME, fl_MoveInDirectionOfKey_4);
- stage.addEventListener(KeyboardEvent.KEY_DOWN, fl_SetKeyPressed_4);
- stage.addEventListener(KeyboardEvent.KEY_UP, fl_UnsetKeyPressed_4);
- function fl_MoveInDirectionOfKey_4(event:Event)
- {
- if (upPressed)
- {
- MCM.y -= 5;
- MCM.gotoAndPlay(17);
- MCM.y -= MCMspeed;
- }
- if (downPressed)
- {
- MCM.y += 5;
- MCM.gotoAndPlay(17);
- MCM.y += MCMspeed;
- }
- if (leftPressed)
- {
- MCM.x -= 5;
- MCM.gotoAndPlay(41);
- MCM.x -= MCMspeed;
- }
- if (rightPressed)
- {
- MCM.x += 5;
- MCM.gotoAndPlay(17);
- MCM.x += MCMspeed;
- }
- }
- function fl_SetKeyPressed_4(event:KeyboardEvent):void
- {
- switch (event.keyCode)
- {
- case Keyboard.UP :
- {
- upPressed = true;
- break;
- };
- case Keyboard.DOWN :
- {
- downPressed = true;
- break;
- };
- case Keyboard.LEFT :
- {
- leftPressed = true;
- break;
- };
- case Keyboard.RIGHT :
- {
- rightPressed = true;
- break;
- }
- }
- };
- function fl_UnsetKeyPressed_4(event:KeyboardEvent):void
- {
- switch (event.keyCode)
- {
- case Keyboard.UP :
- {
- upPressed = false;
- break;
- };
- case Keyboard.DOWN :
- {
- downPressed = false;
- break;
- };
- case Keyboard.LEFT :
- {
- leftPressed = false;
- break;
- };
- case Keyboard.RIGHT :
- {
- rightPressed = false;
- break;
- }
- }
- };
- /* Click to Go to Frame and Play
- Clicking on the specified symbol instance moves the playhead to the specified frame in the timeline and continues playback from that frame.
- Can be used on the main timeline or on movie clip timelines.
- Instructions:
- 1. Replace the number 5 in the code below with the frame number you would like the playhead to move to when the symbol instance is clicked.
- */
- A.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndPlayFromFrame_8);
- function fl_ClickToGoToAndPlayFromFrame_8(event:MouseEvent):void
- {
- MCM.gotoAndPlay(2);
- if (MCM.Animator.frame(52))
- MCM.gotoAndPlay(61);
- }
- /* Click to Go to Frame and Play
- Clicking on the specified symbol instance moves the playhead to the specified frame in the timeline and continues playback from that frame.
- Can be used on the main timeline or on movie clip timelines.
- Instructions:
- 1. Replace the number 5 in the code below with the frame number you would like the playhead to move to when the symbol instance is clicked.
- */
- B.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndPlayFromFrame_9);
- function fl_ClickToGoToAndPlayFromFrame_9(event:MouseEvent):void
- {
- MCM.gotoAndPlay(9);
- if (MCM.Animator.frame(52))
- MCM.gotoAndPlay(53)
- }
Advertisement
Add Comment
Please, Sign In to add comment