[Flashcoders] AttachMovieClip VS addChild
In an AS3 Project I have a MovieClip in the Library which class (identifier) is DataCard. My project fetches data from a database through a PHP File, and retruns data in an Array. Now in this project i wanted to do exactly what I used to do in AS2: for(i = 0; idataLength; i++) { var MC = this.attachMovieClip(DataCard, DataCard_ + i, this.getNextHighestDepth()); } in this case flash created as much DataCards Instances as the number of indexes in the Array. In AS3 I tried the follwoing for(var i = 0; idataLength; i++) { var DC:DataCard = new DataCard(); DC.y += 30; } What comes up is an only one instance of the movieClip as in one replaces the one before. Is there another way to achieve this? How can I add instance name to the MovieClip using the i from the loop? Thanks for the help. -- Omar M. Fouad - Digital Emotions http://www.omarfouad.net This e-mail and any attachment is for authorised use by the intended recipient(s) only. It may contain proprietary material, confidential information and/or be subject to legal privilege. It should not be copied, disclosed to, retained or used by, any other party. If you are not an intended recipient then please promptly delete this e-mail and any attachment and all copies and inform the sender. Thank you. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] AttachMovieClip VS addChild
Your code does what you're asking but I suspect you're having trouble with the positioning, or something similar. Since DC has no initial y, all instances will end up at 30, using the code below. Here's an adaptation that shows two visual results: position and trace, using the instance name request you mentioned. Note that, when adding an instance name programmatically, you can't refer that instance by name the same way you can when creating the instance name in the IDE. You must use getChildByName() instead. var dataLength:int = 5; for(var i = 0; idataLength; i++) { var DC:DataCard = new DataCard(); DC.x = Math.random()*550; DC.y = Math.random()*400; DC.name = dataCard + i; addChild(DC); trace(getChildByName(dataCard+i).name); } Rich In AS3 I tried the follwoing for(var i = 0; idataLength; i++) { var DC:DataCard = new DataCard(); DC.y += 30; } What comes up is an only one instance of the movieClip as in one replaces the one before. Is there another way to achieve this? How can I add instance name to the MovieClip using the i from the loop? ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] AttachMovieClip VS addChild
Thanks DUDE!!! The issue was in DC.name = dataCard + i; Didn't know the name property. Thanks On Sat, Mar 15, 2008 at 7:46 PM, Rich Shupe [EMAIL PROTECTED] wrote: Your code does what you're asking but I suspect you're having trouble with the positioning, or something similar. Since DC has no initial y, all instances will end up at 30, using the code below. Here's an adaptation that shows two visual results: position and trace, using the instance name request you mentioned. Note that, when adding an instance name programmatically, you can't refer that instance by name the same way you can when creating the instance name in the IDE. You must use getChildByName() instead. var dataLength:int = 5; for(var i = 0; idataLength; i++) { var DC:DataCard = new DataCard(); DC.x = Math.random()*550; DC.y = Math.random()*400; DC.name = dataCard + i; addChild(DC); trace(getChildByName(dataCard+i).name); } Rich In AS3 I tried the follwoing for(var i = 0; idataLength; i++) { var DC:DataCard = new DataCard(); DC.y += 30; } What comes up is an only one instance of the movieClip as in one replaces the one before. Is there another way to achieve this? How can I add instance name to the MovieClip using the i from the loop? ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders -- Omar M. Fouad - Digital Emotions http://www.omarfouad.net This e-mail and any attachment is for authorised use by the intended recipient(s) only. It may contain proprietary material, confidential information and/or be subject to legal privilege. It should not be copied, disclosed to, retained or used by, any other party. If you are not an intended recipient then please promptly delete this e-mail and any attachment and all copies and inform the sender. Thank you. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
[Flashcoders] attachMovieClip.
Dear Dave Yang, Since I'm used to mcExtends for movieclip instance on stage is associated to class, and it can pass parameters to constructor as well. Since Object.registerClass doesn't seem to let you passing any parameters to constructor. Is it possible to let mcExtends to work in AS 2.0 ? Regards, Wah Jong ___ 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