Sunday, April 4, 2010

Binding - the best practices

Hi All,

I have 2 files:

1. application.mxml where I want to display some variables (properties) from the second file. I will display those variables mainly as debugging infos. I will mainly use %26lt;mx:Label%26gt; tags.

2. file.as is a class and the properties will have to be displayed in application.mxml. The instances of the class will be created during run time and not at the start.


My question is: How do I do this? I know that binding variables is the solution to this problem. Can you give me a clue and some direction how I start with it? Perhaps some working example will be a good start.

This is common problem I think, but I spent the whole day on studying lots of examples and I am confused now.

Best Regards

Chris

Binding - the best practices

If File.as looks like this:

Bindable

public class File

{

public var name:String = ''foo'';

}

You can get it in your app like this:

%26lt;mx:Application%26gt;

%26lt;mx:Script%26gt;

%26lt;![CDATA[

Bindable

private var aFile:File;

]]%26gt;

%26lt;/mx:Script%26gt;

%26lt;mx:Label text=''{aFile.name}'' /%26gt;

%26lt;/mx:Application%26gt;

Add some code to set aFile = new File() and you should see ''foo'' in the label

Alex Harui

Flex SDK Developer

Adobe Systems Inc.

Blog: http://blogs.adobe.com/aharui

No comments:

Post a Comment