solved it, use binding utils... <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="onCreationComplete()"> <mx:Script> <![CDATA[ import mx.binding.utils.*; public var bindSetter:ChangeWatcher; public var sq2:Canvas; public function onCreationComplete():void { sq2 = new Canvas(); sq2.width = 10; sq2.height = 10; sq2.setStyle("backgroundColor", "#999999"); container.addChild(sq2); bindSetter = BindingUtils.bindSetter(watcherListener, container, "width", true); sq2.y = 100; } public function watcherListener(object:*):void { sq2.x = object / 4; } ]]> </mx:Script> <mx:Canvas id="container" width="100%" height="150" backgroundColor="#ffffff"> <mx:Canvas id="sq1" width="10" height="10" x="{container.width / 4}" y="50" backgroundColor="#000000"/> </mx:Canvas> </mx:Application>
--- In flexcoders@yahoogroups.com, "vixiom" <[EMAIL PROTECTED]> wrote: > > Is it possible to bind an ActionScript generated component's properties? > > In the example below 'sq1' will move when the browser is resized but > 'sq2' won't. > > <?xml version="1.0" encoding="utf-8"?> > <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" > layout="absolute" creationComplete="onCreationComplete()"> > <mx:Script> > <![CDATA[ > public function onCreationComplete():void > { > var sq2:Canvas = new Canvas(); > sq2.width = 10; > sq2.height = 10; > sq2.setStyle("backgroundColor", "#999999"); > container.addChild(sq2); > sq2.x = container.width / 4; > sq2.y = 100; > } > ]]> > </mx:Script> > <mx:Canvas id="container" width="100%" height="150" > backgroundColor="#ffffff"> > <mx:Canvas id="sq1" width="10" height="10" x="{container.width > / 4}" > y="50" backgroundColor="#000000"/> > </mx:Canvas> > </mx:Application> >