Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamic Event Handling

Status
Not open for further replies.

thebeige

Programmer
Joined
Oct 1, 2003
Messages
5
Location
US
I haven't been able to find a definitive, helpful answer about this...

I'm loading several MC's dynamically using attachMovie. Now, these things are dynamically named, but I want to get the onRelease event of them. Here's what I have so far.

function importClips(movieClipArray)
{
xPos = 400;

for (i = 0; i < movieClipArray.length; i++)
{
linkName = movieClipArray[ i ];
newName = linkName;
_root._level1.attachMovie(linkName, newName, i);

newMovie = eval(&quot;_root._level1.&quot; + newName);
newMovie._x = xPos;
newMovie._y = 155;

xPos += newMovie._width + 15;

newMovie.onRelease = function()
{
selectShell(newName); // Does a few other things with the clip.
}
}
}

Since I can't discretely reference the MC's, I have to put the onRelease inside of the function (and loop) that attaches them.
Invariably, when I click on any of the MC's, the last MC loaded gets the &quot;selectShell()&quot; function call.

Any ideas on how I can get around this?
 
What's this _root._level1 business?
And you shouldn't be using eval but associative array syntax...

Regards,

cubalibre2.gif
 
_root._level1 is a way that i'm able to attachMovie().
the movie clips are loaded from an external library - the .swf that's loaded is loaded onto _level1.

eval is used because movieClipArray merely contains an array of strings.

anyway, all of that works. the movies are attached and they are positioned properly - the problem comes in with the onRelease stuff.
i merely included the other code for contextual reference.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top