RE: [Flashcoders] access movieclip trough a class
You must defined the variable first in your class before using it. class Holder extends MovieClip { private var mc1:MovieClip; function Holder() { mc1._x = 50; } } that way you won't get any compiler errors Alain -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of ntasky Sent: 29 janvier 2007 14:32 To: Flashcoders mailing list Subject: [Flashcoders] access movieclip trough a class i have a movieClip holder that contains other child movieClips (mc1, mc2, mc3...) created in the flash interface. From the librairie i linked themovieClip holder to this Class. class Holder extends MovieClip{ //constructor function Holder(){ mc1._x=50 } } But it says mc1 is undefined.Well, it is undefined in the class but it is in the movieClip which is linked to. I was just wondering if i can access the movie clips created in the interface trought the linked class and how. don't know if i was clear :) thx N. ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.1.410 / Virus Database: 268.17.14/657 - Release Date: 2007-01-29 ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] access movieclip trough a class
Simply define class members with the instance names of your movie clips on the stage: class Holder extends MovieClip { private var mc1: MovieClip; function Holder() { mc1._x = 50; } } n i have a movieClip holder that contains other child movieClips (mc1, mc2, n mc3...) created in the flash interface. From the librairie i linked themovieClip holder to this Class. n n class Holder extends MovieClip{ n //constructor n function Holder(){ n mc1._x=50 n } n } n n But it says mc1 is undefined.Well, it is undefined in the class but it is in n the movieClip which is linked to. n I was just wondering if i can access the movie clips created in the n interface trought the linked class and how. n don't know if i was clear :) ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] access movieclip trough a class
You may have to wait for the child clips to initialise: Make sure your load order is set to bottom up in the publish settings, then try to initialise your child clips in the onLoad function. class Holder { /** ... */ function onLoad() { mc1._x = 50; mc2._x = ... mc3._x = ... } } If that does not work, you may want to add a register function in the Holder clip. And create a class for your children which calls the register function. class Holder { /** ... */ function register(child:MovieClip) { if(child == mc1) { mc1._x = 50; } else if(child == mc2) { mc2._x = ... } else { mc3._x = ... } } } class Child extends MovieClip { /** ... */ function onLoad() { this._parent.register(this); } } HTH G ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com