Re: [Flashcoders] how to access mcs dinamically
> but in the descrived situation i must ommit the dot to get it to work, why's > that!?? because there are two ways of accessing a property (the parent has a property named "mc1" that references a movieclip). one way is to use a dot, the other to use a string (i.e. a variable of type String or a literal string "foo") inside []s. so, those three are the same thing: - myObject.myProperty; - myObject[ "myProperty" ]; - var prop:String = "myPro" + "perty"; myObject[ prop ]; you can even call methods: trace( Math[ "random" ]() ); hth, mark On 10/28/05, Jorge Rego <[EMAIL PROTECTED]> wrote: > Thanks all! :-) > > Just curious about this, > > if i want to access nested MCs "normally" i do it like this > > > theParentOfYourMCs.mc1.someProperty (with dots in between) > > but in the descrived situation i must ommit the dot to get it to work, why's > that!?? > > > theParentOfYourMCs[ "mc" + number ].someProperty > > Jorge Rego > > > > ___ > Flashcoders mailing list > Flashcoders@chattyfig.figleaf.com > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders > -- http://snafoo.org/ jabber: [EMAIL PROTECTED] ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] how to access mcs dinamically
Thanks all! :-) Just curious about this, if i want to access nested MCs "normally" i do it like this theParentOfYourMCs.mc1.someProperty (with dots in between) but in the descrived situation i must ommit the dot to get it to work, why's that!?? theParentOfYourMCs[ "mc" + number ].someProperty Jorge Rego ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] how to access mcs dinamically
On 28 Oct 2005, at 11:08, Roman Blöth wrote: ["mc_"+number].someProperty - when referencing mc's by name you have to put it in square brackets... Cool, you learn something everyday on here :> Goodbye eval()... ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] how to access mcs dinamically
["mc"+number].someProperty Cedric Hi list, I have some MCs named mc1, mc2, mc3 ... I'm trying to access them like this: mc[number].someProperty ... but no luck! How can this be done!? Jorge Rego ___ 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] how to access mcs dinamically
On 28 Oct 2005, at 11:08, Jorge Rego wrote: Hi list, I have some MCs named mc1, mc2, mc3 ... I'm trying to access them like this: mc[number].someProperty ... but no luck! How can this be done!? I use eval() eval("mc"+i).someProperty where i is some number perhaps a "more correct" way would be to generate the mc name into a variable, and then use the variable? tempVariable = eval("mc"+i); tempVariable.someProperty tempVariable.someOtherProperty ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] how to access mcs dinamically
On 10/28/05, Jorge Rego <[EMAIL PROTECTED]> wrote: > Hi list, > > I have some MCs named mc1, mc2, mc3 ... > I'm trying to access them like this: > > mc[number].someProperty ... but no luck! > > How can this be done!? *sigh*... There really should be a FlashCoders FAQ. You could do it like this: theParentOfYourMCs[ "mc" + number ].someProperty, but really, better loop through an array: var myMCs:Array = [ "mc1", "mc2", "mc3", ..., "mcN" ]; for( var i:String in myMCs ) myMCs[ i ].someProperty... That way you could give them meaningful names (e.g. topLeft, topRight...), or just push them on the array while you place them on stage dynamically. hth, mark -- http://snafoo.org/ jabber: [EMAIL PROTECTED] ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] how to access mcs dinamically
this["mc"+number].someProperty (assuming 'this' is the current timeline) On 10/28/05, Jorge Rego <[EMAIL PROTECTED]> wrote: > > Hi list, > > I have some MCs named mc1, mc2, mc3 ... > I'm trying to access them like this: > > mc[number].someProperty ... but no luck! > > How can this be done!? > ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] how to access mcs dinamically
Jorge Rego wrote: > Hi list, > > I have some MCs named mc1, mc2, mc3 ... > I'm trying to access them like this: > mc[number].someProperty ... but no luck! > > How can this be done!? just do it like this: ["mc_"+number].someProperty - when referencing mc's by name you have to put it in square brackets... regards, roman. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
[Flashcoders] how to access mcs dinamically
Hi list, I have some MCs named mc1, mc2, mc3 ... I'm trying to access them like this: mc[number].someProperty ... but no luck! How can this be done!? Jorge Rego ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders