一、自定义控件在主控件里的注册方法
在主应用程序的Application标签里首先加上 xmlns:admin="admin.*" 头一个admin是相当瑜mx,后一个admin指明自定义控件的目录。(这一步是注册控件)
添加自定义控件到desigh中写 <admin:AdminView id="adminCanvas" /> AdminView是那个自定义控件的名称。这样就把自定义控件加进去了
二、删除事件
要求:删除提示,弹出一个对话框,提示删除或取消
1、import popup.removeAlert; removeAlert是一个自定义控件,popup是它所在的文件夹
2、private var alertBox:removeAlert=new removeAlert();
3、当点击删除的时候,执行这个操作
alertBox.type="user";
alertBox.text_txt="Are you sure to remove the selected item ?";
alertBox.adminName="bb";
PopUpManager.addPopUp(alertBox, DisplayObject(parentApplication), true); //屏幕居中
PopUpManager.centerPopUp(alertBox);
三、事件传递
已知:alertBox是一个自定义控件,有一个属性是type
发送: public var type:String;
if (type == "admin")
{
dispatchEvent(new Event("removeAdmin"));
}
接收:在另外的一个mxml里面,alertBox监听发送过来的事件
alertBox.addEventListener(" removeAdmin ", removeAdminAfterConfirm);
当接收到事件后执行 removeAdminAfterConfirm()
四、根据textInput控件的text是否变化,并做出判断
已知:一个textInput控件已有文字,当更改后,提示是否保存或取消
1、 public var a1:String;
2、 <mx:TextInput id="ashostip_txt" change="{a1=true}"/>
3、if(a1==true) {}
五、flex的转页面(附带参数) 比如登陆例子
login.mxml界面 username是参数
1、import flash.net.SharedObject;
2、public var so:SharedObject=SharedObject.getLocal("mydata","/");
3、 var user:Object=new Object();
user.userName=name_txt.text;
so.data.user=user;
4、 ExternalInterface.call("function(username) {window.location.href='IMSAdminConsole_index.swf?a1='+username}", name_txt.text);
IMSAdminConsole.mxml界面
1、import flash.net.SharedObject;
2、public var so2:SharedObject=SharedObject.getLocal("mydata","/");
3、 public var wellcomString="wellcome to adminConsole," + so2.data.user.userName;