You need userObject to be [Bindable] and for this build that also means it needs to be public (this is in the application).

 

Matt

 


From: flexcoders@yahoogroups.com [mailto:flexcoders@yahoogroups.com] On Behalf Of Ralf Rottmann
Sent: Wednesday, November 30, 2005 4:13 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Passing Object to MXML Component?

 

I am trying to pass an Object to an MXML Component in Flex 2 Alpha. It seems not to work. Your help is greatly appreciated. Here is the scenario:

 

1.

I have added an AS Class File “UserObject.as”. In the main application I create an instance of UserObject:

 

<mx:Script>

      <![CDATA[

            import rottmann.net.*;

            import flash.events.*;

            import mx.controls.*;

           

            private var userObject:UserObject;             

           

            private function init():Void

            {

                  userObject = new UserObject();

            }

 

The private init() function is triggered by the applications creationComplete event. Debugger indicates that the userObject gets successfully created.

 

2.

I have added an MXML Component “Login.mxml” which mainly contains a couple of Label and TextInput controls. At the beginning of this MXML Component I have added a private property to hold the UserObject:

 

<mx:Script>

      <![CDATA[

            import rottmann.net.*;

            import mx.controls.*;

            import mx.events.*;

 

            var u:UserObject;

 

 

3.

Now, back in the main application I use the MXML Component as follows:

 

<rottmann:Login u="{this.userObject}"/>

 

My assumption was, that the u=”{this.userObject}” passes the instance of my main application UserObject object to the MXML Component and inside the MXML Component I could access properties of this object via

 

u.getLastname();

etc.

 

However the Debugger tells me, that u is null in the MXML Component.

What’s going wrong?

 

Ralf Rottmann

 




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




Reply via email to