Interactive Media

Mohamed Al-Kaf - Media Explorations

Advanced Adobe Animate

Written by: Mohamed Al-Kaf | Posted on: | Category:

Control MovieCLips With Keyboard Things to remember:

  • Instance Names
  • Code Snippets
  • Scalex
  • Keycodes
  • Rotation
  • MC.x
  • Hittest - for Collision detection

Screenshot 2019-03-11 at 4.19.45 pm.png

Moving animation using keyboard, can any other keyboard button.

Screenshot 2019-03-11 at 2.52.27 pm.png

  • Walk Angle
  • Graphics symbolers
  • Bone Tool
  • COntoel with Keybaord and or mouse

Create movement with botton interaction. here i set the the Box on the left to move with WASD keys and the box on the right with the walking cycle to move with the arrows keys. A possible way to wave Mulitplayer interaction/Gameplay.

2019-04-30 10.36.23 pm.gif

Code to Constrain Box within the Canvas Scene

Screenshot 2019-04-30 at 10.37.47 pm.png

Using cude to reset scene/object/ movie clip/grtaphic symbole postion with mouse click.

var test:Boolean = false;

stage.addEventListener(MouseEvent.CLICK, fl_ClickToPosition);

function fl_ClickToPosition(event:MouseEvent):void
{

  if(test == true){
    box_MC_1.x = 250;
    box_MC_1.y = 250;       
    }
    test = true;
    }

Changing the direction of animation to the directionwith walking. Press left, to move left and face left.

if (leftPressed)
    {
        movieClip_1.x -= 1;
        movieClip_1.scaleX = -1;

I had noticed that code snippet with in adobe animate used a different way for character movement.

var upPressed:Boolean = false;
var downPressed:Boolean = false;
var leftPressed:Boolean = false;
var rightPressed:Boolean = false;

movieClip_1.addEventListener(Event.ENTER_FRAME, fl_MoveInDirectionOfKey);
stage.addEventListener(KeyboardEvent.KEY_DOWN, fl_SetKeyPressed);
stage.addEventListener(KeyboardEvent.KEY_UP, fl_UnsetKeyPressed);

unction fl_MoveInDirectionOfKey(event:Event)
{
    if (upPressed)
    {
        movieClip_1.y -= 1;
    }
    if (downPressed)
    {
        movieClip_1.y += 1;
    }
    if (leftPressed)
    {
        movieClip_1.x -= 1;
    }
    if (rightPressed)
    {
        movieClip_1.x += 1;
        }
}

function fl_SetKeyPressed(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;
        }
    }
}