onRelease issue on dynamically created clips

  • dilly
  • Born
  • Born
  • dilly
  • Posts: 2

Post 3+ Months Ago

I'm sure this is just a user error on my part.

I have an instance of a movie clip and use it to dynamically generate 12 new clips. Each clip has an onRelease attached to it as a function. There is another clip on the stage (textholder) with a variable text field (cliptext) attached to it. What I want to do is change the contents of the variable text field depending on which dynamically generated clip the user clicks on. Code thus:

for (j=1; j<=12; j++) {
newclipname = "clip" + j;
duplicateMovieClip(_root.baseclip,newclipname,j);
_root[newclipname].onRelease = function() {
cliptext = 'hello world ' + j;
_root.textholder.cliptext.text = cliptext;
}
}

When playing the movie, all the clips are in place, I can click on each one and everything works, except the text that appears in _root.textholder.cliptext is _always_ 'hello world 13'. Like I said I'm sure this is my fault, looks like the function is resetting events - just my head is so filled with PHP and JS I can't get it around this one. Any help would be appreciated. Thanks in advance.

Mike
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • dilly
  • Born
  • Born
  • dilly
  • Posts: 2

Post 3+ Months Ago

Solved this. Thought I'd add a note here in case someone else runs into this. Plain inexperience with AS, that's all.

for (j=1; j<=12; j++) {
newclipname = "clip" + j;
duplicateMovieClip(_root.baseclip,newclipname,j);
_root[newclipname].textid = j;
_root[newclipname].onRelease = function() {
cliptext = 'hello world ' + this.textid;
_root.textholder.cliptext.text = cliptext;
}
}

Post Information

  • Total Posts in this topic: 2 posts
  • Users browsing this forum: No registered users and 13 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.