jelly-guy
07-26-2006, 12:04 PM
Hi everyone,
I am cleaning up the code from a game I made a few months ago and I am trying to place all my code into one external file as opposed to code residing on individual movie clips.
All is well but a number of questions have arisen. They are not complicated so can someone set me straight please.
First of all. In Actionscript good practice should all the code reside in one .as file or is it common practice to seperate ellements of the game by using seperate .as files? ie one for the main time line and another for the main character and so on?
The second question is a bit more complex. In my original game Code for the enemy characters resided in on the movie clip. This clip was then duplicated taking the code with it. Now that have movied the script to the main timeline I am finding it difficult to reference the duplicated objects.
The original scrpit works alone the lines of:
On the main time line
_root.enemy_mc.duplicateMovieClip("enemy_mc"+_root.enemyCount,_root.level);
Then on the movie clip is the onEnterFrame function:
OnClipEvent (EnterFrame){
this._x +=2;
}
How can this be translated to the main time line. I have tried using
_root["enemy_mc"+_root.EnemyCount].onEnterFrame =function(){
}
But this doesn't seem to work. Can anyone help? Maybe you cannot use onEnterFrame this way but I am not sure please shed some light on this for me.
Thanks:confused:
I am cleaning up the code from a game I made a few months ago and I am trying to place all my code into one external file as opposed to code residing on individual movie clips.
All is well but a number of questions have arisen. They are not complicated so can someone set me straight please.
First of all. In Actionscript good practice should all the code reside in one .as file or is it common practice to seperate ellements of the game by using seperate .as files? ie one for the main time line and another for the main character and so on?
The second question is a bit more complex. In my original game Code for the enemy characters resided in on the movie clip. This clip was then duplicated taking the code with it. Now that have movied the script to the main timeline I am finding it difficult to reference the duplicated objects.
The original scrpit works alone the lines of:
On the main time line
_root.enemy_mc.duplicateMovieClip("enemy_mc"+_root.enemyCount,_root.level);
Then on the movie clip is the onEnterFrame function:
OnClipEvent (EnterFrame){
this._x +=2;
}
How can this be translated to the main time line. I have tried using
_root["enemy_mc"+_root.EnemyCount].onEnterFrame =function(){
}
But this doesn't seem to work. Can anyone help? Maybe you cannot use onEnterFrame this way but I am not sure please shed some light on this for me.
Thanks:confused: