1 Replies - 1399 Views - Last Post: 06 February 2012 - 09:57 AM

Topic Sponsor:

#1 meowbits  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 107
  • Joined: 31-January 12

Move scene with arrow keys/mouse

Posted 01 February 2012 - 12:37 PM

Say my scene dimensions are 400x600
but my project is 1000x1200

What are the attributes that I need to edit so that I can move around the project when I press arrow keys?

So far I have,

addEventListener(KeyboardEvent.KEY_DOWN, keyPressed);

function keyPressed(event:KeyboardEvent):void{ 
    if (event.keyCode == Keyboard.UP){

// What goes here?

	}
	if (event.keyCode == Keyboard.DOWN){

	}
	if (event.keyCode == Keyboard.LEFT){
		
	}
	if (event.keyCode == Keyboard.RIGHT){
		
	}
}


Is This A Good Question/Topic? 0
  • +

Replies To: Move scene with arrow keys/mouse

#2 razcobhc  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 11
  • Joined: 07-January 07

Re: Move scene with arrow keys/mouse

Posted 06 February 2012 - 09:57 AM

Hi,
First of all you need your 1000x1200 project inside of a MovieClip and give it an instance name (eg "myObj"). After you do that, in each if block you need to alter the y or x property of myObj accordingly. For up you increase the y of the object by 5 (or how much you want) writing:
 myObj.y+=5;

for down you decrease y, left and right are the same only you use the x property instead of y.

Hope this helps,
Razvan
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1