PDA

View Full Version : Referencing Programmatically Attached movie Clips


Detroit_Andy
06-25-2007, 08:10 PM
Hello, I am teaching myself Flash in my spare time. I think this question is similiar to the other one posted in this forum by Jesse.

I want to programmatically create a set of menu buttons from several arrays with variable numbers of elements.

So I wrote some script in a conditional loop that attaches a movie clip to the root timeline like this:

nameString = "Button_"+String(count);
_root.attachMovie("Button", nameString, 1);

I also wrote it like this:

_root.attachMovie("Button", "Button_"+String(count), 1);

Then I ran into trouble because I had no idea how to reference the instances I had created. I want to offset the instances I created so they are not on top of each other.

I could probably come up with a kludgy way to solve this problem but I decided that I might be better off asking what the best way to solve this problem is on a project level scope.

ok, so once I have created an instance programatically how do I programatically acces it and its properties? The name of the movice clip was generated programatically, but I don't think that I can programatically reference it in the same way it's name was created.

"Button_"+String(count)._y = 50; Will not work, right? I need to pull the name of the clip somehow. But I don't see how. So, how do I tell the interpreter Button_0._y = 50; programatically?

Detroit_Andy
06-25-2007, 08:35 PM
It looks like the Advanced Pathing tutorial directly addresses this question...

hangalot
06-26-2007, 03:13 PM
never bothered looking at that tut, but attachmovie and createmovieclip both return refrences to the object you just added to the stage.
don't use _root
also look into the movieclip method getNextHighestDepth