PDA

View Full Version : Wont work using AS3, but does using AS2!!!Please help!



Scank
April 2nd, 2008, 01:13 PM
Hi, Im following a simple tutorial for creating a spacegame, simple game where a space ship shoots bullets and hits objects, using keyboard input... I have the following script, which makes the object move around the stage...

this.onEnterFrame = function()
{
if (Key.isDown(Key.RIGHT))
{
Ship._x += 10;
} else if (Key.isDown(Key.LEFT))
{
Ship._x -= 10;
} else if (Key.isDown(Key.UP))
{
Ship._y -= 10;
} else if (Key.isDown(Key.DOWN))
{
Ship._y += 10;
}
}

Now Im doing this for a University assignment, and a reqwuirement is it needs to use AS3! Well when i run the application in AS3 it does not recognise the UP DOWN RIGHT and LEFT values...however, it does run fine using AS2..is there anyway i can incorporate this script into AS3? Thanks.

Gundark
April 2nd, 2008, 01:29 PM
Event listeners work completely differently in Actionscript 3. There is no onEnterFrame(). You need to use addEventListener.

Here is a tutorial I found in like 5 seconds using Google:
http://www.emanueleferonato.com/2008/03/24/create-a-flash-ball-game-using-as3/

Or for even more help, trying reading some of Senocular's tutorials on Actionscript 3 at http://www.senocular.com/flash/tutorials/as3withflashcs3/?page=3

Good luck on your assignment.

Scank
April 2nd, 2008, 01:38 PM
Event listeners work completely differently in Actionscript 3. There is no onEnterFrame(). You need to use addEventListener.

Here is a tutorial I found in like 5 seconds using Google:
http://www.emanueleferonato.com/2008/03/24/create-a-flash-ball-game-using-as3/

Or for even more help, trying reading some of Senocular's tutorials on Actionscript 3 at http://www.senocular.com/flash/tutorials/as3withflashcs3/?page=3

Good luck on your assignment.

Thanks for your help Gundark... If i followed this tutorial (in AS2) will there be alot of functions that will not work in AS3 becasue they are set differently in AS3? I just want a simple tutorial to create a simple game, I have looked at that site, but the flash ball is not really a game for me :)