Yes Tracy both of my 2 mxml (A and B) are in a directory /comps and both have this:

xmlns:comps="comps.*"

namespace reference. Maybe I missed something but it sounds correct as Flex code hinting lists me all my components as soon as I type down 'comps'.

LoginPanel was instanciated in a state of Main.mxml (the Application)

Here's Main.mxml:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
                xmlns:user="classes.*"
                xmlns:comps="comps.*" >

                <mx:states>
                        <mx:State name="connected">
                                <mx:RemoveChild target="{loginpanel1}"/>
                                <mx:AddChild position="lastChild">
                                        <comps:UserPanel >
                                        </comps:UserPanel>
                                </mx:AddChild>
                        </mx:State>
                </mx:states>

                <comps:LoginPanel id="loginpanel1">
                </comps:LoginPanel>

</mx:Application>



Here's what my mxml B (UserPanel) looks like ( User class is located in /classes dir)

<?xml version="1.0" encoding="utf-8"?>
<mx:Panel xmlns:        mx="http://www.adobe.com/2006/mxml";
                        xmlns:user="classes.*"
                        xmlns:comps="comps.*"
                        creationComplete="init()">

                <mx:Script>
                <![CDATA[
                        import classes.*;
                        private var user:User;

                        private function init():void{
                                ...
user=comps.LoginPanel.user //error 1119 at this line !!!
                                ...
                        }
                        ...
                ]]>
        </mx:Script>
        ...
</mx:Panel>



Again ,thank's all for your help ;)

Eric




At 2007-11-12   20:18, you wrote:

Hmm, "namespace" in this context makes me nervous. You want to access subcomponents via their "id", when that id is in scope. You do not use namespaces, unless I am misunderstanding your use of the word.



Show us a bit of code.  How are you instanitating "LoginPanel"?

Tracy



----------
From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of elr
Sent: Monday, November 12, 2007 6:27 PM
To: [email protected]
Subject: RE: [flexcoders] reference a class instance from another mxml



No Gordon. unfortunately my instance was public. I even defined a getter but no way:I still get an 1119 error in my second mxml (B) at line:

user=comps.LoginPanel.user;


where of course comps is the namespace targeting my LoginPanel.mxml



Eric

At 2007-11-12   17:05, you wrote:

When your login component created a User instance, did it store it in a public instance variable (say, 'user') of the login component? If so, it should be accessible as myLoginComponent.user.

- Gordon

----------
From: [email protected] [ mailto:[EMAIL PROTECTED] On Behalf Of elr
Sent: Sunday, November 11, 2007 5:03 PM
To: [email protected]
Subject: [flexcoders] reference a class instance from another mxml


HI,

I can't find a way to access from an mxml B to a class C that was
instanciated in a mxml A

In my sample. a login component (mxml A) instanciates a user:User
As soon as login is done, the second component (mxml B) should
retrieve the user instance

I referenced this user instance starting from component that composes
it (mxml A) but I always get a 1119 error:Access of possibly
undefined property user through a reference with static Class...

Thx for your help

Eric


Reply via email to