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

keith <[email protected]> Fri, 19 Oct 2007 23:35:38 -0400
Newsgroups gmane.comp.web.flashcoders.devel
Message-ID <[email protected]>
Is there a reason you can't access the Sprite with the variable you 
first created?
cont.visible=false;

-- Keith H --




Alistair Colling wrote:
> Hiya everyone, good to see the list back up and running.
>
>  I'm trying to access a sprite that is inside of 2 other sprites and I 
> have 2 questions about this:
>
> 1) It seems that the syntax for targeting this sprite once it is 
> created is quite long winded (2 temporary vars have to be created):
>
> 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;
>
>
>
>
> 2) Also, I can't data type my target var as a Sprite otherwise I get 
> an error (unless I cast  the type as well).
>
> If anyone knows of a better of doing this I would be really interested 
> to hear it :)
> Cheers,
> Ali
>
>
>
> _______________________________________________
> Flashcoders mailing list
> [email protected]
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
>

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