Re: Short syntax for accessing nested display objects? (AS3)

Rich Rainbolt <[email protected]> Sun, 21 Oct 2007 12:26:55 -0700
Newsgroups gmane.comp.web.flashcoders.devel
Message-ID <[email protected]>
Unsubscribe Remove
On Oct 19, 2007, at 9:30 PM, Troy Rollins wrote:

>
> On Oct 19, 2007, at 10:05 AM, Alistair Colling wrote:
>
>> var cont:Sprite = new Sprite();
>> this.addChild(cont);
>> var cont1:Sprite = new Sprite();
>> cont.addChild(cont1);
>> var child1:Sprite = new H1();
>>
>> var target =cont.getChildByName("cont1");
>> var targ2 = target.getChildByName("child1");	
>>
>> targ2._visible = false;
>
> Well, if you _really_ want to, you can do it with 1...
>
> //////////////////////////
> // This code will run in a frame script
> import flash.display.*;
>
> var cont:Sprite = new Sprite();
> cont.name = "cont"
> this.addChild(cont);
> var cont1:Sprite = new Sprite();
> cont1.name = "cont1"
>
> var child1:Sprite = new Sprite();
> child1.name = "child1"
> cont1.addChild(child1);
> cont.addChild(cont1);
>
>
> var childTest:Sprite = Sprite(cont.getChildByName 
> ("cont1")).getChildByName("child1") as Sprite;
> childTest.visible = true;
> trace(childTest.name + " " + childTest);
> stop();
> ///////////////////////////
>
> Of course, I effectively casted twice in one line, but hey...  ;-)
>
> --
> Troy
> RPSystems, Ltd.
> http://www.rpsystems.net
>
>
> _______________________________________________
> Flashcoders mailing list
> [email protected]
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders