一、Application常用的事件
initialize=============>初始化
createcomplate==========>元素加載完
initialize發生在createcomplate之前。
二、數據請求說明
HTTPService==========>http數據請求。
SOAP(Simple Object Access Protocal)=======> webService
AMF(Adobe Action Message Format)========>Remote Object
三、Httpservice result格式
object
xml
flashvars
text
e4x
array
四、HTTPService的錯誤返回值說明
faultDetail錯誤細節,faultCode錯誤代碼,faultString錯誤文字描述。
message是以上三個屬性的集合。
五、自定義組件中的數據不要直接引用父容器的變量 ,而是要在父容器中給自定義組件設置屬性。如:
父容器的一個變量是能過httpservice取得的,暫且叫 goodList,
在自定義組件中要聲明一個public的變量,然後綁定到組件中的某個控件上。
public var dataList:ArrrayCollection
<mx:datagrid dataprovider="dataList"/>
在父容器中引用時: <comp:mycomp dataList="goodList"/>
六、利用標籤的形式創建自定義事件
1、首先在<metadata>標籤中聲名事件,如:
<mx:MetaData>
(Event(name="clickevent", type="flash.event.Event"))
</mx:MetaData>
2、派發事件。
3、直接在mx標籤中做爲屬性監聽此事件,如:
<mx:datagrid clickevent="clickHandler(event)">
4、要在自定義事件中傳遞參數,需要重寫clone方法,如:
>> 構造函數定義事件方法
clickevent(type:string,param1:string)
>> 重寫clone方法
override public function clone():Event{
return new clickevent(type,param1);
}
七、渲染(ItemRenderer)
1、內聯渲染的寫法
<mx:datagrid>
<mx:itemrenderer>
<mx:Component>
<mx:Image/> //這裏是要渲染的元素
</mx:Component>
</mx:itemrenderer>
</mx:datagrid>
2、對於獨立的渲染類,要更新數據,可以重寫data方法,如:
override public function set data(value:object)
可以用於字段爲空時,顯示的內容等
八、檢測圖片是否存在的方法
用UrlLoader,監聽Compleate(圖片存在)的IOError(圖片不存在)事件,不存在時可以用默認圖片代替
九、FB常用技巧
ctrl+shift+c 註釋MXML代碼段,及as代碼段
ctrl+shift+p 跳轉到大擴號的另一端
調整某行(或多行)的位置,可以用alt+上下箭頭
十、容器
viewstack 屬性 resizeToContent="true" 自動調節大小適應內容
引用id選中:content.selectedChild = id(id不要用引號)
顯示最後一個標籤頁內容
content.selectedIndex = numChildren - 1
ButtonBar(LinkBar、TabBar)與viewstack配合使用,viewstack中有幾個子元素,buttonbar將自動創建幾個按鈕。
<mx:ButtonBar dataprovider="{viewstack}"/>
將viewstack的每個子容器設置label屬性,buttonbar會自動找label屬性的值做爲按鈕的顯示。
如果想顯示圖標,設置子容器的icon屬性,如:icon="@Embed('assets/list.png')"
TabNavigator結合了TabBar與viewStack的功能,TabNavigator中直接包含子容器。
十一、嵌入圖像
(包括swf svg png jpg gif)
方法一:
<mx:Images source="@Embed('assets/globe.swf')"/> or
<mx:Images source="@Embed(source='assets/globe.swf')"/>
嵌入的swf可以是一段動畫
可以嵌入按鈕(Button)、影片剪輯(MovieClip)元件,不能嵌入圖片(Graphic)元件
嵌入flash中設計的多個元件,
爲flash中的元件導出,並設置class值(texticon)
在嵌入時<mx:Images source="@Embed(source='assets/globe.swf', symbol='texticon')"/> or
<mx:Images source="@Embed('assets/globe.swf#texticon')"/>
方法二:
mx:script中定義[Embed()]元數據
[Embed(source='assets/globe.swf')]
[Bindable]
private var TextIcon:Class;
<mx:Image source="{TextIcon}"/>
or
[Embed(source='assets/globe.swf')]
private var TextIcon:Class;
[Bindable]
private var icon1:MovieClipAsset = new TextIcon();
[Bindable]
private var icon2:MovieClipAsset = new TextIcon();
<mx:Image source="{icon1}"/>
<mx:Image source="{icon2}"/>
十二、嵌入字體
1、檢測已使用的是嵌入字體或設備字體
設置控件的rotation="45",如果仍然顯示,說明是嵌入字體,否則是設備字體。
[Embed(source="c:/Windows/Fonts/Justus-Roman.ttf", mimeType="application/x-font" fontName="fontJustus", fontWeight="bold")]
private var font1:Class;
<mx:label fontFamily="fontJustus"/>
2、利用css定義
<mx:Style>
.logofont{
fontFamily:fontJustus
}
</mx:Style>
3、可以利用字體名賦予systemFont屬性,查看字體名的方法:在windows目錄下找到字體,右鍵--屬性,名字選項卡,其中有字體名稱顯示。
如:
[Embed(systemFont="Justus", mimeType="application/x-font" fontName="fontJustus", fontWeight="bold")]
4、用@font-face嵌入字體,如:
<mx:Style>
@font-face{
src:url("c:/windows/Fonts/Justus.ttf")
fontFamily:"fontJustusRomain"
unicodeRange:"U+0061-U+007A" //用unicode編碼圈定字體範圍
}
</mx:Style>
or
<mx:Style>
@font-face{
src:local("Justus")
fontFamily:"fontJustusRomain"
}
</mx:Style>
5、利用flash cs3嵌入字體
在flash cs3中創建一個文本(動態文本),選擇希望用於的字體,單擊Embed按鈕,可以直接輸入字符(如:company,此時company這個單詞將被嵌入),發佈swf
在css中font-size的src直接引用導出的swf,此時的fontFamily要與在falsh中下拉框中選擇的字體同名。
十三、css
global{} //設置全局
css樣式提示(alt+>)
button的icon(upIcon、downIcon)可以是一個swf,用embed綁定元件,
skin(upSkin、downSkin)也可以是一個swf,skin會被拉伸至整個按鈕的大小
十四、
flash cs中定義元件,轉換爲組件後,在flex中引用,可以直接將button的icon值指向元件名,如:
icon="listbutton"
十五、安全沙箱,允許訪問本地文件
在編譯器自變量中加入 --use-network=false