-
Add movieclips from instances in array
Ive created a array to hold an instance of the Zombie movie clip, the movie is given an instance of "Zombie" + 1, 2, 3..... But now i can't work out how to add the movie clips from the Array to the stage.
Thanks allot
here's the code..
var ZombieArray:Array = [];
var Zombie_mc:MovieClip = new MovieClip();
//update current zombie number for array
CurrentZombie++;
//name instance
Zombie_mc.name = "Zombie" + CurrentZombie;
//add zombie to end of array
ZombieArray.push("Zombie"+CurrentZombie);
//add Zombie_mc to stage;
addChild(Zombie_mc);
//show array on text box
textbox1_txt.text = ZombieArray.join("\n");
I also need to be able to preform a hitTest and move the movie clips if anybody can help with that.
-
you can prolly use the same idea as what they use to generate these bullets
http://www.freeactionscript.com/2009...-machine-guns/
-
Originally Posted by Jaggernought
Ive created a array to hold an instance of the Zombie movie clip, the movie is given an instance of "Zombie" + 1, 2, 3..... But now i can't work out how to add the movie clips from the Array to the stage.
Thanks allot
here's the code..
var ZombieArray:Array = [];
var Zombie_mc:MovieClip = new MovieClip();
//update current zombie number for array
CurrentZombie++;
//name instance
Zombie_mc.name = "Zombie" + CurrentZombie;
//add zombie to end of array
ZombieArray.push("Zombie"+CurrentZombie);
//add Zombie_mc to stage;
addChild(Zombie_mc);
//show array on text box
textbox1_txt.text = ZombieArray.join("\n");
I also need to be able to preform a hitTest and move the movie clips if anybody can help with that.
I suggest making a zombie class that has a movieclip attribute and/or extending the movieclip class to detect collisions. (maybe movieHitClip).
This way you are adding the type Zombie instead of simple movieclips that limit you. I dont know why you would want to add the zombie instance itself in an array as the zombie type should handle the destruction for you.
A good design tip is to keep zombie self contained inside of it's class so that it can function in any application you add zombie to. This will save you the head ache of keeping track of zombies on a global level. As far as zombie count, I can understand why you would want to know how "many" zombies there are, but referencing the zombie itself can be tedious.
I hope this helps...
-
Ah, cool. Now I at least know where I'm going wrong but I've got no idea how to do it, I must admin Im completely new to flash. Any chance you could link a tutorial
Oh and ybab, the tutorial was great and what I need but I'm learning as3 not 3
Thanks for the help
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|