The following code works for me

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

   <mx:Script>
      <![CDATA[
         [Bindable]
         private var userBind : User = User.getInstance();
      ]]>
   </mx:Script>

   <mx:Button label="{ userBind.fullname }" />

</mx:Application>

package
{
   [Bindable]
   public class User
   {
      public var fullname : String;

      public function User( inFullname : String )
      {
         fullname = inFullname;
      }

      private static var instance : User;

      public static function getInstance() : User
      {
         if( instance == null ) instance = new User("test");
         return instance;
      }
   }
}

In contrast to what i said before it works with getInstance() in the
binding as well.
Cheers
Ralf.

On Nov 23, 2007 9:00 PM, nxzone <[EMAIL PROTECTED]> wrote:
>
>
>
>
>
>
> Yes, all the class
>
>  --- In [email protected], "Ralf Bokelberg"
>  <[EMAIL PROTECTED]> wrote:
>  >
>  > Is fullname declared as bindable as well?
>  > Cheers
>  > Ralf.
>  >
>
>  > On Nov 23, 2007 8:05 PM, nxzone <[EMAIL PROTECTED]> wrote:
>  > >
>  > >
>  > >
>  > >
>  > >
>  > >
>  > > Thank you for you answer. But is not working...
>  > >
>  > > I tried this:
>  > >
>  > >
>  > > In User.AS
>  > > public static function setUser(u:User):void{
>  > > loggedUser=u;
>  > > }
>  > > public static function getInstance():User{
>  > > if(loggedUser==null){
>  > > loggedUser= new User(0,"Pas","
>  > > }
>  > > return loggedUser;
>  > > }
>  > >
>  > > In Myapp.mxml
>  > > [Bindable]
>  > > private var userBind:User = User.getInstance();
>  > >
>  > > <mx:Button id="btConnection" label="{userBind.fullname}"
>  > > click="openLoginWindow()" />
>  > >
>  > > But userBind is alway the same... When the user in static UserClass
>  > > change, userBind is not reflected :(.
>  > >
>  > > --- In [email protected], "Ralf Bokelberg"
>  > >
>  > > <ralf.bokelberg@> wrote:
>  > > >
>  > > > Binding is based on the name of a property, it doesn't work if
>  there
>  > > > is a method call involved.
>  > > > Assign the model returned by getInstance to a local bindable
>  property
>  > > > and bind to it instead.
>  > > > Cheers
>  > > > Ralf.
>  > > >
>  > > > On Nov 23, 2007 5:42 PM, nxzone <nxzone@> wrote:
>  > > > >
>  > > > >
>  > > > >
>  > > > >
>  > > > >
>  > > > >
>  > > > > Should i user a observer/watcher
>  > > > >
>  > > > >
>  > > > > --- In [email protected], "nxzone" <nxzone@> wrote:
>  > > > > >
>  > > > > > Why databinding is not working? User class in bindable. When I
>  > > set the
>  > > > > > new user, with setUser the fullname in Myapp in not changed.
>  > > > > >
>  > > > > > In User.AS
>  > > > > > public static function setUser(u:User):void{
>  > > > > > loggedUser=u;
>  > > > > > }
>  > > > > > public static function getInstance():User{
>  > > > > > if(loggedUser==null){
>  > > > > > loggedUser= new User(0,"Pas","
>  > > > > > }
>  > > > > > return loggedUser;
>  > > > > > }
>  > > > > > In Myapp.mxml
>  > > > > > <mx:Button id="btConnection"
>  label="{User.getInstance().fullname}"
>  > > > > > click="openLoginWindow()" />
>  > > > > >
>  > > > >
>  > > > >
>  > > >
>  > > >
>  > > >
>  > > > --
>  > > > Ralf Bokelberg <ralf.bokelberg@>
>  > >
>  > > > Flex & Flash Consultant based in Cologne/Germany
>  > > > Phone +49 (0) 221 530 15 35
>  > > >
>  > >
>  > >
>  >
>  >
>  >
>  > --
>
>  > Ralf Bokelberg <[EMAIL PROTECTED]>
>  > Flex & Flash Consultant based in Cologne/Germany
>  > Phone +49 (0) 221 530 15 35
>  >
>
>
>  



-- 
Ralf Bokelberg <[EMAIL PROTECTED]>
Flex & Flash Consultant based in Cologne/Germany
Phone +49 (0) 221 530 15 35

Reply via email to