Hi... What i want to manage is, seperating the code from the mxml completely. And here is my attempt but it is not working. I guess my problem is about adding the event listeners or setting the component id s in the class file. How should i change the code so that it works ? and any good practice advises are welcome. Thank you ...
///////////////////////// Code /////////////////////////////// ///////////////// MXML FILE ////////////////////////////////// <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" applicationComplete="init()"> <mx:Script> <![CDATA[ import mx.controls.Alert import lostchild.DirectoryBrowser private var lcModel:DirectoryBrowser private function init():void{ lcModel = new DirectoryBrowser() Alert.show("application complete", "Flex Debug") } ]]> </mx:Script> <mx:HDividedBox width="100%" height="100%"> <mx:Button id="btn" width="100" height="100%"/> <mx:Text id="txt" height="100%" width="100%"/> </mx:HDividedBox> </mx:Application> ///// DirectoryBrowser.as placed in the folder "lostchild"////// package lostchild{ import flash.events.MouseEvent import mx.controls.Button import mx.controls.Text import mx.controls.Alert public class DirectoryBrowser{ private var btn:Button = new Button() private var txt:Text = new Text() public function DirectoryBrowser():void{ setStuff() Alert.show("class loaded","class debug") } public function callAlert(evt:MouseEvent):void{ Alert.show("button clicked","debugging event handler") txt.text = "working fine" } public function setStuff():void{ btn.label = "just click!" txt.text = " i can't get to see this !" btn.addEventListener(MouseEvent.CLICK,callAlert) } } } _______________________________________________ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com