Re: [Flashcoders] Minimizing Code: Logic Issue
You can create an array of MovieClips as well and if you don't have to fetch the movieclip's parent name in order to controll it's alpha var myStuff:Array = [_root.mc1., _root.mc1., _root.mc1.] for (var i:Number = 0; i myStuff.length; i++ { myStuff[i].mc3.onRollOver = function() {changeViewOn(this);}; myStuff[i].mc3.onRollOut = function() {changeViewOff(this);}; } function changeViewOn(mov:MovieClip) { mov._parent.alpha = 100; } function changeViewOff(mov:MovieClip) { mov._parent.alpha = 0; } Lehr, Theodore wrote: Here is the solution I came up with - a mishmosh of a few peoples help: var myStuff:Array = [a,b,c]; for (var i:Number=0; imyStuff.length; i++) { var nm:String = myStuff[i]; _root.mc1[nm].mc3.onRollOver = function() { changeViewOn(this); } _root.mc1[nm].mc3.onRollOut = function() { changeViewOff(this); } } function changeViewOn(mov) { _root[mov._parent._name].alpha=100; } function changeViewOff(mov) { _root[mov._parent._name].alpha=0; } Thanks! From: flashcoders-boun...@chattyfig.figleaf.com [flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of David Hunter [davehunte...@hotmail.com] Sent: Tuesday, December 08, 2009 9:22 AM To: flashcoders@chattyfig.figleaf.com Subject: RE: [Flashcoders] Minimizing Code: Logic Issue i've been following this thread and may have missed a critical detail, but why do you need to check an instances name against an array if all you want to change is its alpha? or if you have extra values you need to check can't you just assign them to each instance when you add the rollover behaviours? i put an example of what i mean on pastebin: http://pastebin.com/m1db46cee hope it helps and i haven't completely missed the point and wasted your time! david From: ted_l...@federal.dell.com To: flashcoders@chattyfig.figleaf.com Date: Tue, 8 Dec 2009 08:58:34 -0500 Subject: RE: [Flashcoders] Minimizing Code: Logic Issue OK - I think I MAY have found a way - which leads me to another question: how can I grab the FULL name of an object (ie _level0.mc1.mc2.mc3) and substring it - like in the example, I want to extract mc2 from the path. From: flashcoders-boun...@chattyfig.figleaf.com [flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Glen Pike [g...@engineeredarts.co.uk] Sent: Tuesday, December 08, 2009 8:02 AM To: Flash Coders List Subject: Re: [Flashcoders] Minimizing Code: Logic Issue Hmm, Just to be clear. I guess you are creating a number of clips on which you set the alpha. Then you are using an equal number of clips that can be rolled over. When you rollover these clips, you set the alpha on the corresponding alpha clip. I can see why it might be using the last array member - that would be assigned the last time you loop through the array. You might want to add traces in a few more places - e.g. trace out the clip you are messing with, trace out it's name, etc. after you assigned it? Are you adding the clips programmatically - at runtime - or at authortime - in the IDE? Not 100%, but if you are adding them at authortime, you might not be able to add to their properties. I usually do a loop like below and attach symbols, then create properties on them, e.g. //Trimmed down example of adding a load of button clips for (iBut=0; iButsection.buttons.length; iBut++) { var btn:Object = section.buttons[iBut]; trace(button + btn.text + attributes: + btn.attributes[audioID] + , + btn.attributes[seqID] ); // create speech clip button var speechMC:MovieClip = this.speechButtons.dummy.attachMovie(audio button, speechS+iBut, (1000+iBut)); //Assign properties. speechMC.audioID = btn.attributes[audioID]; speechMC.seqID = btn.attributes[seqID]; //add the onRelease functionality speechMC.onRelease = function() { trace(onRelease + this + audioID + this.audioID); if (this.seqID this.audioID) { playSequenceA(this.seqID, this.audioID); } else if (this.seqID) { playSequence(this.seqID); } else if (this.audioID) { playAudio(this.audioID); } //Generic button handling for rollover colours... fButtonOff(this); } } Also, when you rollover and it traces - does each clip have the same nm value - that will break it / not work. You could always use the _name value of the clip to find out what to change. Lehr, Theodore wrote: ALSO: (and this might be impacting my results... when I used this.nm it did not work at all... so I took this. out and just used nm, while it works they are all suing the last array member From: flashcoders-boun...@chattyfig.figleaf.com [flashcoders-boun
RE: [Flashcoders] Minimizing Code: Logic Issue
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: flashcoders-boun...@chattyfig.figleaf.com [flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Glen Pike [postmas...@glenpike.co.uk] 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 = [, 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.._alpha = 0; _root.mc1..mc2.onRollOver = function() { if (findValue(, arrayName) == 1) { _root.._alpha = 100; } } _root.mc1..mc2.onRollOut = function() { _root.._alpha=0; } Now, I have to repeat this code like 50 times for 50 different movies with the '' being replaced by a different instance name My thought was to put the '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 Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders -- Glen Pike 01326 218440 www.glenpike.co.uk http://www.glenpike.co.uk ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] Minimizing Code: Logic Issue
ALSO: (and this might be impacting my results... when I used this.nm it did not work at all... so I took this. out and just used nm, while it works they are all suing the last array member From: flashcoders-boun...@chattyfig.figleaf.com [flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Glen Pike [postmas...@glenpike.co.uk] 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 = [, 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.._alpha = 0; _root.mc1..mc2.onRollOver = function() { if (findValue(, arrayName) == 1) { _root.._alpha = 100; } } _root.mc1..mc2.onRollOut = function() { _root.._alpha=0; } Now, I have to repeat this code like 50 times for 50 different movies with the '' being replaced by a different instance name My thought was to put the '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 Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders -- Glen Pike 01326 218440 www.glenpike.co.uk http://www.glenpike.co.uk ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Minimizing Code: Logic Issue
Hmm, Just to be clear. I guess you are creating a number of clips on which you set the alpha. Then you are using an equal number of clips that can be rolled over. When you rollover these clips, you set the alpha on the corresponding alpha clip. I can see why it might be using the last array member - that would be assigned the last time you loop through the array. You might want to add traces in a few more places - e.g. trace out the clip you are messing with, trace out it's name, etc. after you assigned it? Are you adding the clips programmatically - at runtime - or at authortime - in the IDE? Not 100%, but if you are adding them at authortime, you might not be able to add to their properties. I usually do a loop like below and attach symbols, then create properties on them, e.g. //Trimmed down example of adding a load of button clips for (iBut=0; iButsection.buttons.length; iBut++) { var btn:Object = section.buttons[iBut]; trace(button + btn.text + attributes: + btn.attributes[audioID] + , + btn.attributes[seqID] ); // create speech clip button var speechMC:MovieClip = this.speechButtons.dummy.attachMovie(audio button, speechS+iBut, (1000+iBut)); //Assign properties. speechMC.audioID = btn.attributes[audioID]; speechMC.seqID = btn.attributes[seqID]; //add the onRelease functionality speechMC.onRelease = function() { trace(onRelease + this + audioID + this.audioID); if (this.seqID this.audioID) { playSequenceA(this.seqID, this.audioID); } else if (this.seqID) { playSequence(this.seqID); } else if (this.audioID) { playAudio(this.audioID); } //Generic button handling for rollover colours... fButtonOff(this); } } Also, when you rollover and it traces - does each clip have the same nm value - that will break it / not work. You could always use the _name value of the clip to find out what to change. Lehr, Theodore wrote: ALSO: (and this might be impacting my results... when I used this.nm it did not work at all... so I took this. out and just used nm, while it works they are all suing the last array member From: flashcoders-boun...@chattyfig.figleaf.com [flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Glen Pike [postmas...@glenpike.co.uk] 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 = [, 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.._alpha = 0; _root.mc1..mc2.onRollOver = function() { if (findValue(, arrayName) == 1) { _root.._alpha = 100; } } _root.mc1..mc2.onRollOut = function() { _root.._alpha=0; } Now, I have to repeat this code like 50 times for 50 different movies with the '' being replaced by a different instance name My thought was to put the '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 Flashcoders@chattyfig.figleaf.com http
Re: [Flashcoders] Minimizing Code: Logic Issue
What kind of method do you use in findValue() to compare the movieclips ? If you are using _name then it might be to short string: var mc = createEmptyMovieClip(aaa,0); trace(mc: +mc); trace(mc: +mc._name); trace(mc: +String(mc)); outputs: mc: _level0.aaa mc: aaa mc: _level0.aaa Maybe you could paste findValue()... g Tuesday, December 08, 2009 (1:35:47 PM) Lehr, Theodore wrote: ALSO: (and this might be impacting my results... when I used this.nm it did not work at all... so I took this. out and just used nm, while it works they are all suing the last array member From: flashcoders-boun...@chattyfig.figleaf.com [flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Glen Pike [postmas...@glenpike.co.uk] 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 = [, 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.._alpha = 0; _root.mc1..mc2.onRollOver = function() { if (findValue(, arrayName) == 1) { _root.._alpha = 100; } } _root.mc1..mc2.onRollOut = function() { _root.._alpha=0; } Now, I have to repeat this code like 50 times for 50 different movies with the '' being replaced by a different instance name My thought was to put the '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 Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders -- Glen Pike 01326 218440 www.glenpike.co.uk http://www.glenpike.co.uk ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] Minimizing Code: Logic Issue
Yeah - they are created in the IDE... that's what I was afraid of thanks - I will look at the code you included... From: flashcoders-boun...@chattyfig.figleaf.com [flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Glen Pike [g...@engineeredarts.co.uk] Sent: Tuesday, December 08, 2009 8:02 AM To: Flash Coders List Subject: Re: [Flashcoders] Minimizing Code: Logic Issue Hmm, Just to be clear. I guess you are creating a number of clips on which you set the alpha. Then you are using an equal number of clips that can be rolled over. When you rollover these clips, you set the alpha on the corresponding alpha clip. I can see why it might be using the last array member - that would be assigned the last time you loop through the array. You might want to add traces in a few more places - e.g. trace out the clip you are messing with, trace out it's name, etc. after you assigned it? Are you adding the clips programmatically - at runtime - or at authortime - in the IDE? Not 100%, but if you are adding them at authortime, you might not be able to add to their properties. I usually do a loop like below and attach symbols, then create properties on them, e.g. //Trimmed down example of adding a load of button clips for (iBut=0; iButsection.buttons.length; iBut++) { var btn:Object = section.buttons[iBut]; trace(button + btn.text + attributes: + btn.attributes[audioID] + , + btn.attributes[seqID] ); // create speech clip button var speechMC:MovieClip = this.speechButtons.dummy.attachMovie(audio button, speechS+iBut, (1000+iBut)); //Assign properties. speechMC.audioID = btn.attributes[audioID]; speechMC.seqID = btn.attributes[seqID]; //add the onRelease functionality speechMC.onRelease = function() { trace(onRelease + this + audioID + this.audioID); if (this.seqID this.audioID) { playSequenceA(this.seqID, this.audioID); } else if (this.seqID) { playSequence(this.seqID); } else if (this.audioID) { playAudio(this.audioID); } //Generic button handling for rollover colours... fButtonOff(this); } } Also, when you rollover and it traces - does each clip have the same nm value - that will break it / not work. You could always use the _name value of the clip to find out what to change. Lehr, Theodore wrote: ALSO: (and this might be impacting my results... when I used this.nm it did not work at all... so I took this. out and just used nm, while it works they are all suing the last array member From: flashcoders-boun...@chattyfig.figleaf.com [flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Glen Pike [postmas...@glenpike.co.uk] 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 = [, 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.._alpha = 0; _root.mc1..mc2.onRollOver = function() { if (findValue(, arrayName) == 1) { _root.._alpha = 100; } } _root.mc1..mc2.onRollOut = function() { _root.._alpha=0; } Now, I have to repeat this code like 50 times for 50 different movies with the '' being replaced by a different instance name My
RE: [Flashcoders] Minimizing Code: Logic Issue
Also, when you rollover and it traces - does each clip have the same nm value - that will break it / not work. You could always use the _name value of the clip to find out what to change. They all trace the same one... the last member of the array not sure I undertstand the last part From: flashcoders-boun...@chattyfig.figleaf.com [flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Glen Pike [g...@engineeredarts.co.uk] Sent: Tuesday, December 08, 2009 8:02 AM To: Flash Coders List Subject: Re: [Flashcoders] Minimizing Code: Logic Issue Hmm, Just to be clear. I guess you are creating a number of clips on which you set the alpha. Then you are using an equal number of clips that can be rolled over. When you rollover these clips, you set the alpha on the corresponding alpha clip. I can see why it might be using the last array member - that would be assigned the last time you loop through the array. You might want to add traces in a few more places - e.g. trace out the clip you are messing with, trace out it's name, etc. after you assigned it? Are you adding the clips programmatically - at runtime - or at authortime - in the IDE? Not 100%, but if you are adding them at authortime, you might not be able to add to their properties. I usually do a loop like below and attach symbols, then create properties on them, e.g. //Trimmed down example of adding a load of button clips for (iBut=0; iButsection.buttons.length; iBut++) { var btn:Object = section.buttons[iBut]; trace(button + btn.text + attributes: + btn.attributes[audioID] + , + btn.attributes[seqID] ); // create speech clip button var speechMC:MovieClip = this.speechButtons.dummy.attachMovie(audio button, speechS+iBut, (1000+iBut)); //Assign properties. speechMC.audioID = btn.attributes[audioID]; speechMC.seqID = btn.attributes[seqID]; //add the onRelease functionality speechMC.onRelease = function() { trace(onRelease + this + audioID + this.audioID); if (this.seqID this.audioID) { playSequenceA(this.seqID, this.audioID); } else if (this.seqID) { playSequence(this.seqID); } else if (this.audioID) { playAudio(this.audioID); } //Generic button handling for rollover colours... fButtonOff(this); } } Also, when you rollover and it traces - does each clip have the same nm value - that will break it / not work. You could always use the _name value of the clip to find out what to change. Lehr, Theodore wrote: ALSO: (and this might be impacting my results... when I used this.nm it did not work at all... so I took this. out and just used nm, while it works they are all suing the last array member From: flashcoders-boun...@chattyfig.figleaf.com [flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Glen Pike [postmas...@glenpike.co.uk] 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 = [, 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.._alpha = 0; _root.mc1..mc2.onRollOver = function() { if (findValue(, arrayName) == 1) { _root.._alpha = 100; } } _root.mc1..mc2.onRollOut
Re: [Flashcoders] Minimizing Code: Logic Issue
If you gave names to the clips you place on the stage at authortime - in the instance name box (Properties panel), then you can access the name with the _name property. If you don't name them, the flash player assigns names like instance0, etc. It's a bit of work for 50 clips, but you could name them all , etc. I would suggest trying to add the clips dynamically for that many - it's probably the same amount of work, but easier to fix ;) Lehr, Theodore wrote: Also, when you rollover and it traces - does each clip have the same nm value - that will break it / not work. You could always use the _name value of the clip to find out what to change. They all trace the same one... the last member of the array not sure I undertstand the last part From: flashcoders-boun...@chattyfig.figleaf.com [flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Glen Pike [g...@engineeredarts.co.uk] Sent: Tuesday, December 08, 2009 8:02 AM To: Flash Coders List Subject: Re: [Flashcoders] Minimizing Code: Logic Issue Hmm, Just to be clear. I guess you are creating a number of clips on which you set the alpha. Then you are using an equal number of clips that can be rolled over. When you rollover these clips, you set the alpha on the corresponding alpha clip. I can see why it might be using the last array member - that would be assigned the last time you loop through the array. You might want to add traces in a few more places - e.g. trace out the clip you are messing with, trace out it's name, etc. after you assigned it? Are you adding the clips programmatically - at runtime - or at authortime - in the IDE? Not 100%, but if you are adding them at authortime, you might not be able to add to their properties. I usually do a loop like below and attach symbols, then create properties on them, e.g. //Trimmed down example of adding a load of button clips for (iBut=0; iButsection.buttons.length; iBut++) { var btn:Object = section.buttons[iBut]; trace(button + btn.text + attributes: + btn.attributes[audioID] + , + btn.attributes[seqID] ); // create speech clip button var speechMC:MovieClip = this.speechButtons.dummy.attachMovie(audio button, speechS+iBut, (1000+iBut)); //Assign properties. speechMC.audioID = btn.attributes[audioID]; speechMC.seqID = btn.attributes[seqID]; //add the onRelease functionality speechMC.onRelease = function() { trace(onRelease + this + audioID + this.audioID); if (this.seqID this.audioID) { playSequenceA(this.seqID, this.audioID); } else if (this.seqID) { playSequence(this.seqID); } else if (this.audioID) { playAudio(this.audioID); } //Generic button handling for rollover colours... fButtonOff(this); } } Also, when you rollover and it traces - does each clip have the same nm value - that will break it / not work. You could always use the _name value of the clip to find out what to change. Lehr, Theodore wrote: ALSO: (and this might be impacting my results... when I used this.nm it did not work at all... so I took this. out and just used nm, while it works they are all suing the last array member From: flashcoders-boun...@chattyfig.figleaf.com [flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Glen Pike [postmas...@glenpike.co.uk] 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 = [, 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
RE: [Flashcoders] Minimizing Code: Logic Issue
OK - I think I MAY have found a way - which leads me to another question: how can I grab the FULL name of an object (ie _level0.mc1.mc2.mc3) and substring it - like in the example, I want to extract mc2 from the path. From: flashcoders-boun...@chattyfig.figleaf.com [flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Glen Pike [g...@engineeredarts.co.uk] Sent: Tuesday, December 08, 2009 8:02 AM To: Flash Coders List Subject: Re: [Flashcoders] Minimizing Code: Logic Issue Hmm, Just to be clear. I guess you are creating a number of clips on which you set the alpha. Then you are using an equal number of clips that can be rolled over. When you rollover these clips, you set the alpha on the corresponding alpha clip. I can see why it might be using the last array member - that would be assigned the last time you loop through the array. You might want to add traces in a few more places - e.g. trace out the clip you are messing with, trace out it's name, etc. after you assigned it? Are you adding the clips programmatically - at runtime - or at authortime - in the IDE? Not 100%, but if you are adding them at authortime, you might not be able to add to their properties. I usually do a loop like below and attach symbols, then create properties on them, e.g. //Trimmed down example of adding a load of button clips for (iBut=0; iButsection.buttons.length; iBut++) { var btn:Object = section.buttons[iBut]; trace(button + btn.text + attributes: + btn.attributes[audioID] + , + btn.attributes[seqID] ); // create speech clip button var speechMC:MovieClip = this.speechButtons.dummy.attachMovie(audio button, speechS+iBut, (1000+iBut)); //Assign properties. speechMC.audioID = btn.attributes[audioID]; speechMC.seqID = btn.attributes[seqID]; //add the onRelease functionality speechMC.onRelease = function() { trace(onRelease + this + audioID + this.audioID); if (this.seqID this.audioID) { playSequenceA(this.seqID, this.audioID); } else if (this.seqID) { playSequence(this.seqID); } else if (this.audioID) { playAudio(this.audioID); } //Generic button handling for rollover colours... fButtonOff(this); } } Also, when you rollover and it traces - does each clip have the same nm value - that will break it / not work. You could always use the _name value of the clip to find out what to change. Lehr, Theodore wrote: ALSO: (and this might be impacting my results... when I used this.nm it did not work at all... so I took this. out and just used nm, while it works they are all suing the last array member From: flashcoders-boun...@chattyfig.figleaf.com [flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Glen Pike [postmas...@glenpike.co.uk] 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 = [, 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.._alpha = 0; _root.mc1..mc2.onRollOver = function() { if (findValue(, arrayName) == 1) { _root.._alpha = 100; } } _root.mc1..mc2.onRollOut = function() { _root.._alpha=0; } Now, I have to repeat this code
Re: [Flashcoders] Minimizing Code: Logic Issue
That's the _name parameter Lehr, Theodore wrote: OK - I think I MAY have found a way - which leads me to another question: how can I grab the FULL name of an object (ie _level0.mc1.mc2.mc3) and substring it - like in the example, I want to extract mc2 from the path. From: flashcoders-boun...@chattyfig.figleaf.com [flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Glen Pike [g...@engineeredarts.co.uk] Sent: Tuesday, December 08, 2009 8:02 AM To: Flash Coders List Subject: Re: [Flashcoders] Minimizing Code: Logic Issue Hmm, Just to be clear. I guess you are creating a number of clips on which you set the alpha. Then you are using an equal number of clips that can be rolled over. When you rollover these clips, you set the alpha on the corresponding alpha clip. I can see why it might be using the last array member - that would be assigned the last time you loop through the array. You might want to add traces in a few more places - e.g. trace out the clip you are messing with, trace out it's name, etc. after you assigned it? Are you adding the clips programmatically - at runtime - or at authortime - in the IDE? Not 100%, but if you are adding them at authortime, you might not be able to add to their properties. I usually do a loop like below and attach symbols, then create properties on them, e.g. //Trimmed down example of adding a load of button clips for (iBut=0; iButsection.buttons.length; iBut++) { var btn:Object = section.buttons[iBut]; trace(button + btn.text + attributes: + btn.attributes[audioID] + , + btn.attributes[seqID] ); // create speech clip button var speechMC:MovieClip = this.speechButtons.dummy.attachMovie(audio button, speechS+iBut, (1000+iBut)); //Assign properties. speechMC.audioID = btn.attributes[audioID]; speechMC.seqID = btn.attributes[seqID]; //add the onRelease functionality speechMC.onRelease = function() { trace(onRelease + this + audioID + this.audioID); if (this.seqID this.audioID) { playSequenceA(this.seqID, this.audioID); } else if (this.seqID) { playSequence(this.seqID); } else if (this.audioID) { playAudio(this.audioID); } //Generic button handling for rollover colours... fButtonOff(this); } } Also, when you rollover and it traces - does each clip have the same nm value - that will break it / not work. You could always use the _name value of the clip to find out what to change. Lehr, Theodore wrote: ALSO: (and this might be impacting my results... when I used this.nm it did not work at all... so I took this. out and just used nm, while it works they are all suing the last array member From: flashcoders-boun...@chattyfig.figleaf.com [flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Glen Pike [postmas...@glenpike.co.uk] 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 = [, 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.._alpha = 0; _root.mc1..mc2.onRollOver = function() { if (findValue(, arrayName) == 1) { _root.._alpha = 100; } } _root.mc1..mc2.onRollOut = function() { _root.._alpha=0; } Now, I have to repeat
RE: [Flashcoders] Minimizing Code: Logic Issue
_name is giving me mc3 - I need mc2. My thought was if I could string the whole thing, I could extract it... From: flashcoders-boun...@chattyfig.figleaf.com [flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Glen Pike [g...@engineeredarts.co.uk] Sent: Tuesday, December 08, 2009 9:10 AM To: Flash Coders List Subject: Re: [Flashcoders] Minimizing Code: Logic Issue That's the _name parameter Lehr, Theodore wrote: OK - I think I MAY have found a way - which leads me to another question: how can I grab the FULL name of an object (ie _level0.mc1.mc2.mc3) and substring it - like in the example, I want to extract mc2 from the path. From: flashcoders-boun...@chattyfig.figleaf.com [flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Glen Pike [g...@engineeredarts.co.uk] Sent: Tuesday, December 08, 2009 8:02 AM To: Flash Coders List Subject: Re: [Flashcoders] Minimizing Code: Logic Issue Hmm, Just to be clear. I guess you are creating a number of clips on which you set the alpha. Then you are using an equal number of clips that can be rolled over. When you rollover these clips, you set the alpha on the corresponding alpha clip. I can see why it might be using the last array member - that would be assigned the last time you loop through the array. You might want to add traces in a few more places - e.g. trace out the clip you are messing with, trace out it's name, etc. after you assigned it? Are you adding the clips programmatically - at runtime - or at authortime - in the IDE? Not 100%, but if you are adding them at authortime, you might not be able to add to their properties. I usually do a loop like below and attach symbols, then create properties on them, e.g. //Trimmed down example of adding a load of button clips for (iBut=0; iButsection.buttons.length; iBut++) { var btn:Object = section.buttons[iBut]; trace(button + btn.text + attributes: + btn.attributes[audioID] + , + btn.attributes[seqID] ); // create speech clip button var speechMC:MovieClip = this.speechButtons.dummy.attachMovie(audio button, speechS+iBut, (1000+iBut)); //Assign properties. speechMC.audioID = btn.attributes[audioID]; speechMC.seqID = btn.attributes[seqID]; //add the onRelease functionality speechMC.onRelease = function() { trace(onRelease + this + audioID + this.audioID); if (this.seqID this.audioID) { playSequenceA(this.seqID, this.audioID); } else if (this.seqID) { playSequence(this.seqID); } else if (this.audioID) { playAudio(this.audioID); } //Generic button handling for rollover colours... fButtonOff(this); } } Also, when you rollover and it traces - does each clip have the same nm value - that will break it / not work. You could always use the _name value of the clip to find out what to change. Lehr, Theodore wrote: ALSO: (and this might be impacting my results... when I used this.nm it did not work at all... so I took this. out and just used nm, while it works they are all suing the last array member From: flashcoders-boun...@chattyfig.figleaf.com [flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Glen Pike [postmas...@glenpike.co.uk] 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 = [, 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
Re: [Flashcoders] Minimizing Code: Logic Issue
try using String(this) instead of this._name Lehr, Theodore wrote: _name is giving me mc3 - I need mc2. My thought was if I could string the whole thing, I could extract it... From: flashcoders-boun...@chattyfig.figleaf.com [flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Glen Pike [g...@engineeredarts.co.uk] Sent: Tuesday, December 08, 2009 9:10 AM To: Flash Coders List Subject: Re: [Flashcoders] Minimizing Code: Logic Issue That's the _name parameter Lehr, Theodore wrote: OK - I think I MAY have found a way - which leads me to another question: how can I grab the FULL name of an object (ie _level0.mc1.mc2.mc3) and substring it - like in the example, I want to extract mc2 from the path. From: flashcoders-boun...@chattyfig.figleaf.com [flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Glen Pike [g...@engineeredarts.co.uk] Sent: Tuesday, December 08, 2009 8:02 AM To: Flash Coders List Subject: Re: [Flashcoders] Minimizing Code: Logic Issue Hmm, Just to be clear. I guess you are creating a number of clips on which you set the alpha. Then you are using an equal number of clips that can be rolled over. When you rollover these clips, you set the alpha on the corresponding alpha clip. I can see why it might be using the last array member - that would be assigned the last time you loop through the array. You might want to add traces in a few more places - e.g. trace out the clip you are messing with, trace out it's name, etc. after you assigned it? Are you adding the clips programmatically - at runtime - or at authortime - in the IDE? Not 100%, but if you are adding them at authortime, you might not be able to add to their properties. I usually do a loop like below and attach symbols, then create properties on them, e.g. //Trimmed down example of adding a load of button clips for (iBut=0; iButsection.buttons.length; iBut++) { var btn:Object = section.buttons[iBut]; trace(button + btn.text + attributes: + btn.attributes[audioID] + , + btn.attributes[seqID] ); // create speech clip button var speechMC:MovieClip = this.speechButtons.dummy.attachMovie(audio button, speechS+iBut, (1000+iBut)); //Assign properties. speechMC.audioID = btn.attributes[audioID]; speechMC.seqID = btn.attributes[seqID]; //add the onRelease functionality speechMC.onRelease = function() { trace(onRelease + this + audioID + this.audioID); if (this.seqID this.audioID) { playSequenceA(this.seqID, this.audioID); } else if (this.seqID) { playSequence(this.seqID); } else if (this.audioID) { playAudio(this.audioID); } //Generic button handling for rollover colours... fButtonOff(this); } } Also, when you rollover and it traces - does each clip have the same nm value - that will break it / not work. You could always use the _name value of the clip to find out what to change. Lehr, Theodore wrote: ALSO: (and this might be impacting my results... when I used this.nm it did not work at all... so I took this. out and just used nm, while it works they are all suing the last array member From: flashcoders-boun...@chattyfig.figleaf.com [flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Glen Pike [postmas...@glenpike.co.uk] 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 = [, 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
RE: [Flashcoders] Minimizing Code: Logic Issue
I got it: object._parent._name From: flashcoders-boun...@chattyfig.figleaf.com [flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Glen Pike [g...@engineeredarts.co.uk] Sent: Tuesday, December 08, 2009 9:10 AM To: Flash Coders List Subject: Re: [Flashcoders] Minimizing Code: Logic Issue That's the _name parameter Lehr, Theodore wrote: OK - I think I MAY have found a way - which leads me to another question: how can I grab the FULL name of an object (ie _level0.mc1.mc2.mc3) and substring it - like in the example, I want to extract mc2 from the path. From: flashcoders-boun...@chattyfig.figleaf.com [flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Glen Pike [g...@engineeredarts.co.uk] Sent: Tuesday, December 08, 2009 8:02 AM To: Flash Coders List Subject: Re: [Flashcoders] Minimizing Code: Logic Issue Hmm, Just to be clear. I guess you are creating a number of clips on which you set the alpha. Then you are using an equal number of clips that can be rolled over. When you rollover these clips, you set the alpha on the corresponding alpha clip. I can see why it might be using the last array member - that would be assigned the last time you loop through the array. You might want to add traces in a few more places - e.g. trace out the clip you are messing with, trace out it's name, etc. after you assigned it? Are you adding the clips programmatically - at runtime - or at authortime - in the IDE? Not 100%, but if you are adding them at authortime, you might not be able to add to their properties. I usually do a loop like below and attach symbols, then create properties on them, e.g. //Trimmed down example of adding a load of button clips for (iBut=0; iButsection.buttons.length; iBut++) { var btn:Object = section.buttons[iBut]; trace(button + btn.text + attributes: + btn.attributes[audioID] + , + btn.attributes[seqID] ); // create speech clip button var speechMC:MovieClip = this.speechButtons.dummy.attachMovie(audio button, speechS+iBut, (1000+iBut)); //Assign properties. speechMC.audioID = btn.attributes[audioID]; speechMC.seqID = btn.attributes[seqID]; //add the onRelease functionality speechMC.onRelease = function() { trace(onRelease + this + audioID + this.audioID); if (this.seqID this.audioID) { playSequenceA(this.seqID, this.audioID); } else if (this.seqID) { playSequence(this.seqID); } else if (this.audioID) { playAudio(this.audioID); } //Generic button handling for rollover colours... fButtonOff(this); } } Also, when you rollover and it traces - does each clip have the same nm value - that will break it / not work. You could always use the _name value of the clip to find out what to change. Lehr, Theodore wrote: ALSO: (and this might be impacting my results... when I used this.nm it did not work at all... so I took this. out and just used nm, while it works they are all suing the last array member From: flashcoders-boun...@chattyfig.figleaf.com [flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Glen Pike [postmas...@glenpike.co.uk] 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 = [, 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
RE: [Flashcoders] Minimizing Code: Logic Issue
i've been following this thread and may have missed a critical detail, but why do you need to check an instances name against an array if all you want to change is its alpha? or if you have extra values you need to check can't you just assign them to each instance when you add the rollover behaviours? i put an example of what i mean on pastebin: http://pastebin.com/m1db46cee hope it helps and i haven't completely missed the point and wasted your time! david From: ted_l...@federal.dell.com To: flashcoders@chattyfig.figleaf.com Date: Tue, 8 Dec 2009 08:58:34 -0500 Subject: RE: [Flashcoders] Minimizing Code: Logic Issue OK - I think I MAY have found a way - which leads me to another question: how can I grab the FULL name of an object (ie _level0.mc1.mc2.mc3) and substring it - like in the example, I want to extract mc2 from the path. From: flashcoders-boun...@chattyfig.figleaf.com [flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Glen Pike [g...@engineeredarts.co.uk] Sent: Tuesday, December 08, 2009 8:02 AM To: Flash Coders List Subject: Re: [Flashcoders] Minimizing Code: Logic Issue Hmm, Just to be clear. I guess you are creating a number of clips on which you set the alpha. Then you are using an equal number of clips that can be rolled over. When you rollover these clips, you set the alpha on the corresponding alpha clip. I can see why it might be using the last array member - that would be assigned the last time you loop through the array. You might want to add traces in a few more places - e.g. trace out the clip you are messing with, trace out it's name, etc. after you assigned it? Are you adding the clips programmatically - at runtime - or at authortime - in the IDE? Not 100%, but if you are adding them at authortime, you might not be able to add to their properties. I usually do a loop like below and attach symbols, then create properties on them, e.g. //Trimmed down example of adding a load of button clips for (iBut=0; iButsection.buttons.length; iBut++) { var btn:Object = section.buttons[iBut]; trace(button + btn.text + attributes: + btn.attributes[audioID] + , + btn.attributes[seqID] ); // create speech clip button var speechMC:MovieClip = this.speechButtons.dummy.attachMovie(audio button, speechS+iBut, (1000+iBut)); //Assign properties. speechMC.audioID = btn.attributes[audioID]; speechMC.seqID = btn.attributes[seqID]; //add the onRelease functionality speechMC.onRelease = function() { trace(onRelease + this + audioID + this.audioID); if (this.seqID this.audioID) { playSequenceA(this.seqID, this.audioID); } else if (this.seqID) { playSequence(this.seqID); } else if (this.audioID) { playAudio(this.audioID); } //Generic button handling for rollover colours... fButtonOff(this); } } Also, when you rollover and it traces - does each clip have the same nm value - that will break it / not work. You could always use the _name value of the clip to find out what to change. Lehr, Theodore wrote: ALSO: (and this might be impacting my results... when I used this.nm it did not work at all... so I took this. out and just used nm, while it works they are all suing the last array member From: flashcoders-boun...@chattyfig.figleaf.com [flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Glen Pike [postmas...@glenpike.co.uk] 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 = [, 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
RE: [Flashcoders] Minimizing Code: Logic Issue
Here is the solution I came up with - a mishmosh of a few peoples help: var myStuff:Array = [a,b,c]; for (var i:Number=0; imyStuff.length; i++) { var nm:String = myStuff[i]; _root.mc1[nm].mc3.onRollOver = function() { changeViewOn(this); } _root.mc1[nm].mc3.onRollOut = function() { changeViewOff(this); } } function changeViewOn(mov) { _root[mov._parent._name].alpha=100; } function changeViewOff(mov) { _root[mov._parent._name].alpha=0; } Thanks! From: flashcoders-boun...@chattyfig.figleaf.com [flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of David Hunter [davehunte...@hotmail.com] Sent: Tuesday, December 08, 2009 9:22 AM To: flashcoders@chattyfig.figleaf.com Subject: RE: [Flashcoders] Minimizing Code: Logic Issue i've been following this thread and may have missed a critical detail, but why do you need to check an instances name against an array if all you want to change is its alpha? or if you have extra values you need to check can't you just assign them to each instance when you add the rollover behaviours? i put an example of what i mean on pastebin: http://pastebin.com/m1db46cee hope it helps and i haven't completely missed the point and wasted your time! david From: ted_l...@federal.dell.com To: flashcoders@chattyfig.figleaf.com Date: Tue, 8 Dec 2009 08:58:34 -0500 Subject: RE: [Flashcoders] Minimizing Code: Logic Issue OK - I think I MAY have found a way - which leads me to another question: how can I grab the FULL name of an object (ie _level0.mc1.mc2.mc3) and substring it - like in the example, I want to extract mc2 from the path. From: flashcoders-boun...@chattyfig.figleaf.com [flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Glen Pike [g...@engineeredarts.co.uk] Sent: Tuesday, December 08, 2009 8:02 AM To: Flash Coders List Subject: Re: [Flashcoders] Minimizing Code: Logic Issue Hmm, Just to be clear. I guess you are creating a number of clips on which you set the alpha. Then you are using an equal number of clips that can be rolled over. When you rollover these clips, you set the alpha on the corresponding alpha clip. I can see why it might be using the last array member - that would be assigned the last time you loop through the array. You might want to add traces in a few more places - e.g. trace out the clip you are messing with, trace out it's name, etc. after you assigned it? Are you adding the clips programmatically - at runtime - or at authortime - in the IDE? Not 100%, but if you are adding them at authortime, you might not be able to add to their properties. I usually do a loop like below and attach symbols, then create properties on them, e.g. //Trimmed down example of adding a load of button clips for (iBut=0; iButsection.buttons.length; iBut++) { var btn:Object = section.buttons[iBut]; trace(button + btn.text + attributes: + btn.attributes[audioID] + , + btn.attributes[seqID] ); // create speech clip button var speechMC:MovieClip = this.speechButtons.dummy.attachMovie(audio button, speechS+iBut, (1000+iBut)); //Assign properties. speechMC.audioID = btn.attributes[audioID]; speechMC.seqID = btn.attributes[seqID]; //add the onRelease functionality speechMC.onRelease = function() { trace(onRelease + this + audioID + this.audioID); if (this.seqID this.audioID) { playSequenceA(this.seqID, this.audioID); } else if (this.seqID) { playSequence(this.seqID); } else if (this.audioID) { playAudio(this.audioID); } //Generic button handling for rollover colours... fButtonOff(this); } } Also, when you rollover and it traces - does each clip have the same nm value - that will break it / not work. You could always use the _name value of the clip to find out what to change. Lehr, Theodore wrote: ALSO: (and this might be impacting my results... when I used this.nm it did not work at all... so I took this. out and just used nm, while it works they are all suing the last array member From: flashcoders-boun...@chattyfig.figleaf.com [flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Glen Pike [postmas...@glenpike.co.uk] 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
[Flashcoders] Minimizing Code: Logic Issue
OK - imagine: _root.._alpha = 0; _root.mc1..mc2.onRollOver = function() { if (findValue(, arrayName) == 1) { _root.._alpha = 100; } } _root.mc1..mc2.onRollOut = function() { _root.._alpha=0; } Now, I have to repeat this code like 50 times for 50 different movies with the '' being replaced by a different instance name My thought was to put the '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 Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
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 = [, 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.._alpha = 0; _root.mc1..mc2.onRollOver = function() { if (findValue(, arrayName) == 1) { _root.._alpha = 100; } } _root.mc1..mc2.onRollOut = function() { _root.._alpha=0; } Now, I have to repeat this code like 50 times for 50 different movies with the '' being replaced by a different instance name My thought was to put the '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 Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders -- Glen Pike 01326 218440 www.glenpike.co.uk http://www.glenpike.co.uk ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders