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;

}

}

 

Why Fortune Innovations?

  • Cost-saving for your projects, up to 40%
  • Hire web development and web designing specialists
  • Project management based out in Liverpool
  • 50 plus strong off shore development team based in Bangalore, India
  • Expert teams well verse with Web 2.0 standards
  • Quality-driven delivery model
  • Detailed time sheets, daily reporting and regular status updates
  • 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