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; iBut<section.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 = ["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
>>> 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
> _______________________________________________
> 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

Reply via email to