Yes. Suppose you get a data item like
var item:Object = { type: "mx.controls.Button", properties: { label:
"OK", x: 100, y:100 } };
from the server. Then you can dynamically create a Button with this
label as follows:
import flash.utils.getDefinitionByName;
private function createComponentFromData(item:Object)
{
// Look up the Button class from its ful name,
"mx.controls.Button"
var c:Class = Class(getDefinitionByName(item.type));
// Create an instance of that class.
var component:UIComponent = new c();
// Set specified properties (in this case, label, x, and y.
for (var prop:String in item.properties)
{
component[prop] = item.properties[prop];
}
// Attach the new Button as a child of some container.
someContainer.addChild(component);
You will have to ensure that the code for the mx.controls.Button class
is actually present in your application. You can do this by simply
declaring a var of this type:
import mx.controls.Button;
private static var buttonDependency:Button;
- Gordon________________________________ From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Joseph Abenhaim Sent: Friday, March 16, 2007 11:24 AM To: [email protected] Subject: [flexcomponents] Dynamic component generation Hi, I would like to know if theres any way to create components dynamically using remoteobject and getting a reply from sql server. Thanks, ________________________________ Under Florida law, e-mail addresses are public records. If you do not want your e-mail address released in response to a public records request, do not send electronic mail to this entity. Instead, contact this office by phone or in writing.
<<attachment: image001.jpg>>
