oops I missed paste it complete... var totalMovieClips:Number = 3; for ( var i = 0; i < totalMovieClips; i ++ ) { _root['mc' + i].indexPos = i;
_root[ 'mc' + i ].onRelease = function() { trace( 'mc' + this.indexPos + ' onRelease' ); } _root[ 'mc' + i ].onRollOver = function() { trace( 'mc' + this.indexPos + ' onRollOver' ); } _root[ 'mc' + i ].onRollOut = function() { trace( 'mc' + this.indexPos + ' onRollOut' ); } } On 3/30/06, Ing. Mario Falomir <[EMAIL PROTECTED]> wrote: > > Hi Alex, here is an example that could help you and illustrate how to > accomplish what you want > > var totalMovieClips:Number = 3; > > for ( var i = 0; i < totalMovieClips; i ++ ) > { > _root['mc' + i].indexPos = i; > > _root[ 'mc' + i ].onRelease = function() > { > trace( 'mc' + this.indexPos + ' onRelease' ); > } > > _root[ 'mc' + i ].onRollOver = function() > { > trace( 'mc' + this.indexPos + ' onRollOver' ); > } > > _root[ 'mc' + i ].onRollOut = function() > { > trace( 'mc' + this.indexPos + ' onRollOut' ); > > } > } > > On 3/30/06, Alejandro Diaz <[EMAIL PROTECTED]> wrote: > > > > Heya guys, > > > > I am assigning the button behaviors to a set of movieclips through a > > for loop, however, I am coming up against something where I know what > > is happening, but don't know how to fix it. > > > > Basically, inside that for loop I assign each of the button behaviors > > as a function but I don't know how to evaluate the counter in the > > function, rather than having it just literally written into it. > > instead of "section_"+ _root.i being section_1, section_2, etc...it > > is literally written in each of the buttons as "section_"+_root.i and > > so each button has exactly the same code and all go to the last > > section (last value of i) when clicked. > > > > How can I have it so that each function has the proper code it in? is > > this even the proper way to go about this? Is there a way to 'force' > > the evaluation of that counter in that function when it is being > > assigned to the MC? > > > > > > > > code: > > > > function buttonBehavior ():Void { > > for (_root.i=1;_root.i<8;_root.i++) { > > _root["mb_"+_root.i].onRollOver = function() { > > this.gotoAndPlay("over"); > > } > > _root["mb_"+_root.i].onRollOut = function() { > > this.gotoAndPlay("out"); > > } > > _root["mb_"+_root.i].onRelease = function() { > > _root.gotoAndPlay("display_frame"); > > loadMovie("section_"+_root.i+".swf", "load_target"); > > } > > > > > > } > > } > > > > (btw, I added the _root. to each of the i's so that the function could > > 'see' it. > > > > thanks in advance! > > -Alex > > _______________________________________________ > > Flashcoders@chattyfig.figleaf.com > > To change your subscription options or search the archive: > > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders > > > > Brought to you by Fig Leaf Software > > Premier Authorized Adobe Consulting and Training > > http://www.figleaf.com > > http://training.figleaf.com > > > > _______________________________________________ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com