Works for me

-------------------- snip ---------------------------
<?xml version="1.0" encoding="utf-8"?>
<mx:Application
        xmlns:mx="http://www.adobe.com/2006/mxml";
        layout="vertical"
        preinitialize="createTestData()">
        <mx:Script>
                <![CDATA[
                
                        [Bindable]
                        private var itemManager : ItemManager = 
ItemManager.getInstance();
                        
                        private function createTestData() : void
                        {
                                for( var i:int = 0; i<10; i++)
                                {
                                        itemManager.addItem( new 
MyClassObject("test " + i));
                                }
                        }
                        
                ]]>
        </mx:Script>
        <mx:ComboBox dataProvider="{ itemManager.currentItems }" 
labelField="title"/>
        <mx:Label id="tmpLabel" text="{itemManager.currentItem.title}" />
</mx:Application>
-------------------- snip ---------------------------
package
{
        import mx.collections.ArrayCollection;
        
        public class ItemManager
        {
                
                [Bindable]
                public var currentItem : MyClassObject;
                
                [Bindable]
                public var currentItems : ArrayCollection;
                
                public function ItemManager()
                {
                        currentItems = new ArrayCollection();
                }
                
                public function addItem( item : MyClassObject ) : void
                {
                        currentItem = item;
                        currentItems.addItem( item );
                }
                
                private static var instance : ItemManager;
                
                public static function getInstance() : ItemManager
                {
                        if( instance == null ) instance = new ItemManager();
                        return instance;
                }
        }
}
-------------------- snip ---------------------------
package
{
        public class MyClassObject
        {
                [Bindable]
                public var title : String;
                
                public function MyClassObject( title : String )
                {
                        this.title = title;
                }
        }
}
-------------------- snip ---------------------------

Cheers,
Ralf.

On 7/20/06, Tim Hoff <[EMAIL PROTECTED]> wrote:
>
> Hi Tracy,
>
> I'm not sure if this will make any difference, but the entire Cairngorm
> ModelLocator class is Bindable instead of the individual variables.
> Perhaps this would make a difference with your model.
>
> -TH
>
>    [Bindable]
>   public class ModelLocator implements
> com.adobe.cairngorm.model.ModelLocator
>   {
>    private static var modelLocator:com.ets.main.model.ModelLocator;
>
>    public static function getInstance() : com.ets.main.model.ModelLocator
>    {
>     if ( modelLocator == null )
>      modelLocator = new com.ets.main.model.ModelLocator();
>
>     return modelLocator;
>      }
>
>
> //----------------------------------------------------------------------\
> ---
>
>       public function ModelLocator()
>       {
>        if ( com.ets.main.model.ModelLocator.modelLocator != null )
>      throw new Error( "Only one ModelLocator instance should be
> instantiated" );
>       }
>
> }
>
>
>
>
> --- In [email protected], "polestar11" <[EMAIL PROTECTED]> wrote:
> >
> > Hi there
> >
> > I have a class containing 2 variables, which I am trying to bind to a
> > seperate component. I am not using Cairngorm, although the structure
> > is quite similar, in that I have a component (view) that references
> > values in a singleton class (model)
> >
> > In the model-like class I have the following:
> >
> > public function addItem(item:MyClassObject) {
> > currentItem = item;
> > currentItems.addItem(item);
> > }
> >
> > [Bindable]
> > public var currentItem:MyClassObject;
> > [Bindable]
> > public var currentItems:ArrayCollection;
> >
> > In the view-like class I reference the variables like so:
> >
> > <ns1:MultiView id="multiView"
> dataProvider="{itemManager.currentItems}" />
> > <mx:Label id="tmpLabel" text="{itemManager.currentItem.title}" />
> >
> > In the script part of this component I reference the model-like class:
> > [Bindable]
> > public var itemManager:ItemManager = ItemManager.getInstance();
> >
> > My MultiView class is a custom component that takes the
> > ArrayCollection of 'currentItems' and adds them as children. There
> > might be a problem in this code preventing the associated children
> > from updating.
> >
> > The binding should however work for the label (tmpLabel).
> >
> > Any help much appreciated
> >
> > Tracy
> >
>
>
>
>
>
>
>
>
>
> --
> 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
>
>
>
>
>
>
>


-- 
Ralf Bokelberg <[EMAIL PROTECTED]>
Flex & Flash Consultant based in Cologne/Germany


------------------------ Yahoo! Groups Sponsor --------------------~--> 
Something is new at Yahoo! Groups.  Check out the enhanced email design.
http://us.click.yahoo.com/SISQkA/gOaOAA/yQLSAA/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/
 



Reply via email to