發表文章

Flex最底層的Application是一個Singleton Class

因此在app的任一個子物件中,用Application.application就可以access到最底層的屬性和物件了。換句話說,最底層的(public的)屬性和物件都是全域的,用一個最簡單的範例做demo。 主程式裡面有一個數字,可以按主程式的按鈕去累加。 main.mxml <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" xmlns:comp="comp.*"> <mx:Script> <![CDATA[ [Bindable] public var counter:int = 0; ]]> </mx:Script> <mx:Label text="'counter' property in flex app root:" /> <mx:Label text="{counter}" /> <mx:HBox> <mx:Label text="access 'counter' from root:" /> <mx:Button mouseDown="counter++;" label="plus"/> </mx:HBox> <comp:TestApplicationSingleton/> </mx:Application> 另外做一個組件,在組件內部可以直接access到主程式裡面那個累加的數字 comp/TestApplicationSingleton.mxml <?xml version="1.0" encoding="utf-8"?> <mx:Panel x...

在AIR裡放一個最精簡的Web Browser

如題。

Flex Log的使用方法

Flex有內建了一套將trace包裝得更高階的 Log Framework可以用。trace()是開發ActionScript的好伴侶,不過當有更高階的需要時又顯得太陽春。 Flex Log的兩大元件為Log和TraceTarget,TraceTarget相關類別是用來指定輸出的目的地,比如TraceTarget本身就是包裝了trace()命令。所以說也可以繼承target的相關類別,將輸出改為輸出到其他地方,如socket。Log則是用來輸出你的log紀錄。 <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="onComplete()"> <mx:Script> <![CDATA[ import mx.logging.LogEventLevel; import mx.logging.Log; import mx.logging.targets.TraceTarget; private var _target : TraceTarget; private function onComplete():void{ _target = new TraceTarget(); // _target.includeCategory = true; // 包含的輸出種類 // _target.includeDate = true; _target.includeTime = true; _target.includeLevel = true; _target.filters = ["com.*"]; // * 可用於過濾 // _target.level = LogEventLevel.ALL;  // 以下為各顯示層級,層級高低按照排列列出 // _target.level = LogEventLevel.DEBUG; _target.level ...

編譯Flex Module的方法

1. 在一般project中新增mxml module。不需特別去編譯,在編譯主application的時候就會被自動編譯 2. 新增一般的mxml檔,以module為最外層包裝,直接編譯該mxml就可以得到swf 3. 使用 mxmlc xxxModule.mxml 工具編譯。建立繼承自module的as class似乎只能用這方法 (編譯的參數可以參考 Compiling modules 這篇)

設定Flex Application FrameRate的方法

方法參考自  Flex tip: a higher frame rate even makes text entry look better   mxml 應用設定的方法 :application frameRate="60"> ActionScript 應用設定的方法 [SWF(frameRate="60")] public class MyApp extends Sprite { ... } 這篇文章也分享了一個重點,就是frame rate的高低其實對Flex內建組件的表現也有影響,更新變高其實也讓組件的回饋(ex:在TextInput打字後文字的顯示)變得更為靈敏。

用Flash開發Flex組件的方法

一搜尋就找到一篇Flash Evanglist寫的不錯的教學 Tutorial: The Flash and Flex marriage ,對我很有幫助。 個人筆記(ps:只記不知道的): When you’ve done that, go ahead and double click on the MyVideoPlayer movieclip. Create a new layer and draw a rectangle with the same size as your FLVPlayback component. Convert this in to a movieclip and specify it’s instance name to “boundingBox”. Once we use our component in Flex, it will not be visible. Flex will use this “boundingBox” movieclip to determine how big your component actually is .  If you’ve done that, we also need to add the player skin we’re using. This goes in to the src folder. So go ahead and drag “SkinOverAllNoFullNoCaption.swf” to the src folder   (play的skin的access路徑是跟著主swf的)  of your Flex project. 文章最後可以找到幾則相關的教學,也不錯 Video tutorial: Create Flex container components with Flash CS4