Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 ActionScrip 2.0 help ?
Index -> General Programming
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Lucman909




PostPosted: Mon Jun 28, 2010 11:03 am   Post subject: ActionScrip 2.0 help ?

Hello everyone, kso im trying to make a shooter game. I have read the shoot-toreals on kongragate and Newgrounds and neather of it help me when it gets down to the code . . . . this is what i have so far.

Quote:

class Ship extends MovieClip
{
var speed;

function onLoad()
{
speed = 10;
}
function onEnterFrame()
{
_x = _x + speed;
}


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


The I have checked for syntax errors with the auto checker and it says "There Are No Errors In Your Script", but when I test it out my ship does not move !
If you know a bit of AS2.0 and can help PLEASE coment !
thank you .
Sponsor
Sponsor
Sponsor
sponsor
yoursecretninja




PostPosted: Mon Jun 28, 2010 12:31 pm   Post subject: Re: ActionScrip 2.0 help ?

Let me preface this by saying that I am not familiar with AS2... I never worked with Flash until AS3 came around. I'd recommend learning that over AS2... especially if you are familiar with Java.

There may be other problems with this code... I have never even looked at AS2 code before.... but, you shouldn't have a redefinition of onEnterFrame(). You should delete the first implementation of that function. Secondly, make sure that you actually have an instance of this class in your scene. If you're working with the scene editor it can be easy to forget to define a movie clip as an instance of a class if you created the class after the fact. Also, in AS3 at least, onEnterFrame() is an event, and thus, the function you should be implementing would be onEnterFrame(e:event);
Lucman909




PostPosted: Wed Jun 30, 2010 8:32 pm   Post subject: Re: ActionScrip 2.0 help ?

Thanks That Helps A lot ! (:
Display posts from previous:   
   Index -> General Programming
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 3 Posts ]
Jump to:   


Style:  
Search: