Type objectA as Object instead of UIComponent.

 


From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Libby
Sent: Wednesday, December 07, 2005 1:06 PM
To: [email protected]
Subject: [flexcoders] Re: Cast Object Name from string then do object.function() - is it possible?

 

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
>







--
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




Reply via email to