I’m new to this forum, etc. etc. looked at s.a.q., etc. etc. so forgive me if this, or any other questions, are often answered. I’ve looked a little, but can’t find anything.
Anywho, my question is pretty simple (I think):
I’m new to AS and am doing a test where I create shrapnel pieces from a grenade which explodes upon the user pressing a button.
Here’s my code so far:
import flash.events.MouseEvent;
btn1.addEventListener(MouseEvent.CLICK, createShrap);
function createShrap(e:MouseEvent):void
{
source1.visible = false;
for (var i:uint = 0; i < 10; i++)
{
var shrap:MovieClip = new Shrap();
addChild(shrap);
shrap.x = source1.x;
shrap.y = source1.y;
}
}
Source1 is the grenade image, and, of course, shrap is the many shrapnel coming out of it. What I want is to set velocity variables to the individual shraps being added, but I don’t know their individual instance names with which I can refer to them later on in the code. I expected something like “shrap1”, “shrap2” etc., but am pretty well confused here.
Could you tell me any of the following:
[LIST]
[]How to set a new instance name to any MovieClip using Action Script
[]What are the instance names of the 10 MovieClips I have created?
[]When I type trace(shrap.instanceName) or trace(shrap.name), this doesn’t seem to be the same instance name with which I alter the MovieClip’s properties. Why is this?
[]Hence, what is the purpose of .instanceName and .name?
[/LIST]
Thank you!