1.9 Tree Ò»¸öʹÓÃXML×÷ΪTree×é¼þÊý¾ÝÔ´µÄСÀý×Ó
Ê÷ÐÍ×é¼þ£¬ÊÇList ±äÒìºóµÄ²úÎï¡£ÔÚÏÔʾÊý¾Ýʱ±£ÁôÁ˲㼶½á¹¹£¬Ã¿¸öÔªËض¼ÊÇÒ»¸ö·ÖÖ§»òÕßÒ¶×Ó£¬·ÖÖ§°üº¬ÆäËû·ÖÖ§»òÒ¶×Ó£¬Ò¶×Ó²»¿ÉÔÙ·Ö¡£
½á¹¹ºÍXMLÒ»Ñù£¬ËùÒÔÓÃXML ×÷ΪTreeµÄÊý¾ÝÔ´ÔÙÊʺϲ»¹ýÁË¡£
?
treeµÄʼþ£º
change ÔÚÑ¡ÖÐÁиıäʱ´¥·¢¡£
itemClick µã»÷ijһÁÐʱ±»´¥·¢¡£
itemOpen ¡¢itemClose ÔÚ½ÚµãÕ¹¿ªºÍ¹Ø±Õʱ´¥·¢¡£
?
ÊôÐÔ£º
labeField ±íʾÏÔʾµÄÎı¾Ëù¶ÔÓ¦µÄXML×ֶΣ¬ÕâÀïµÄֵΪ@label £¬
@ ·ûºÅ±íʾºóÃæµÄÃû×ÖÊÇXML½ÚµãµÄÊôÐÔÃû£¬ÊÇAS3 ÖеÄXMLÊý¾ÝµÄרÓñí´ï·½Ê½¡£
@label Ö¸µÃÊÇfolder ½ÚµãÖеÄlabel ÊôÐÔ¡£
?
change="treeChanged(event) ½Úµã¸Ä±äʼþ
ÔÚtreeChanged ¼àÌýº¯ÊýÖУ¬Í¨¹ýTree µÄselectedItem ÊôÐԵõ½µ±Ç°±»Ñ¡ÖнڵãµÄXML Êý¾Ý¡£
Tree(event.target) Ç¿Öƽ« event.target ת»»³É Tree ÀàÐÍ¡£event.target ´ú±íµÄ¾ÍÊÇTree¡£
as ²Ù×÷·û ÊÇÀàÐÍת»»·û£¬ÓÃÀ´½«selectedItem µÄֵת»»ÎªXML ÀàÐÍ¡£Èç¹ûÀàÐÍÆ¥Åä·µ»Ø¸ÃÀàÐ͵ÄÖµ£¬·ñÔò·µ»Ønull ¡£
?
itemClick="clickItem(event)" µ¥»÷½Úµãʼþ
ÆäʵitemClick ʼþ°üÀ¨ÁËchange ʼþ£¬Òò´ËtreeChanged ²¢²»»á±»Ö´ÐС£
- ??
- <mx:application?xmlns:mx="http: www.adobe.com="" 2006="" mxml"?layout="absolute" ?fontsize="12">????<mx:script>??
- ????????
- ????????????import?mx.events.TreeEvent; ?
- ????????????import?mx.events.ListEvent ?
- ???????????? ?
- ????????????public?var?selectedNode:XML; ?
- ????????????// ?
- ????????????public?function?treeChanged(event:Event):void?{ ?
- ????????????????selectedNode=Tree(event.target).selectedItem?as?XML;???????????????? ?
- ????????????????//res_txt.text?=?"Ñ¡ÔñµÄÎļþ¼Ð£º"+selectedNode.@label ?
- ????????????} ?
- ????????????internal?function?clickItem(evt:ListEvent):void{ ?
- ????????????????res_txt.text?=?"µã»÷µÄ½Úµã£º"+evt.rowIndex ?
- ????????????} ?
- ????????????internal?function?openItem(evt:TreeEvent):void{ ?
- ????????????????res_txt.text?=?"´ø¿ªµÄ½Úµã£º"+evt.item ?
- ????????????} ?
- ????????????internal?function?closeItem(evt:TreeEvent):void{ ?
- ????????????????res_txt.text?=?"¹Ø±ÕµÄ½Úµã£º"+evt.item ?
- ????????????} ?
- ????????]]>??
- ????</mx:script>??
- ????<mx:xmllist?id="files">??
- ????????<folder?label="c:">??
- ????????????<folder?label="my?documents">??
- ????????????????<folder?label="adobe">??
- ????????????</folder>??
- ????????????<folder?label="windows">??
- ????????????????<folder?label="soft">??
- ????????????????<folder?label="drive">??
- ????????????</folder>??
- ????????????<folder?label="image">??
- ????????????<folder?label="music">??
- ????????</folder>???? ??
- ????</mx:xmllist>??
- ????<mx:tree?id="mytree"?width="165"?height="265"?labelfield="@label"?itemrenderer="nodeitem"??< li="">
- ????????????????showRoot="true"?dataProvider="{files}"?itemClick="clickItem(event)"?itemOpen="openItem(event)"?itemClose="closeItem(event)"?change="treeChanged(event)"?x="38"?y="40"/>??
- ????<mx:textarea?id="res_txt"?x="211"?y="40"?height="197">? ??
- </mx:application>??
<mx:application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" fontsize="12"> <mx:script> </mx:script> <mx:xmllist id="files"> <folder label="C:"> <folder label="My Documents"> <folder label="Adobe"> </folder> <folder label="Windows"> <folder label="soft"> <folder label="drive"> </folder> <folder label="Image"> <folder label="Music"> </folder> </mx:xmllist> <mx:tree id="myTree" width="165" height="265" labelfield="@label" itemrenderer="nodeItem" showroot="true" dataprovider="{files}" itemclick="clickItem(event)" itemopen="openItem(event)" itemclose="closeItem(event)" change="treeChanged(event)" x="38" y="40"> <mx:textarea id="res_txt" x="211" y="40" height="197"> </mx:application>?
Tree ĬÈϲÉÓõÄitemRendererÊÇ mx.controls.treeClasses °üÖеÄTreeItemRenderer Àà¡£½Ó×ÅÎÒÃÇÀ´À©Õ¹Ê¹ÓÃËü¡£
data ·½·¨ÊÇ itemRenderer »ñµÃÊý¾ÝµÄºËÐÄ·½·¨£¬ÖØдÕâ¸ö·½·¨£¬²¢¼òµ¥ÐÞ¸ÄÁ˽ڵãÎÄ×ÖµÄÑÕÉ«¡£
- package ??
- { ??
- ????import?mx.controls.treeClasses.*; ??
- ????import?mx.collections.*; ??
- ???? ??
- ??
- ????public?class?nodeItem?extends?TreeItemRenderer ??
- ????{ ??
- ????????//??????? ??
- ????????public?function?nodeItem()?{ ??
- ????????????super(); ??
- ????????} ??
- ????????//ÕâÊǽÓÊÕÍⲿÊý¾ÝµÄºËÐÄ·½·¨??????? ??
- ????????override?public?function?set?data(value:Object):void?{ ??
- ????????????super.data?=?value; ??
- ????????????//ÅжÏÊÇ·ñ»¹ÓÐ×ӽڵ㣬²ÉÓò»Í¬µÄÑÕÉ«ºÍ×ÖÑù ??
- ????????????if(TreeListData(super.listData).hasChildren) ??
- ????????????{ ??
- ????????????????setStyle("color",?0x006699); ??
- ????????????????setStyle("fontWeight",?'bold'); ??
- ????????????} ??
- ????????????else ??
- ????????????{ ??
- ????????????????setStyle("color",?0x000000); ??
- ????????????????setStyle("fontWeight",?'normal'); ??
- ????????????}?? ??
- ????????} ??
- ????} ??
- }??
package{ import mx.controls.treeClasses.*; import mx.collections.*; public class nodeItem extends TreeItemRenderer { // public function nodeItem() { super(); } //ÕâÊǽÓÊÕÍⲿÊý¾ÝµÄºËÐÄ·½·¨ override public function set data(value:Object):void { super.data = value; //ÅжÏÊÇ·ñ»¹ÓÐ×ӽڵ㣬²ÉÓò»Í¬µÄÑÕÉ«ºÍ×ÖÑù if(TreeListData(super.listData).hasChildren) { setStyle("color", 0x006699); setStyle("fontWeight", 'bold'); } else { setStyle("color", 0x000000); setStyle("fontWeight", 'normal'); } } }}?
1.10 TileList ºÍ HorizontalList
TileList ºÍ ÈÝÆ÷Tile ûÓÐÁªÏµ£¬²»¹ýÁ½ÕßʵÏÖµÄЧ¹û»ù±¾ÏàËÆ£¬¶¼ÊDzÉÓÿéµÄÐÎʽ²¼¾Ö¡£TileList = Tile + List
columnCount ÊôÐÔÓÃÀ´É趨ÿÐÐÏÔʾµÄÔªËظöÊý£¬×é¼þ¸ù¾ÝÿÐеĸöÊý×Ô¶¯¼ÆËã³öÔªËصÄλÖá£
- ??
- <mx:application?xmlns:mx="http: www.adobe.com="" 2006="" mxml"?layout="absolute">??
- ????<mx:style?source?="style.css">??
- ????<mx:model?id="images">??
- ??????<image>??
- ????????<item?label="ͼƬ1"?data="images baby01.gif"=""/>??
- ????????<item?label="ͼƬ2"?data="images baby02.gif"=""/>??
- ????????<item?label="ͼƬ3"?data="images baby03.gif"=""/>??
- ????????<item?label="ͼƬ4"?data="images baby04.gif"=""/>??
- ????????<item?label="ͼƬ5"?data="images baby01.gif"=""/>??
- ????????<item?label="ͼƬ6"?data="images baby02.gif"=""/>??
- ????????<item?label="ͼƬ7"?data="images baby03.gif"=""/>??
- ????????<item?label="ͼƬ8"?data="images baby04.gif"=""/>??
- ??????</image>??
- ????</mx:model>??
- ????<mx:tilelist?itemrenderer="imageitem"?x="29"?y="49"?height="196"?columncount="3"?dataprovider="{images.item}">??
- ????</mx:tilelist>???? ??
- </mx:application>??
<mx:application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"> <mx:style source="style.css"> <mx:model id="images"> <image> <item label="ͼƬ1" data="images/Baby01.gif"> <item label="ͼƬ2" data="images/Baby02.gif"> <item label="ͼƬ3" data="images/Baby03.gif"> <item label="ͼƬ4" data="images/Baby04.gif"> <item label="ͼƬ5" data="images/Baby01.gif"> <item label="ͼƬ6" data="images/Baby02.gif"> <item label="ͼƬ7" data="images/Baby03.gif"> <item label="ͼƬ8" data="images/Baby04.gif"> </image> </mx:model> <mx:tilelist itemrenderer="ImageItem" x="29" y="49" height="196" columncount="3" dataprovider="{images.item}"> </mx:tilelist> </mx:application>
?
´´½¨itemRenderer À´¶¨Òåÿ¸öÔªËصĽçÃæ¡£
data.data¶ÔÓ¦Êý¾ÝÔ´ÖÐitem.data
data.label¶ÔÓ¦Êý¾ÝÔ´ÖÐitem.label
- ??
- <mx:vbox?xmlns:mx="http: www.adobe.com="" 2006="" mxml"?width="98" ?height="64" ?horizontalalign="center">??
- ????<mx:image?width="32"?height="32"?source="{data.data}">??
- ????<mx:button?x="38"?y="40"?label="{data.label}">??? ??
- </mx:vbox>??
<mx:vbox xmlns:mx="http://www.adobe.com/2006/mxml" width="98" height="64" horizontalalign="center"> <mx:image width="32" height="32" source="{data.data}"> <mx:button x="38" y="40" label="{data.label}"> </mx:vbox>?
1.11 Îı¾´¦Àí
Îı¾´¦Àí×é¼þ£º
Text£º ¿ÉÒÔʹÓÃHTML²»¹ýÒª½èÖúhtmlText ±êÇ©»ò htmlText ÊôÐÔ¡£²åÈëHTML´úÂëʱÐèҪʹÓÃCDATA±êÇ©¡£
TextArea£º editableÊôÐÔΪtrueʱ£¬Ï൱ÓÚÒ»¸öÖ§³Ö¶àÐеÄTextInput¡£Ö§³ÖHTMLºÍÄÚÖùö¶¯Ìõ¡£
TextInput ºÍ RichTextEditor ÒÔ¼° Label
?
- ??
- <mx:application?xmlns:mx="http: www.adobe.com="" 2006="" mxml"?layout="absolute">??
- ???? ??
- ????<mx:style>??
- ????????Application{ ??
- ????????????fontSize:12;???? ??
- ????????????backgroundGradientColors:?#c0c0c0,?#c0c0c0; ??
- ????????} ??
- ????</mx:style>??
- ??
- ????<mx:text?x="51"?y="56"?width="253"?height="23"?text="¼òµ¥Îı¾">??
- ???? ??
- ????<mx:textarea?x="51"?y="96"?text="Îı¾Çø"?editable="false"?width="172"?height="48">??
- ????<mx:textinput?x="51"?y="171"?text="ÊäÈë¿ò"?displayaspassword="true">??
- ??
- ????<mx:text?width="253"?height="96"?x="51"?y="226">??
- ????????<mx:htmltext>??
- ????????????HTMLÎı¾?Ö§³Öhtml±êÇ©<img?src="images baby01.gif"=""/>...??]]>??
- ????????</mx:htmltext>??
- ????</mx:text>??
- </mx:application>??
<mx:application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"> <mx:style> Application{ fontSize:12; backgroundGradientColors: #c0c0c0, #c0c0c0; } </mx:style> <mx:text x="51" y="56" width="253" height="23" text="¼òµ¥Îı¾"> <mx:textarea x="51" y="96" text="Îı¾Çø" editable="false" width="172" height="48"> <mx:textinput x="51" y="171" text="ÊäÈë¿ò" displayaspassword="true"> <mx:text width="253" height="96" x="51" y="226"> <mx:htmltext> HTMLÎı¾ Ö§³Öhtml±êÇ©... ]]> </mx:htmltext> </mx:text></mx:application>?
1.12 Ò»¸öÇ¿ÓÐÁ¦µÄ×é¼þ -- RichTextEditor
ËüʵÏÖÁËHTMLËùÓй¦ÄÜ¡£
ÊÇÒ»¸ö¼¯³ÉÁËÎı¾´¦Àí¹¦ÄܵÄPanel×é¼þ£¬Ö÷Òª°üÀ¨£ºTextArea Îı¾Çø ºÍ ¿ØÖÆÎÄ×Ö¸ñʽµÄÈÝÆ÷¡£
ÔÚÈÝÆ÷ÖаüÀ¨ÁËÆäËûµÄ×é¼þ£¬Èç ×ÖÌåÑ¡ÔñµÄComboBox ¡¢Ñ¡ÔñÎı¾ÑÕÉ«µÄ ColorPicker ¡¢Ñ¡ÔñÎı¾¶ÔÆ뷽ʽµÄToggleButtonBar µÈµÈ¡£
- ??
- <mx:application?xmlns:mx="http: www.adobe.com="" 2006="" mxml"?layout="absolute" ?width="442" ?height="420">??
- ????<mx:richtexteditor?x="10"?y="10"?width="403"?height="281"?id="myrich">??
- ????</mx:richtexteditor>??
- ????<mx:textarea?id="output_txt"?x="10"?y="309"?width="330"?height="101">??
- ???? ??
- ????<mx:button?x="348"?y="308"?label="²é¿´Îı¾"?click="output_txt.text=?myrich.text">??
- ????<mx:button?x="348"?y="388"?label="html´úÂë"?width="70"?click="output_txt.text=?myrich.htmltext">??
- ???? ??
- </mx:application>??
<mx:application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="442" height="420"> <mx:richtexteditor x="10" y="10" width="403" height="281" id="myRich"> </mx:richtexteditor> <mx:textarea id="output_txt" x="10" y="309" width="330" height="101"> <mx:button x="348" y="308" label="²é¿´Îı¾" click="output_txt.text= myRich.text"> <mx:button x="348" y="388" label="HTML´úÂë" width="70" click="output_txt.text= myRich.htmlText"> </mx:application>?
1.13 É豸×ÖÌåºÍǶÈë×ÖÌåµÄÓ¦ÓÃʵÀý
É豸×ÖÌ壺Óû§»úÆ÷ÉÏËùÓÐ×ÖÌ嶼×î´ó¿ÉÄܵØÄ£ÄâÆäÍâ¹Û£¬±£³ÖÎı¾µÄÑùʽ²»»á³öÏֽϴó±ä»¯¡£Ö§³ÖÈýÖÖÉ豸×ÖÌ壺_sans, _serif, _typewriter¡£
É豸×ÖÌå±ØÐëʹÓÃÒýºÅ""°üº¬¡£
?
ǶÈë×ÖÌ壺½«×ÖÌåÎļþ±àÒë½øSWFÎļþÖлòÕßÔËÐÐʱ¼ÓÔص½SWFÎļþÖУ¬¹©SWFÎļþʹÓᣲ¢Ê¹Îı¾¾ßÓп¹¾â³ÝÌØÐÔ£¬±ßÔµ¸üƽ»¬£¬Í¬Ê±Îı¾¿ÉÒÔÉèÖÃ͸Ã÷¶È£¬»¹¿ÉÒÔÐýת¡£È±µã¾ÍÊÇÔö¼Ó³ÌÐòµÄÎļþ´óС£¬×ÖÌåСÓÚ10ʱ¾ÍºÜÄѱæÈÏ¡£
- <mx:style>??
- ????????@font-face?{ ??
- ????????????src:local("Arial");?//ǶÈë×ÖÌålocal,±íʾ±¾»úϵͳÖеÄ×ÖÌå ??
- ????????????src:url("./Arial.swf");?//Ö¸¶¨µÄ×ÖÌåÎļþµØÖ·£¬½«×ÖÌå·¿×ÓSWFÎļþÖУ¬È»ºó¼ÓÔØËü¡£ ??
- ????????????fontFamily:?myFont;?//×ÖÌåµÄ±ðÃû£¬±ØÐ붨Òå ??
- ????????????fontStyle:?normal;??//¿ÉÑ¡ÏĬÈÏnormal?Õý³££¬italic?бÌå?oblique?Çãб ??
- ????????????fontWeight:?normal;?//¿ÉÑ¡ÏĬÈÏnormal?Õý³££¬bold?´ÖÌå?heavy?¼Ó±¶´ÖÌå ??
- ????????????flashType:?true;??//¿ÉÑ¡ÏĬÈÏtrue£¬Ìí¼ÓÎı¾µÄ¶îÍâÐÅÏ¢£¬Ê¹µÃÎı¾¿¹¾â³Ý£¬Æ½»¬ÏÔʾ ??
- ??
- ???????????????????????//ÏÞÖÆǶÈëµÄ×Ö·û¡£×Ö·û±àÂë±ØÐë²ÉÓÃUnicode±ê×¼¡£ ??
- ???????????????????????unicodeRange: ??
- ????????????????U+0041-U+005A,?//´óд×ÖĸA-Z ??
- ????????????????U+0061-U+007A,?//Сд×Öĸa-z ??
- ????????????????U+0030-U+0039,?//Êý×Ö0-9 ??
- ????????????????U+002E-U+002E,?//µã. ??
- ????????} ??
- ??
- </mx:style>??
<mx:style> @font-face { src:local("Arial"); //ǶÈë×ÖÌålocal,±íʾ±¾»úϵͳÖеÄ×ÖÌå src:url("./Arial.swf"); //Ö¸¶¨µÄ×ÖÌåÎļþµØÖ·£¬½«×ÖÌå·¿×ÓSWFÎļþÖУ¬È»ºó¼ÓÔØËü¡£ fontFamily: myFont; //×ÖÌåµÄ±ðÃû£¬±ØÐ붨Òå fontStyle: normal; //¿ÉÑ¡ÏĬÈÏnormal Õý³££¬italic бÌå oblique Çãб fontWeight: normal; //¿ÉÑ¡ÏĬÈÏnormal Õý³££¬bold ´ÖÌå heavy ¼Ó±¶´ÖÌå flashType: true; //¿ÉÑ¡ÏĬÈÏtrue£¬Ìí¼ÓÎı¾µÄ¶îÍâÐÅÏ¢£¬Ê¹µÃÎı¾¿¹¾â³Ý£¬Æ½»¬ÏÔʾ //ÏÞÖÆǶÈëµÄ×Ö·û¡£×Ö·û±àÂë±ØÐë²ÉÓÃUnicode±ê×¼¡£ unicodeRange: U+0041-U+005A, //´óд×ÖĸA-Z U+0061-U+007A, //Сд×Öĸa-z U+0030-U+0039, //Êý×Ö0-9 U+002E-U+002E, //µã. }</mx:style>?
¶¨Òå×Ö·ûµÄ·½·¨Ò²¿ÉÒÔÔÚFlex SDK 2\frameworks\flex-config.xmlÖÐÌí¼ÓÏà¹ØÐÅÏ¢¡£
ÔÚ@font-faceÖоͿÉÒÔÕâÑùʹÓãºunicodeRange:"englishRange"
- <fonts>??
- ????????<languages>??
- ??????????<language-range>??
- ????????????<lang>englishRange</lang>??
- ????????????<range>U+0020-U+007E</range>??
- ??????????</language-range>??
- ????????</languages>??
- </fonts>????
2. µ¼º½Àà×é¼þ
?
2.1 ToggleButtonBar µ¼º½°´Å¥×é
ToggleButtonBar ÊÇButtonBar µÄ×ÓÀ࣬ÔöÇ¿À´µ¼º½¹¦ÄÜ£¬¿ÉÒÔ³ÖÐø±£³Ö¿Í»§¶Ë״̬¡£
ͬʱÔÚ½çÃæÉ϶Ե±Ç°µÄÑ¡ÖÐ״̬×öÃ÷È·µÄ±êʶ¡£
?
toggleOnClick ÊôÐÔÖ¸Ã÷ÊÇ·ñ¿ÉÒÔͨ¹ýµ¥»÷È¡ÏûÑ¡ÖеÄ״̬¡£true£ºµ±Êó±êµ¥»÷ÒѾѡÖеݴťʱ£¬¸Ã°´Å¥»Ö¸´µ½Õý³£×´Ì¬¡£false£ºÔò²»»á»Ö¸´¡£
?
itemClick="btn_click_handler(event);" ¼àÌýÓû§µÄµ¥»÷¶¯×÷¡£
?
- ??
- <mx:application?xmlns:mx="http: www.adobe.com="" 2006="" mxml"?layout="absolute" ??<="" li="">
- ?creationComplete="initUI()">??
- ????<mx:style?source="style.css">??
- ????<mx:script>??
- ????????
- ????????????//µ¼Èëµã»÷ʼþ¶ÔÏó ?
- ????????????import?mx.events.ItemClickEvent;???????? ?
- ????????????internal?function?initUI():void{ ?
- ????????????????var?data_arr:Array?=?new?Array(); ?
- ????????????????data_arr.push("<span?class=hilite1>Flex"); ?
- ????????????????data_arr.push("Flash"); ?
- ????????????????data_arr.push("Flash?Media?Server"); ?
- ????????????????data_arr.push("<span?class=hilite1>Flex?Data?Server"); ?
- ????????????????//Ìí¼ÓÊý¾ÝÔ´ ?
- ????????????????btns.dataProvider?=?data_arr; ?
- ????????????} ?
- ????????????//´¦ÀíitemClickµã»÷ʼþ ?
- ????????????internal?function?btn_click_handler(evt:ItemClickEvent):void{ ?
- ????????????????tip_txt.text?=?"µã»÷µÄ°´Å¥£º"+evt.index+":"+evt.label; ?
- ????????????} ?
- ????????]]>??
- ????</mx:script>??
- ????<mx:togglebuttonbar?toggleοnclick="true"?id="btns"?itemclick="btn_click_handler(event);"? ??<="" li="">
- horizontalGap="5"?x="22"?y="82">??
- ????</mx:togglebuttonbar>??
- ???? ??
- ????<mx:label?id="tip_txt"?text="»¹Ã»Óеã»÷ÄØ"?x="22"?y="126"?width="266">??
- ???? ??
- </mx:application>??
<mx:application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" ?creationcomplete="initUI()"> <mx:style source="style.css"> <mx:script> </mx:script> <mx:togglebuttonbar toggleοnclick="true" id="btns" itemclick="btn_click_handler(event);" horizontalgap="5" x="22" y="82"> </mx:togglebuttonbar> <mx:label id="tip_txt" text="»¹Ã»Óеã»÷ÄØ" x="22" y="126" width="266"> </mx:application>
?
2.2? TabBar ±êÇ©×é
TabBar ÔÚToggleButtonBar µÄ»ù´¡ÉϼÌÐøÀ©Õ¹£¬¸Ä±äÁ˶ÔÑ¡ÖÐ״̬µÄ±íÏÖÐÎʽ£¬½«Ñ¡ÖÐÏîÒÔ±êÇ©µÄÐÎʽͻ³öÏÔʾ£¬Õâµã¸úTabNavigator Ïàͬ£¬²»¹ýËü²»°üÀ¨ÆäËû×Ó¼¶ÈÝÆ÷¡£
¿ÉºÍÈκÎ×é¼þ½áºÏʹÓ㬶ø²»½ö½öÏÞÓÚÈÝÆ÷¡£
TabBar ±¾ÉíÖ»°üÀ¨ÁËÒ»×é±êÇ©£¬Ã»ÓÐÆäËûÄÚÈÝ¡£
myViewstack.selectedIndex = evt.index;
½«TabBar µÄ°´Å¥Ë÷ÒýºÍViewStack µÄ±»Ñ¡ÖÐÔªËصÄλÖùØÁªÆðÀ´¡£
- ??
- <mx:application?xmlns:mx="http: www.adobe.com="" 2006="" mxml"?layout="absolute">??
- ???? ??
- ????<mx:style?source="style.css">??
- ????<mx:script>??
- ????????
- ???????? ?
- ????????????import?mx.events.ItemClickEvent;???????? ?
- ???????? ?
- ????????????internal?function?btn_click_handler(evt:ItemClickEvent):void{ ?
- ????????????????myViewstack.selectedIndex?=?evt.index; ?
- ????????????} ?
- ????????]]>??
- ????</mx:script>??
- ???? ??
- ????<mx:panel?x="43"?y="10"?width="366"?height="310"?layout="absolute"?horizontalgap="0"?verticalgap="0"?title="tabbarʵÀý"?borderstyle="solid">??
- ????<mx:tabbar?id="btns"?x="10"?y="10"?width="308"?itemclick="btn_click_handler(event)">??
- ????????<mx:dataprovider>??
- ????????????<mx:array>??
- ????????????????<mx:string><span?class=hilite1>Flex</mx:string>??
- ????????????????<mx:string>Flash</mx:string>??
- ????????????????<mx:string>FMS</mx:string>??
- ????????????????<mx:string>FDS</mx:string>??
- ????????????</mx:array>??
- ????????</mx:dataprovider>??
- ????</mx:tabbar>??
- ????<mx:viewstack?x="10"?y="40"?id="myviewstack"?width="308"?height="200">??
- ????????<mx:canvas?id="child1"?label="view?1"?width="100%"?height="100%">??
- ????????????<mx:list>??
- ????????????????<mx:array>??
- ????????????????????<mx:object?label="ÇëÑ¡ÔñÄú¸ÐÐËȤµÄ¼¼Êõ£º">?????????????????? ??
- ????????????????????<mx:object?label="flash">??
- ????????????????????<mx:object?label="<span?class=hilite1>Flex"/>??
- ????????????????????<mx:object?label="flash?media?server">??
- ????????????????????<mx:object?label="breeze">??
- ????????????????</mx:array>??
- ????????????</mx:list>??
- ????????</mx:canvas>??
- ????????<mx:canvas?id="child2"?label="view?2"?width="100%"?height="100%">??
- ????????????<mx:textinput?text="ÇëÊäÈëÄúµÄÓÊÏäµØÖ·"?>??
- ????????????<mx:button?x="168"?y="1"?label="¶©ÔÄflash?rss">??
- ????????</mx:canvas>??
- ????????<mx:canvas?id="child3"?label="view?3"?width="100%"?height="100%">??
- ????????????<mx:label?text="fms?2.0.4·¢²¼ÁË"?>??
- ????????</mx:canvas>??
- ????????<mx:canvas?id="child4"?label="view?4"?width="100%"?height="100%">??
- ????????????<mx:label?text="breeze"?>??
- ????????</mx:canvas>??
- ????</mx:viewstack>??
- ????</mx:panel>??
- ???? ??
- </mx:application>??
<mx:application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"> <mx:style source="style.css"> <mx:script> </mx:script> <mx:panel x="43" y="10" width="366" height="310" layout="absolute" horizontalgap="0" verticalgap="0" title="TabBarʵÀý" borderstyle="solid"> <mx:tabbar id="btns" x="10" y="10" width="308" itemclick="btn_click_handler(event)"> <mx:dataprovider> <mx:array> <mx:string>Flex</mx:string> <mx:string>Flash</mx:string> <mx:string>FMS</mx:string> <mx:string>FDS</mx:string> </mx:array> </mx:dataprovider> </mx:tabbar> <mx:viewstack x="10" y="40" id="myViewstack" width="308" height="200"> <mx:canvas id="child1" label="View 1" width="100%" height="100%"> <mx:list> <mx:array> <mx:object label="ÇëÑ¡ÔñÄú¸ÐÐËȤµÄ¼¼Êõ£º"> <mx:object label="Flash"> <mx:object label="Flex"> <mx:object label="Flash Media server"> <mx:object label="Breeze"> </mx:array> </mx:list> </mx:canvas> <mx:canvas id="child2" label="View 2" width="100%" height="100%"> <mx:textinput text="ÇëÊäÈëÄúµÄÓÊÏäµØÖ·"> <mx:button x="168" y="1" label="¶©ÔÄFlash Rss"> </mx:canvas> <mx:canvas id="child3" label="View 3" width="100%" height="100%"> <mx:label text="FMS 2.0.4·¢²¼ÁË"> </mx:canvas> <mx:canvas id="child4" label="View 4" width="100%" height="100%"> <mx:label text="Breeze"> </mx:canvas> </mx:viewstack> </mx:panel> </mx:application>?
5.3 ʹÓò˵¥µ¼º½ -- ´´½¨Ò»¸ö¼òµ¥µÄ¶à¾Ã²Ëµ¥
ʹÓÃMenuBar ²Ëµ¥Ìõ×÷È«¾Öµ¼º½¡£
ÔÚʹÓÃAS ¶¨ÒåXML Êý¾Ýʱ£¬¿ÉÒÔʹÓû»Ðзû±£³ÖXMLÊý¾ÝµÄ¸ñʽ£¬Ö»ÒªXML µÄ±êÇ©ÕýÈ·£¬±àÒëÆ÷×Ô¶¯»áʶ±ð¡£
ÔÚnode ÔªËØÖÐµÄ enabled ÊôÐÔ ´ú±íÊÇ·ñ¿ÉÓã¬Ä¬ÈÏtrueΪ¿ÉÓã¬falseΪ²»¿ÉÓò˵¥Ïî±ä³É»ÒÉ«¡£
type ÊôÐÔ Îª separator ´ú±íÒ»¸ö·Ö¸îÏß¡£
?
XML ºÍ XMLList ¶¼ÊÇÓÃÀ´¶¨ÒåXML Êý¾Ý£¬²»Í¬µÄÊÇ£¬XMLList ÊǶà¸öXML Êý¾ÝµÄ¼¯ºÏ¡£
ÔÚÕâ¸öÀý×ÓÖУ¬mXMLÊÇXMLListÀàÐÍ£¬¸ù½Úµã±»ºöÂÔ£¬item ½Úµã±»½âÎöΪ¶ÀÁ¢µÄ XML Êý¾Ý¡£ item ½Úµã±ØÐëÓÐÒ»¸ö¸ù½Úµã£¬²»¿ÉºöÂÔ¡£
- ??
- <mx:application?xmlns:mx="http: www.adobe.com="" 2006="" mxml"?layout="absolute" ?creationcomplete="initApp()">??
- ???? ??
- ????<mx:style?source="style.css">???????????? ??
- ????<mx:script>??
- ????????
- ????????????import?mx.controls.Alert;??????? ?
- ????????????import?mx.events.MenuEvent; ?
- ???????????? ?
- ????????????private?var?mXML:XML?= ?
- ????????????????<menu?label?=?"ϵͳ²Ëµ¥"> ?
- ????????????????????<item?label="Îļþ"> ?
- ????????????????????????<node?label="н¨»°å"?data="new"> ?
- ????????????????????????<node?label="Çå³ý»°å"?data="clear"?enabled="false"> ?
- ????????????????????????<node?type="separator"?> ?
- ????????????????????????<node?label="Í˳öϵͳ"?data="logout"> ?
- ????????????????????</item> ?
- ????????????????????<item?label="°ïÖú"> ?
- ????????????????????????<node?label="°ïÖú"?data="help"> ?
- ????????????????????????<node?label="¹ØÓÚ×÷Õß"?data="about"> ?
- ?????????????????????</item> ?
- ????????????????; ?
- ???????????? ?
- ????????????internal?function?initApp():void{ ?
- ????????????????//ΪMenuBarÌí¼ÓÊý¾ÝÔ´ ?
- ????????????????myMenu.dataProvider?=?mXML; ?
- ????????????????//¼àÌýMenuµÄµã»÷ʵ¼ù ?
- ????????????????myMenu.addEventListener(MenuEvent.ITEM_CLICK,menuClickHandler); ?
- ????????????} ?
- ???????????? ?
- ????????????internal?function?menuClickHandler(evt:MenuEvent):void{ ?
- ????????????????Alert.show("Ñ¡Ôñ²Ëµ¥£º"+evt.item.@data,"ÌáʾÐÅÏ¢"); ?
- ????????????} ?
- ????????]]>??
- ????</mx:script>??
- ????<mx:vbox?width="100%"?height="100%">??
- ????????<mx:canvas?stylename="windowbar"?width="100%">??
- ????????????<mx:menubar?labelfield="@label"??height="30"?id="mymenu"?width="100%"></mx:menubar>? ??
- ????????</mx:canvas>??
- ????????<mx:canvas?width="100%"?height="100%"?id="paper">??
- ???????????? ??
- ????????</mx:canvas>?????????? ??
- ????</mx:vbox>??
- ???? ??
- </mx:application>??
<mx:application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationcomplete="initApp()"> <mx:style source="style.css"> <mx:script> <item label="Îļþ"> <node label="н¨»°å" data="new"> <node label="Çå³ý»°å" data="clear" enabled="false"> <node type="separator"> <node label="Í˳öϵͳ" data="logout"> </item> <item label="°ïÖú"> <node label="°ïÖú" data="help"> <node label="¹ØÓÚ×÷Õß" data="about"> </item> ; internal function initApp():void{ //ΪMenuBarÌí¼ÓÊý¾ÝÔ´ myMenu.dataProvider = mXML; //¼àÌýMenuµÄµã»÷ʵ¼ù myMenu.addEventListener(MenuEvent.ITEM_CLICK,menuClickHandler); } internal function menuClickHandler(evt:MenuEvent):void{ Alert.show("Ñ¡Ôñ²Ëµ¥£º"+evt.item.@data,"ÌáʾÐÅÏ¢"); } ]]> </mx:script> <mx:vbox width="100%" height="100%"> <mx:canvas stylename="windowBar" width="100%"> <mx:menubar labelfield="@label" height="30" id="myMenu" width="100%"></mx:menubar> </mx:canvas> <mx:canvas width="100%" height="100%" id="paper"> </mx:canvas> </mx:vbox> </mx:application>?
2.4 PopUpButton ÏÂÀµ¯³ö´°¿Ú¿Ø¼þ
PopUpButton ÊÇÒ»¸öÌØÊâµÄButton£¬ ±¾ÉíÓÉÁ½¸öButton×é³É£ºÖ÷°´Å¥ºÍ×Ó°´Å¥¡£µã»÷×Ó°´Å¥¿ÉÒÔ½«ÈκÎ×é¼þ×÷Ϊ´°¿Úµ¯³ö£¬ÖÃÓÚ×îÉϲ㡣Õâ¸öµ¯³ö¶¯×÷ÓÉ PopUpMenuButton Íê³É¡£
PopUpButton µÄopen ʼþºÍ close ʼþ£ºµ¯³öºÍµ¯³ö´°¿Ú¹Ø±Õʱ´¥·¢¡£
popUp ÊôÐÔ£º½«Òªµ¯³öµÄ¶ÔÏó¡£
DropdownEvent.CLOSE ºÍ DropdownEvent.OPEN ʼþרÃÅÕë¶Ôµ¯³ö´°¿Ú¡£µã»÷Ö÷°´Å¥£¬´¥·¢µÄʼþºÍButton ÊÇÒ»ÑùµÄ£¬±ÈÈçclick¡£
?
- ??
- <mx:application?xmlns:mx="http: www.adobe.com="" 2006="" mxml"?creationcomplete="initApp()" ?layout="absolute">??
- ????<mx:style>??
- ????????Application{ ??
- ????????????fontSize:12; ??
- ????????????backgroundGradientColors:?#c0c0c0,?#c0c0c0; ??
- ????????} ??
- ????</mx:style>??
- ????<mx:script>??
- ????????
- ????????????import?mx.containers.Panel;????? ?
- ????????????import?mx.controls.Alert;??? ?
- ????????????import?mx.events.DropdownEvent; ?
- ?
- ????????????private?var?panel:Panel; ?
- ?
- ????????????private?function?initApp():void?{ ?
- ????????????????panel?=?new?Panel();??//ÉùÃ÷еÄPanel ?
- ????????????????panel.title?=?"panel"; ?
- ????????????????panel.width?=?200; ?
- ????????????????panel.height?=?200; ?
- ????????????????popBtn.popUp?=?panel;???????????//Ö¸¶¨popUpÄ¿±ê¶ÔÏó??????? ?
- ????????????????popBtn.addEventListener(DropdownEvent.CLOSE,closeHandler);??//?????????? ?
- ????????????????popBtn.open();??????//½«´°¿Úµ¯³ö ?
- ????????????}??????????? ?
- ?
- ???????????? ?
- ????????????private?function?closeHandler(evt:DropdownEvent):void{ ?
- ????????????????Alert.show("¹Ø±Õ´°¿Ú"); ?
- ????????????} ?
- ????????]]>??
- ????</mx:script>??
- ????<mx:popupbutton?id="popbtn"?label="µ¯³ö"?width="135"??x="23"?y="23">??
- ???? ??
- </mx:application>??
<mx:application xmlns:mx="http://www.adobe.com/2006/mxml" creationcomplete="initApp()" layout="absolute"> <mx:style> Application{ fontSize:12; backgroundGradientColors: #c0c0c0, #c0c0c0; } </mx:style> <mx:script> </mx:script> <mx:popupbutton id="popBtn" label="µ¯³ö" width="135" x="23" y="23"> </mx:application>?
2.5 PopUpMenuButton
¼Ì³Ð×ÔPopUpButton£¬ÊÇ PopUpButtonµÄÒ»¸öÌØÊâʵÀý¡£Ö»ÄÜ°ÑMenu µ±×÷µ¯³ö´°¿Ú£¬ÇÒMenu Ö»ÄÜÓÐ1¸ø²ã¼¶¡£
Menu ÓÃÀ´´´½¨²Ëµ¥£¬²»¹ýºÍ MenuÏà±È£¬ËüÉÙÁ˲˵¥Ìõ¡£ÇÒûÓжÔÓ¦µÄMXML±êÇ©£¬Ö»ÄÜÓÉ´úÂë´´½¨¡£
PopUpMenuButton ÖÐÄÚÖÃÁËÒ»¸öMenu ¡£
¶¨ÒåXML Êý¾Ý£¬½«Ëü´«¸ø PopUpMenuButton µÄ dataProvider £¬×÷ΪÄÚÖõÄMenu µÄÊý¾ÝÔ´¡£
MenuEvent.ITEM_CLICK ʼþ£ºµ±²Ëµ¥ÏѡÖÐʱ£¬Ê¼þ±»´¥·¢£¬Í¬Ê±²Ëµ¥¹Ø±Õ¡£
- ??
- <mx:application?xmlns:mx="http: www.adobe.com="" 2006="" mxml"?creationcomplete="initApp()" ?layout="absolute">??
- ????<mx:style>??
- ????????Application{ ??
- ????????????fontSize:12; ??
- ????????????backgroundGradientColors:?#c0c0c0,?#c0c0c0; ??
- ????????} ??
- ????</mx:style>??
- ????<mx:script>??
- ????????
- ????????????import?mx.controls.Alert;??? ?
- ????????????import?mx.events.MenuEvent; ?
- ???????????? ?
- ????????????private?var?mXML:XMLList?= ?
- ????????????????<> ?
- ????????????????????<node?label="Îļþ"> ?
- ????????????????????????<node?label="н¨»°å"?data="new"> ?
- ????????????????????????<node?label="Çå³ý»°å"?data="clear"?enabled="false"> ?
- ????????????????????????<node?label="Í˳öϵͳ"?data="logout"> ?
- ????????????????????</node> ?
- ????????????????????<node?label="¹¤¾ß">???????????????????????? ?
- ????????????????????<node?label="°ïÖú"> ?
- ????????????????????????<node?label="°ïÖú"?data="help"> ?
- ????????????????????????<node?label="¹ØÓÚ×÷Õß"?data="about"> ?
- ?????????????????????</node> ?
- ????????????????; ?
- ????????????private?function?initApp():void?{ ?
- ????????????????popBtn.dataProvider?=?mXML;?//µ¯³ö²Ëµ¥µÄÊý¾ÝÔ´ ?
- ????????????????popBtn.addEventListener(MenuEvent.ITEM_CLICK,clickHandler);? ?
- ????????????}??????????? ?
- ????????????private?function?clickHandler(evt:MenuEvent):void{ ?
- ????????????????Alert.show("Ñ¡Ôñ²Ëµ¥£º"+evt.label+":²Ëµ¥ÐòºÅ£º"+evt.index); ?
- ????????????} ?
- ????????]]>??
- ????</mx:script>??
- ????<mx:popupmenubutton?id="popbtn"?labelfield="@label"?width="135"??x="23"?y="23">??
- ???? ??
- </mx:application>??