If I want to pass a string to my custom component its pretty easy. Lets say
you have a custom button component and in that component you declare a
public var str, when you create your custom button you can simply do the
following.

<local:CustomButton str="Hello World"/>

This works fine, but If I create an object and I want to pass an object into
the custom component it does not seem to be working. The button is displayed
but the button label is not displayed. Here is a quick example to show what
I am doing.



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

    <mx:Script>
        <![CDATA[
            [Bindable]
            public var obj:Object;

            private function init():void {
                obj = new Object();
                obj.str="Hello Object";
            }
        ]]>
    </mx:Script>

    <local:Screen obj="{obj}"/>

</mx:Application>


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

    <mx:Script>
        <![CDATA[
            [Bindable]
            public var obj:Object = new Object();
        ]]>
    </mx:Script>

    <mx:Button label="{obj.str}"/>

</mx:Canvas>


--
Dan

Reply via email to