Flex開發技巧

1. 去除或改變Alert的模糊效果 以下樣式在Panel中定義
Alert,Panel{
  modalTransparency: 0.0;
  modalTransparencyBlur:0;
  /*modalTransparencyColor: #FF0000;
  modalTransparencyDuration: 1000;*/}

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。您必須確定哪種方法能爲您的應用程序提供最佳的靈活性。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章