thanks - while it works I am having the same issue... by the time I am rolling over - they are all affecting the same mc... so no matter which one you rollover - the same MC is having it's alpha changed - when they should each be changing their own... my thinking is that by the time the event occurs - they are all sitting on the last memeber of the array... make sense?
Ted ________________________________________ From: [email protected] [[email protected]] On Behalf Of Glen Pike [[email protected]] Sent: Monday, December 07, 2009 5:48 PM To: Flash Coders List Subject: Re: [Flashcoders] Minimizing Code: Logic Issue Hi, Not sure what your findValue function does, but I am guessing you are looking for the name in an array of names.... Anyway, you could create an array of names that you are going to use and loop throught these to attach your onRollover / onRollout functionality. To make if work for each clip, you can attach the current name to your clip so it can use it in the onRollover function, etc. Something like below might work: //Create your array somehow - this is just for "show" var myFiftyClips:Array = ["AAAA", "AAAB", ... "AABX"]; var len:Number = myFiftyClips.length; //don't have to do this if you don't want to... //Loop through the clips for(var i:Number = 0; i < len;i++) { //Grab the name we are going to use var nm:String = myFiftyClips[i]; //now we can start accessing our clips using the name as an index... _root[nm]._alpha = 0; //Because this is AS2, you can dynamically attach properties to your movieclip, so assign the name as a variable of the clip so the clip can find it later... _root.mc1[nm].mc2.nm = nm; _root.mc1[nm].mc2.onRollover = function() { trace("Hello I am onRollover for " + this + " my name is " + this.nm); if(findValue(this.nm, arrayName) == 1) { //hey presto, you can still access stuff! _root[this.nm]._alpha = 100; } } _root.mc1[nm].onRollout = function() { _root[this.nm]._alpha = 0; } } Lehr, Theodore wrote: > OK - imagine: > > _root.AAAA._alpha = 0; > _root.mc1.AAAA.mc2.onRollOver = function() { > if (findValue("AAAA", arrayName) == 1) { > _root.AAAA._alpha = 100; > } > } > _root.mc1.AAAA.mc2.onRollOut = function() { > _root.AAAA._alpha=0; > } > > > Now, I have to repeat this code like 50 times for 50 different movies with > the 'AAAA' being replaced by a different instance name.... My thought was to > put the AAAA's into an array and loop through that - but as I am finding the > code is not called until the event (i.e. onRollOver and thus the last array > member is the active one... Is there anyway to minimize the code instead of > havign to repeat this 50 times - I am sure I am approaching this from the > wrong direction.... > _______________________________________________ > Flashcoders mailing list > [email protected] > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders > > -- Glen Pike 01326 218440 www.glenpike.co.uk <http://www.glenpike.co.uk> _______________________________________________ Flashcoders mailing list [email protected] http://chattyfig.figleaf.com/mailman/listinfo/flashcoders _______________________________________________ Flashcoders mailing list [email protected] http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

