1. 去除或改變Alert的模糊效果 以下樣式在Panel中定義
Alert,Panel{
modalTransparency: 0.0;
modalTransparencyBlur:0;
}
2.設定TitleWindow不允許拖動
//此處this指自定義視窗對象
PopUpManager.addPopUp(this, DisplayObject(Application.application), false);
PopUpManager.centerPopUp(this);
this.isPopUp = false;
3. 設定TabNavigator的标簽文本樣式
TabNavigator{tabStyleName:"tabStyle";}
tabStyle{fontWeight:normal;paddingLeft:8;paddingRight:8;}
4. 擷取螢幕分辨率
flash.system.Capabilities.screenResolutionX
flash.system.Capabilities.screenResolutionY
5. Label或LinkButton 的文本換行
actionscript中: label.text="aaa /r/n bbb"
mxml中: text="aaa bbb"
6. AS3 工程設定寬度、高度背景色等屬性
[SWF(width="640",height="480",backgroundColor="#00FFFF",frameRate="1")]
7. Label控件實作手型圖示
lbl.useHandCursor = true;
lbl.mouseChildren = false;
lbl.buttonMode = true;
8. 擷取Alert的使用者選擇
Alert.show('msg, 'ttile', Alert.YES | Alert.NO, null, onAlertClose);
private function onAlertClose(event:CloseEvent):void
{
if(event.detail == Alert.YES){trace('choose YES');}
if(event.detail == Alert.NO){trace('choose NO');}
}
9. 删除字元串中的空格等空白字元
var myurl:String = "w w w ./nc n b l o g s.com//triafans";
trace(myurl);
myurl = myurl.replace(//s/g, ''); //删除空格、回車、TAB等空白字元
trace(myurl);
10. 擷取使用者在Alert上的選擇
Alert.show('msg, 'ttile', Alert.YES | Alert.NO, null, onAlertClose);
private function onAlertClose(event:CloseEvent):void
{
if(event.detail == Alert.YES){trace('choose YES');}
if(event.detail == Alert.NO){trace('choose NO');}
}
11. Flex Builder用flashplayer直接運作swf檔案(不将swf嵌入網頁運作)
右鍵點選項目->Properties->Flex Compiler->取消勾選Generate HTML Wrapper file
12.Flash Player版本檢測
版本:Capabilities.version Capabilities.isDebugger ? ("調試版本") : ("正式版本");
13. 在Flex中重新整理浏覽器
var urlrequest:URLRequest = new URLRequest(Application.application.url);
navigateToURL(urlrequest, '_self');
14. 設定ToolTip持續顯示時間
ToolTipManager.hideDelay = 1000 * 60; //機關毫秒
15. BigEndian和LittleEndian測試的例子
var a:ByteArray = new ByteArray();
a.endian = flash.utils.Endian.BIG_ENDIAN;
a.writeShort(0x1234);
a.position = 0;
trace("0x"+a.readShort().toString(16));
a.position = 0;
a.endian = flash.utils.Endian.LITTLE_ENDIAN;
trace("0x"+a.readShort().toString(16));
16. Label 手形光标
<mx:Label label="測試" buttonMode="true" mouseChildren="false"/>
17. FMS 3.5 注冊序列号 1373-5015-2684-2742-8624-4730
18. DataFormatter formatString='YYYY/MM/DD JJ:NN:SS'
19.在不同swf檔案之間使用SharedObject
SharedObject.getLocal("config","/");
為避免意外限制對共享對象的通路,請使用 localpath 參數。允許級别最高的方法是将 localPath 設定為 /(斜杠),這樣做可使域中的所有 SWF 檔案都可通路該共享對象,但會增加與域中其它共享對象發生名稱沖突的可能性。限制級别較高的方法是向 localPath 追加 SWF 檔案完整路徑中的檔案夾名。例如,對于位于 www.myCompany.com/apps/stockwatcher.swf 的 SWF 檔案建立的 portfolio 共享對象,可以将 localPath 參數設定為/、/apps 或 /apps/stockwatcher.swf。您必須确定哪種方法能為您的應用程式提供最佳的靈活性。
轉自http://lqw.javaeye.com/blog/521329