Since Flex' compiler thinks objectA is just a vanilla Object, it complains that bar() is an unknown method. That was why i needed to cast the real object to ObjectA. So how do I get this to work without importing every one of the hundred mxml files that could get passed in?
--- In [email protected], "JesterXL" <[EMAIL PROTECTED]> wrote: > > You don't need to cast via a function, you can do that already. While this > works: > > objectA = ViewStack.getChildAt(0); > objectA.bar(); > > Since Flex' compiler thinks objectA is just a vanilla Object, thus can't > imply it's type. However, if you want strict-typing, you can do: > > objectA = object1(ViewStack.getChildAt(0)); > objectA.bar(); > > This assumes object1 is an imported class. > > > ----- Original Message ----- > From: "Libby" <[EMAIL PROTECTED]> > To: <[email protected]> > Sent: Wednesday, December 07, 2005 1:00 PM > Subject: [flexcoders] Cast Object Name from string then do > object.function() - is it possible? > > > In Flex is there a way to pass an object name into a method and then > cast that name to another object in order to execute a method on that > object ? > > > foo("myMxmlObjectName"); > > function foo(object1:String) { > var objectA:UIComponent; > objectA = object1(ViewStack.getChildAt(0)); > objectA.bar(); > } > > Thanks, > Libby > > > > > > > > -- > Flexcoders Mailing List > FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt > Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com > Yahoo! Groups Links > ------------------------ Yahoo! Groups Sponsor --------------------~--> Get Bzzzy! (real tools to help you find a job). Welcome to the Sweet Life. http://us.click.yahoo.com/KIlPFB/vlQLAA/TtwFAA/nhFolB/TM --------------------------------------------------------------------~-> -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/flexcoders/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/

