‎2008 Nov 16 11:28 PM
Hi there,
I am building a Flex3 and ActionScript application. I need to build much of the UI dynamically so I am using ActionScript for this.
My problem is that I can't figure out how use constraint-based positioning for my components.
Take for example this MXML that instantiates a TitleWindow.
<mx:TitleWindow layout="absolute" id="myid" title="My Window" left="10" right="10" top="10" bottom="10">
</mx:TitleWindow>I can do the same thing in ActionScript...
var myTitleWindow:TitleWindow = new TitleWindow;
myTitleWindow.id = "myid";
myTitleWindow.layout = "absolute";
myTitleWindow.title="My Window";
this.addChild(myTitleWindow);...but I cannot figure out how to set the left, right, top bottom attributes. I have looked at the generated ActionScript from the MXML example and it uses the stylesFactory property of the mx.core.UIComponentDescriptor class but I can't figure out how to replicate this in my code.
As always I would appreciate anyones help with this.
Cheers
Graham Robbo
‎2008 Nov 16 11:55 PM
Hey Graham. Check this out.
var aComponent:yourComponent = new yourComponent();
var theStyle:CSSStyleDeclaration = new CSSStyleDeclaration();
theStyle.setStyle(u201Dtopu201D, 0);
theStyle.setStyle(u201Dbottomu201D, 0);
theStyle.setStyle(u201Dleftu201D, 0);
theStyle.setStyle(u201Drightu201D, 0);
theStyle.setStyle(u201DhorizontalCenteru201D, 0);
aComponent.styleDeclaration = theStyle;
Regards,
Rich Heilman
‎2008 Nov 16 11:55 PM
Hey Graham. Check this out.
var aComponent:yourComponent = new yourComponent();
var theStyle:CSSStyleDeclaration = new CSSStyleDeclaration();
theStyle.setStyle(u201Dtopu201D, 0);
theStyle.setStyle(u201Dbottomu201D, 0);
theStyle.setStyle(u201Dleftu201D, 0);
theStyle.setStyle(u201Drightu201D, 0);
theStyle.setStyle(u201DhorizontalCenteru201D, 0);
aComponent.styleDeclaration = theStyle;
Regards,
Rich Heilman
‎2008 Nov 17 12:08 AM
Thanks Rich - your response time is not bad either.
Cheers
Graham Robbo