views:

32

answers:

2

Hello,

I'm trying to create simple custom component with two labels with this MXML:

<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="250" height="30">

    <mx:String id="result" />

    <mx:Label x="5" y="7" id="titleLabel" text="{label}" width="120"/>
    <mx:Label x="125" y="7" id="resultLabel" text="{result}" width="120" textAlign="right" color="#A41D00"/>

</mx:Canvas>

It is working well at runtime, bud I have troubles making it working at design-time. How can I make databinding work at the design time? If it is impossible, how should I code the label text assignements?

A: 

Try with text={data.label} and text={data.result} instead of mere label and result.

jase21
Hello, jasie21, I've tried your code, but got "{data.label}" message instead of an actual label value...
Evan
A: 

You won't see the actual data at design time. I'm not exactly sure what you're going for but here's how you might code the Labels

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="100%" height="100%">

<mx:Script>
    <![CDATA[
        private var str : String = "Hello world";
    ]]>
</mx:Script>

<mx:Label x="5" y="7" id="titleLabel" text="{str}" width="120"/>
<mx:Label x="125" y="7" id="resultLabel" text="{titleLabel.text}" width="120" textAlign="right" color="#A41D00"/>

</mx:Application>
Brandon Cook