In AS3, how can I instantiate a class, com.foo.MyClass, using the string "com.foo.MyClass"? The reason I ask is that I'd like to load an XML file and use it to dynamically create components at runtime. Something like this:
<components>
<component className="com.foo.MyClass" x="100" y="100"/>
<component className="com.foo.MyClass" x="100" y="100"/>
</components>
Thanks,
Tom
Whoa.... not only is there no eval(), there's no _target, no _level0, and no _global! Plus, you should almost always use Sprite instead of MovieClip.
So what are you really trying to do? Are you using Flex or just pure AS3? Where are you getting a string like "sprite1.sprite2.sprite3" from? Why do you have to transform it back into a Sprite reference? Could you have just kept the reference instead of the string?
- Gordon
From: flexcoders@yahoogroups.com [mailto:flexcoders@yahoogroups.com] On Behalf Of Boon Chew
Sent: Friday, March 03, 2006 3:41 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] eval gone in AS3, how to get reference to movieclip via target name?
Hi all,
With the _eval being gone in AS3, does anyone know how to get to the reference of a movieclip (via the target name string) without using _eval (e.g. "_level0.mc1.mc2.mc3") ? I know we can instantiate an object from a class name string via the _global namespace but not positive about mc's.
Thanks.
- boon
Yahoo! Mail
Bring photos to life! New PhotoMail makes sharing a breeze.
--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
SPONSORED LINKS
Web site design development Computer software development Software design and development Macromedia flex Software development best practice
YAHOO! GROUPS LINKS
- Visit your group "flexcoders" on the web.
- To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service .
--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
Web site design development | Computer software development | Software design and development |
Macromedia flex | Software development best practice |
YAHOO! GROUPS LINKS
- Visit your group "flexcoders" on the web.
- To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.