At 2/24/08 09:27 PM, Tivaelydoc wrote:
I need suggestions on what I should do. I'm not sure what would be easier, putting all the MC's into one giant MC or putting them in an array, which I'm still having trouble figuring out. I used the help in Flash as much as I could and my book and the internet tutorials (see SWF), but I can't figure out the rest. I'm not asking for exact AS, but anything that'll help me learn what to do. What I am trying to do then, is have a button that goes back and forth between MC's and on press of the original MC it duplicates and drags and it has the "focus", not sure what the terminology in flash for that is, so that the keyboard buttons apply, but they only modify that selected duplicated MC.
Save and Load I'll figure out later. Can someone help?
FLA:
http://tivaelydoc.110mb.com/shimmy2.fla
Ah, this is where flash scripting starts to get really fun, you'll want to learn about arrays definitely rather than trying to manage this with a giant MC. The good news is, once you master this, you'll really be able to start cranking out more advanced and interactive games.
The way I'd do it is like so:
1. Set a variable called "sel" to stand for the movieclip that's selected.
2. In an onEnterFrame event, set the controls based on the "sel" variable.
ie:
if (Key.isDown(Key.up))
{
_root.sel._y-=5;
}
3. Run a function that mass applies an "onPress" to all the movieclips you care about (this is where an array would be useful, or else name the movieclips sequentially ie: clip0, clip1, clip2) let's assume you're not gonna name them sequentially:
ie:
var myclips=new Array("bill","ted","sandimas","water","slide");
for (i=0;i<myclips.length;i++)
{
t=this[myclips[i]];
t.onPress=function()
{
_root.sel=this;
}
}
So basically, with this code, when you click on one of the clips in your array, is will become "sel" and then the onEnterFrame will let you move "sel" with the arrows.