开发者

Make a set of Flex components a unit

开发者 https://www.devze.com 2022-12-11 07:56 出处:网络
I\'d like to make a series of components into a solid, consistently repeatable object. For example, suppose I have a \"notification\" template that I want to add to a notifications area every time s

I'd like to make a series of components into a solid, consistently repeatable object.

For example, suppose I have a "notification" template that I want to add to a notifications area every time something new happens. This template includes an icon (Image), text (label), and some space between these two things.

I want to take a template like that and make it so I can invoke开发者_如何学编程 it with a function like add_notification("icon", "text"). How would I go about doing that?

Thanks in advance.


Create a mxml file for your component, e.g. MyComponent.mxml. Now you can do

var myComponent = new MyComponent() 

and add that component to your notifications area.

To set the label text you could have this in MyComponent.mxml

[Bindable]
public var label:String;
...

<mx:Label text="{label}" />

and set the label with

myComponent.label = "something";

or you could drop the bindable variable and go with

myComponent.labelid.text = "something"

after giving your mx:Label an id attribute

0

精彩评论

暂无评论...
验证码 换一张
取 消