Place images in Flash
Once you've created your MovieClip, create a layer that you call "background". Place your mc_fond with the X and Y coordinates to 0 (in the properties panel).
Lock the layer to avoid selecting the substance by mistake. Create a new layer and name the "arrows". Place the mc_fleche on stage but outside the working area of 300x350. The arrow will be positioned by the ActionScript code.
Management scenario of a Flash game
A flash game is not built as an animation in that not everything can be programmed in advance. On the main time line, everything will take place on a single image that will be played in a loop by the Flash player. To do this we will use the onEnterFrame Flash.
This feature allows you to execute a portion of code as soon as Flash draws an image, ie 30 times per second. To initialize variables, it simply puts the boots outside this block onEnterFrame.
Managing pressing the arrow keys
Create a layer that you call "ActionScript", which will contain all the code to run the game On the first frame, enter this ActionScript code:
Code:
_root.onEnterFrame = function () (
if (Key.isDown (Key.UP)) (
trace ( "key is pressed UP");
)
if (Key.isDown (Key.DOWN)) (
trace ( "key is pressed DOWN");
)
if (Key.isDown (Key.LEFT)) (
trace ( "key is pressed LEFT");
)
if (Key.isDown (Key.RIGHT)) (
trace ( "RIGHT key is pressed");
)
)
This code will intercept supports the arrow keys on the keyboard. For now, only one support triggers several trace (), because the code is done 30 times per second.
Bookmarks