Sprite Control Using Keyboard in Flash Action script

11 April 2012

Liverpool : Use Keyboard Arrow Keys to move up, bottom, left, right.

Step-1 Open a new document in Flash

Step-2 Create a boy head or whichever you like

Step-3 Convert it into “movie clip” and name it as “sprite”.

Step-4 Write the following action script in a new layer, Key frame-1

spriteDirection = 0;

setInterval(function () {

if (Key.isDown(Key.RIGHT)) {

setDirection(0);

_root.sprite._x += 3;

}

if (Key.isDown(Key.LEFT)) {

setDirection(1);

_root.sprite._x -= 3;

}

if (Key.isDown(Key.DOWN)) {

_root.sprite._y += 3;

}

if (Key.isDown(Key.UP)) {

_root.sprite._y -= 3;

}

updateAfterEvent(); }, 10);

function setDirection(param)

{

if(param==0)

{

sprite._xscale = 100;

}else 

{

sprite._xscale = -100;

}

}

 

News Archive

  • WordPress Development in Liverpool
  • Drupal Development in Liverpool
  • Joomla Development in Liverpool
  • eCommerce Magento Liverpool
  • Web Development Liverpool
  • Web Design Liverpool
  • jQuery development Liverpool
  • Zend framework development Liverpool
  • Airline IBE GDS Integration Navitaire Liverpool
  • Airline IBE GDS Integration Aamadeus Liverpool