I want to seperate 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
//////////////////////////////////
%26lt;?xml version=''1.0'' encoding=''utf-8''?%26gt;
%26lt;mx:Application xmlns:mx=''
http://www.adobe.com/2006/mxml''
applicationComplete=''init()''%26gt;
%26lt;mx:Script%26gt;
%26lt;![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'')
}
]]%26gt;
%26lt;/mx:Script%26gt;
%26lt;mx:HDividedBox width=''100%'' height=''100%''%26gt;
%26lt;mx:Button id=''btn'' width=''100'' height=''100%''/%26gt;
%26lt;mx:Text id=''txt'' height=''100%'' width=''100%''/%26gt;
%26lt;/mx:HDividedBox%26gt;
%26lt;/mx:Application%26gt;
//////// 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)
}
}
}
( And why can't i see an attach code option in this message
form ? )
Subscribe to:
Post Comments
(Atom)
No comments:
Post a Comment