FlexʹÓÃ×é¼þ´¦ÀíÊý¾ÝºÍ½»»¥µ¼º½Àà×é¼þ(1)

2. µ¼º½Àà×é¼þ

?

2.1 ToggleButtonBar µ¼º½°´Å¥×é

ToggleButtonBar ÊÇButtonBar µÄ×ÓÀ࣬ÔöÇ¿À´µ¼º½¹¦ÄÜ£¬¿ÉÒÔ³ÖÐø±£³Ö¿Í»§¶Ë״̬¡£

ͬʱÔÚ½çÃæÉ϶Ե±Ç°µÄÑ¡ÖÐ״̬×öÃ÷È·µÄ±êʶ¡£

?

toggleOnClick ÊôÐÔÖ¸Ã÷ÊÇ·ñ¿ÉÒÔͨ¹ýµ¥»÷È¡ÏûÑ¡ÖеÄ״̬¡£true£ºµ±Êó±êµ¥»÷ÒѾ­Ñ¡Öеݴťʱ£¬¸Ã°´Å¥»Ö¸´µ½Õý³£×´Ì¬¡£false£ºÔò²»»á»Ö¸´¡£

?

itemClick="btn_click_handler(event);" ¼àÌýÓû§µÄµ¥»÷¶¯×÷¡£

?

Xml´úÂë

  1. <!---->??
  2. <mx:application?xmlns:mx="http: www.adobe.com="" 2006="" mxml"?layout="absolute" ??<="" li="">
  3. ?creationComplete="initUI()">??
  4. ????<mx:style?source="style.css">??
  5. ????<mx:script>??
  6. ????????<!---->
  7. ????????????//µ¼Èëµã»÷ʼþ¶ÔÏó ?
  8. ????????????import?mx.events.ItemClickEvent;???????? ?
  9. ????????????internal?function?initUI():void{ ?
  10. ????????????????var?data_arr:Array?=?new?Array(); ?
  11. ????????????????data_arr.push("<span?class=hilite1>Flex"); ?
  12. ????????????????data_arr.push("Flash"); ?
  13. ????????????????data_arr.push("Flash?Media?Server"); ?
  14. ????????????????data_arr.push("<span?class=hilite1>Flex?Data?Server"); ?
  15. ????????????????//Ìí¼ÓÊý¾ÝÔ´ ?
  16. ????????????????btns.dataProvider?=?data_arr; ?
  17. ????????????} ?
  18. ????????????//´¦ÀíitemClickµã»÷ʼþ ?
  19. ????????????internal?function?btn_click_handler(evt:ItemClickEvent):void{ ?
  20. ????????????????tip_txt.text?=?"µã»÷µÄ°´Å¥£º"+evt.index+":"+evt.label; ?
  21. ????????????} ?
  22. ????????]]>??
  23. ????</mx:script>??
  24. ????<mx:togglebuttonbar?toggleonclick="true"?id="btns"?itemclick="btn_click_handler(event);"? ??<="" li="">
  25. horizontalGap="5"?x="22"?y="82">??
  26. ????</mx:togglebuttonbar>??
  27. ???? ??
  28. ????<mx:label?id="tip_txt"?text="»¹Ã»Óеã»÷ÄØ"?x="22"?y="126"?width="266">??
  29. ???? ??
  30. </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 toggleonclick="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 µÄ±»Ñ¡ÖÐÔªËصÄλÖùØÁªÆðÀ´¡£

Xml´úÂë

  1. <!---->??
  2. <mx:application?xmlns:mx="http: www.adobe.com="" 2006="" mxml"?layout="absolute">??
  3. ???? ??
  4. ????<mx:style?source="style.css">??
  5. ????<mx:script>??
  6. ????????<!---->
  7. ???????? ?
  8. ????????????import?mx.events.ItemClickEvent;???????? ?
  9. ???????? ?
  10. ????????????internal?function?btn_click_handler(evt:ItemClickEvent):void{ ?
  11. ????????????????myViewstack.selectedIndex?=?evt.index; ?
  12. ????????????} ?
  13. ????????]]>??
  14. ????</mx:script>??
  15. ???? ??
  16. ????<mx:panel?x="43"?y="10"?width="366"?height="310"?layout="absolute"?horizontalgap="0"?verticalgap="0"?title="tabbarʵÀý"?borderstyle="solid">??
  17. ????<mx:tabbar?id="btns"?x="10"?y="10"?width="308"?itemclick="btn_click_handler(event)">??
  18. ????????<mx:dataprovider>??
  19. ????????????<mx:array>??
  20. ????????????????<mx:string><span?class=hilite1>Flex</mx:string>??
  21. ????????????????<mx:string>Flash</mx:string>??
  22. ????????????????<mx:string>FMS</mx:string>??
  23. ????????????????<mx:string>FDS</mx:string>??
  24. ????????????</mx:array>??
  25. ????????</mx:dataprovider>??
  26. ????</mx:tabbar>??
  27. ????<mx:viewstack?x="10"?y="40"?id="myviewstack"?width="308"?height="200">??
  28. ????????<mx:canvas?id="child1"?label="view?1"?width="100%"?height="100%">??
  29. ????????????<mx:list>??
  30. ????????????????<mx:array>??
  31. ????????????????????<mx:object?label="ÇëÑ¡ÔñÄú¸ÐÐËȤµÄ¼¼Êõ£º">?????????????????? ??
  32. ????????????????????<mx:object?label="flash">??
  33. ????????????????????<mx:object?label="<span?class=hilite1>Flex"/>??
  34. ????????????????????<mx:object?label="flash?media?server">??
  35. ????????????????????<mx:object?label="breeze">??
  36. ????????????????</mx:array>??
  37. ????????????</mx:list>??
  38. ????????</mx:canvas>??
  39. ????????<mx:canvas?id="child2"?label="view?2"?width="100%"?height="100%">??
  40. ????????????<mx:textinput?text="ÇëÊäÈëÄúµÄÓÊÏäµØÖ·"?>??
  41. ????????????<mx:button?x="168"?y="1"?label="¶©ÔÄflash?rss">??
  42. ????????</mx:canvas>??
  43. ????????<mx:canvas?id="child3"?label="view?3"?width="100%"?height="100%">??
  44. ????????????<mx:label?text="fms?2.0.4·¢²¼ÁË"?>??
  45. ????????</mx:canvas>??
  46. ????????<mx:canvas?id="child4"?label="view?4"?width="100%"?height="100%">??
  47. ????????????<mx:label?text="breeze"?>??
  48. ????????</mx:canvas>??
  49. ????</mx:viewstack>??
  50. ????</mx:panel>??
  51. ???? ??
  52. </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 ½Úµã±ØÐëÓÐÒ»¸ö¸ù½Úµã£¬²»¿ÉºöÂÔ¡£

Xml´úÂë

  1. <!---->??
  2. <mx:application?xmlns:mx="http: www.adobe.com="" 2006="" mxml"?layout="absolute" ?creationcomplete="initApp()">??
  3. ???? ??
  4. ????<mx:style?source="style.css">???????????? ??
  5. ????<mx:script>??
  6. ????????<!---->
  7. ????????????import?mx.controls.Alert;??????? ?
  8. ????????????import?mx.events.MenuEvent; ?
  9. ???????????? ?
  10. ????????????private?var?mXML:XML?= ?
  11. ????????????????<menu?label?=?"ϵͳ²Ëµ¥"> ?
  12. ????????????????????<item?label="Îļþ"> ?
  13. ????????????????????????<node?label="н¨»­°å"?data="new"> ?
  14. ????????????????????????<node?label="Çå³ý»­°å"?data="clear"?enabled="false"> ?
  15. ????????????????????????<node?type="separator"?> ?
  16. ????????????????????????<node?label="Í˳öϵͳ"?data="logout"> ?
  17. ????????????????????</item> ?
  18. ????????????????????<item?label="°ïÖú"> ?
  19. ????????????????????????<node?label="°ïÖú"?data="help"> ?
  20. ????????????????????????<node?label="¹ØÓÚ×÷Õß"?data="about"> ?
  21. ?????????????????????</item> ?
  22. ????????????????; ?
  23. ???????????? ?
  24. ????????????internal?function?initApp():void{ ?
  25. ????????????????//ΪMenuBarÌí¼ÓÊý¾ÝÔ´ ?
  26. ????????????????myMenu.dataProvider?=?mXML; ?
  27. ????????????????//¼àÌýMenuµÄµã»÷ʵ¼ù ?
  28. ????????????????myMenu.addEventListener(MenuEvent.ITEM_CLICK,menuClickHandler); ?
  29. ????????????} ?
  30. ???????????? ?
  31. ????????????internal?function?menuClickHandler(evt:MenuEvent):void{ ?
  32. ????????????????Alert.show("Ñ¡Ôñ²Ëµ¥£º"+evt.item.@data,"ÌáʾÐÅÏ¢"); ?
  33. ????????????} ?
  34. ????????]]>??
  35. ????</mx:script>??
  36. ????<mx:vbox?width="100%"?height="100%">??
  37. ????????<mx:canvas?stylename="windowbar"?width="100%">??
  38. ????????????<mx:menubar?labelfield="@label"??height="30"?id="mymenu"?width="100%"></mx:menubar>? ??
  39. ????????</mx:canvas>??
  40. ????????<mx:canvas?width="100%"?height="100%"?id="paper">??
  41. ???????????? ??
  42. ????????</mx:canvas>?????????? ??
  43. ????</mx:vbox>??
  44. ???? ??
  45. </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¡£

?

Xml´úÂë

  1. <!---->??
  2. <mx:application?xmlns:mx="http: www.adobe.com="" 2006="" mxml"?creationcomplete="initApp()" ?layout="absolute">??
  3. ????<mx:style>??
  4. ????????Application{ ??
  5. ????????????fontSize:12; ??
  6. ????????????backgroundGradientColors:?#c0c0c0,?#c0c0c0; ??
  7. ????????} ??
  8. ????</mx:style>??
  9. ????<mx:script>??
  10. ????????<!---->
  11. ????????????import?mx.containers.Panel;????? ?
  12. ????????????import?mx.controls.Alert;??? ?
  13. ????????????import?mx.events.DropdownEvent; ?
  14. ?
  15. ????????????private?var?panel:Panel; ?
  16. ?
  17. ????????????private?function?initApp():void?{ ?
  18. ????????????????panel?=?new?Panel();??//ÉùÃ÷еÄPanel ?
  19. ????????????????panel.title?=?"panel"; ?
  20. ????????????????panel.width?=?200; ?
  21. ????????????????panel.height?=?200; ?
  22. ????????????????popBtn.popUp?=?panel;???????????//Ö¸¶¨popUpÄ¿±ê¶ÔÏó??????? ?
  23. ????????????????popBtn.addEventListener(DropdownEvent.CLOSE,closeHandler);??//?????????? ?
  24. ????????????????popBtn.open();??????//½«´°¿Úµ¯³ö ?
  25. ????????????}??????????? ?
  26. ?
  27. ???????????? ?
  28. ????????????private?function?closeHandler(evt:DropdownEvent):void{ ?
  29. ????????????????Alert.show("¹Ø±Õ´°¿Ú"); ?
  30. ????????????} ?
  31. ????????]]>??
  32. ????</mx:script>??
  33. ????<mx:popupbutton?id="popbtn"?label="µ¯³ö"?width="135"??x="23"?y="23">??
  34. ???? ??
  35. </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 ʼþ£ºµ±²Ëµ¥ÏѡÖÐʱ£¬Ê¼þ±»´¥·¢£¬Í¬Ê±²Ëµ¥¹Ø±Õ¡£

Xml´úÂë

  1. <!---->??
  2. <mx:application?xmlns:mx="http: www.adobe.com="" 2006="" mxml"?creationcomplete="initApp()" ?layout="absolute">??
  3. ????<mx:style>??
  4. ????????Application{ ??
  5. ????????????fontSize:12; ??
  6. ????????????backgroundGradientColors:?#c0c0c0,?#c0c0c0; ??
  7. ????????} ??
  8. ????</mx:style>??
  9. ????<mx:script>??
  10. ????????<!---->
  11. ????????????import?mx.controls.Alert;??? ?
  12. ????????????import?mx.events.MenuEvent; ?
  13. ???????????? ?
  14. ????????????private?var?mXML:XMLList?= ?
  15. ????????????????<> ?
  16. ????????????????????<node?label="Îļþ"> ?
  17. ????????????????????????<node?label="н¨»­°å"?data="new"> ?
  18. ????????????????????????<node?label="Çå³ý»­°å"?data="clear"?enabled="false"> ?
  19. ????????????????????????<node?label="Í˳öϵͳ"?data="logout"> ?
  20. ????????????????????</node> ?
  21. ????????????????????<node?label="¹¤¾ß">???????????????????????? ?
  22. ????????????????????<node?label="°ïÖú"> ?
  23. ????????????????????????<node?label="°ïÖú"?data="help"> ?
  24. ????????????????????????<node?label="¹ØÓÚ×÷Õß"?data="about"> ?
  25. ?????????????????????</node> ?
  26. ????????????????; ?
  27. ????????????private?function?initApp():void?{ ?
  28. ????????????????popBtn.dataProvider?=?mXML;?//µ¯³ö²Ëµ¥µÄÊý¾ÝÔ´ ?
  29. ????????????????popBtn.addEventListener(MenuEvent.ITEM_CLICK,clickHandler);? ?
  30. ????????????}??????????? ?
  31. ????????????private?function?clickHandler(evt:MenuEvent):void{ ?
  32. ????????????????Alert.show("Ñ¡Ôñ²Ëµ¥£º"+evt.label+":²Ëµ¥ÐòºÅ£º"+evt.index); ?
  33. ????????????} ?
  34. ????????]]>??
  35. ????</mx:script>??
  36. ????<mx:popupmenubutton?id="popbtn"?labelfield="@label"?width="135"??x="23"?y="23">??
  37. ???? ??
  38. </mx:application>??

1.8 DataGrid ×é¼þ -- ÖÆ×÷ͼÊéÑ¡¹ºÁбí

DataGrid×é¼þµÄ×÷ÓúÍHTMLÒ³ÃæÖеıí¸ñÀàËÆ£¬½«Êý¾ÝÒÔÐС¢ÁеĸñʽÏÔʾ³öÀ´¡£

?

ÿһ×ÝÁеĿí¶È²»¶¨£¬Óû§¿ÉÒÔÔÚÔËÐÐʱµ÷Õû¿í¶È¡£

¿ÉÔÚÔËÐÐʱµ÷ÕûÁеÄ˳Ðò

µã»÷ÁбêÌâÀ¸¿É¶ÔÁÐÊý¾Ý½øÐÐÅÅÐò

¿ÉÒÔ×Ô¶¨ÒåÿÁеıêÌâÀ¸

ºÍList×é¼þÒ»Ñù£¬¿ÉÒÔ×Ô¶¨Òåÿ¸öµ¥Ôª¸ñµÄitemRenderer

?

ʹÓÃModel¶¨ÒåÊý¾ÝÔ´£¬

columns ¶¨ÒåÁËËùÓеÄÁУ¬ÆäÖÐDataGridColumn ´ú±íÒ»ÁеÄÐÅÏ¢£¬dataFieldµÄÖµ²»¿ÉÊ¡ÂÔ£¬Õâ¸öÖµ±ØÐëÊÇÊý¾ÝÔ´ÖÐÿÌõÊý¾Ý°üº¬µÄÊôÐÔÃû£¬·ñÔòÎÞ·¨ÏÔʾ¡£headerText ±íʾÁбêÌâ¡£

rowCount ±íʾÏÔʾµÄÐÐÊý£¬Èç¹ûheightûÓÐÉèÖã¬ÔòÓÃÕâ¸öÊôÐÔÀ´¼¼Êõ¸ß¶È¡£height=rowCount*rowHeightÐиߡ£

selectedItem ÊôÐÔ´ú±íµ±Ç°Ñ¡ÖÐÐеÄÊý¾Ý£¬¿ÉÒÔÔÚÊý¾Ý°ó¶¨ÖУ¬µ±ËüµÄÖµ·¢Éú±ä»¯Ê±£¬Ê¹ÓøÃÊôÐÔµÄÈκÎÎï¼þ¶¼»á×Ô¶¯¸üС£

?

½Ó×ÅÎÒÃÇÀûÓÃitemRenderer ÔÚDataGridÖмÓÈ븴ѡ¿ò´´½¨×é¼þ£º

ÔÚ×é¼þÖÐÌí¼ÓÒ»¸ö¸´Ñ¡¿ò¡£²¢Ìí¼ÓchangeʼþµÄ·½·¨addCart¡£

this.parentApplication ±íʾ¸¸Application£¬¾ÍÊÇÎÒÃǺóÃæʹÓøÃ×é¼þµÄApplication¡£

new cartEvent(data,cart_check.selected)

addCart ·½·¨´´½¨ÁËÒ»¸ö×Ô¶¨Òåʼþ cartEvent ʼþ£¬²¢ÇÒ½«±ØÒªµÄÊôÐÔ´«µ½¸Ãʼþ£¬

È»ºóͨ¹ý dispatchEvent ÅÉ·¢¸Ãʼþ¡£

?

Xml´úÂë

  1. <!---->??
  2. <mx:canvas?xmlns:mx="http: www.adobe.com="" 2006="" mxml"="">??
  3. ????<mx:script>??
  4. ????????<!---->
  5. ????????????import?bookEvent.cartEvent; ?
  6. ????????????internal?function?addCart():void{ ?
  7. ????????????????this.parentApplication.dispatchEvent(new?cartEvent(data,cart_check.selected)); ?
  8. ????????????} ?
  9. ????????]]>??
  10. ????</mx:script>??
  11. ????<mx:checkbox?id="cart_check"?x="0"?y="0"?label="¹ºÂò"?change="addcart()">??
  12. </mx:canvas>??

<!----><mx:canvas xmlns:mx="http://www.adobe.com/2006/mxml"> <mx:script> <!----> </mx:script> <mx:checkbox id="cart_check" x="0" y="0" label="¹ºÂò" change="addCart()"></mx:canvas>

ÒÔÏÂΪ¶¨ÒåÒ»¸öcartEvent ʼþÀࣺ

ËùÓеÄʼþ¼Ì³ÐEvent£¬ ÔÚ¹¹Ô캯ÊýÖж¨ÒåÁËÁ½¸ö²ÎÊý£º_data ºÍ _isAdd£¬´´½¨Ê¼þµÄʱºò£¬½«Í¨¹ýÕâÁ½¸ö²ÎÊý½«ÐÅÏ¢´«ÈëʼþÖС£

super("AddBook") µ÷Óø¸ÀàEvent µÄ¹¹Ô캯Êý£¬²¢°ÑʼþÀàÐÍ¡°AddBook¡±´«µÝ¹ýÈ¥¡£Ö»Óе÷ÓÃÁ˸¸ÀàµÄ¹¹Ô캯Êý£¬²ÅÄܳÉΪÕæÕýµÄʼþ¶ÔÏó¡£

Xml´úÂë

  1. package?bookEvent ??
  2. { ??
  3. ????import?flash.events.Event; ??
  4. ??
  5. ????public?class?cartEvent?extends?Event{ ??
  6. ????????public?var?isAdd:Boolean; ??
  7. ????????public?var?book:Object; ??
  8. ????????function?cartEvent(_data:Object,_isAdd:Boolean):void{ ??
  9. ????????????isAdd?=?_isAdd; ??
  10. ????????????book?=?_data; ??
  11. ???????????? ??
  12. ????????????super("AddBook"); ??
  13. ????????} ??
  14. ????} ??
  15. }??

package bookEvent{ import flash.events.Event; public class cartEvent extends Event{ public var isAdd:Boolean; public var book:Object; function cartEvent(_data:Object,_isAdd:Boolean):void{ isAdd = _isAdd; book = _data; super("AddBook"); } }}?

½ÓÏÂÀ´ÊÇÖ÷³ÌÐò¡£

ÔÚ³ÌÐò³õʼ»¯º¯ÊýÖУ¬addEventListener("AddBook",AddHandler) Ϊµ±Ç°¶ÔÏóÌí¼ÓÁ˶ÔAddBookʼþµÄ¼àÌý¡£

Xml´úÂë

  1. <!---->??
  2. <mx:application?xmlns:mx="http: www.adobe.com="" 2006="" mxml"?fontsize="12" ?creationcomplete="initApp()">??
  3. ????????<mx:script>??
  4. ????????????<!---->
  5. ????????????????import?mx.events.DataGridEvent; ?
  6. ????????????????import?mx.events.DataGridEventReason ?
  7. ????????????????import?bookEvent.cartEvent; ?
  8. ????????????????import?view.*; ?
  9. ???????????????? ?
  10. ????????????????internal?function?initApp():void{ ?
  11. ????????????????????addEventListener("AddBook",AddHandler); ?
  12. ????????????????} ?
  13. ????????????????internal?function?AddHandler(evt:cartEvent):void{ ?
  14. ????????????????????if(evt.isAdd){ ?
  15. ????????????????????????tip_txt.text?=?"ÄãÑ¡Ôñ¹ºÂò£º"+evt.book.name; ?
  16. ????????????????????}else{ ?
  17. ????????????????????????tip_txt.text?=?"Äã·ÅÆú¹ºÂò£º"+evt.book.name; ?
  18. ????????????????????} ?
  19. ????????????????} ?
  20. ???????????????? ?
  21. ????????????????internal?function?checkInfo(evt:DataGridEvent):void{ ?
  22. ????????????????????//Èç¹ûûÓÐ×÷ÐÞ¸Ä ?
  23. ????????????????????if?(evt.reason?==?DataGridEventReason.CANCELLED){ ?
  24. ????????????????????????return; ?
  25. ????????????????????} ?
  26. ????????????????????//È·¶¨Ð޸ĵÄÊôÐÔ ?
  27. ????????????????????if(evt.dataField?==?"date"){ ?
  28. ????????????????????????//?Çå³ýÔ­À´µÄÊý¾Ý ?
  29. ????????????????????????evt.preventDefault(); ?
  30. ????????????????????????//?µÃµ½ÐµÄÊý¾Ý ?
  31. ????????????????????????book_DG.editedItemRenderer.data.date?=?dateCell(DataGrid(evt.target).itemEditorInstance).num_year.value; ?
  32. ????????????????????????//?¹Ø±Õitem?editor ?
  33. ????????????????????????book_DG.destroyItemEditor();? ?
  34. ????????????????????????//¸üÐÂÊý¾ÝÔ´? ?
  35. ????????????????????????book_DG.dataProvider.itemUpdated(evt.itemRenderer.data); ?
  36. ????????????????????} ?
  37. ????????????????} ?
  38. ????????????]]>??
  39. ????????</mx:script>??
  40. ????????<mx:model?id="books">??
  41. ????????????<datas>??
  42. ????????????????<book>??
  43. ????????????????????<name>FlashµÚÒ»²½</name>??
  44. ????????????????????<author>³Â±ù</author>??
  45. ????????????????????<date>2006</date>??
  46. ????????????????</book>??
  47. ????????????????<book>??
  48. ????????????????????<name>FlexµÚÒ»²½</name>??
  49. ????????????????????<author>walktree</author>??
  50. ????????????????????<date>2007</date>??
  51. ????????????????</book>??
  52. ????????????????<book>??
  53. ????????????????????<name>ApolloµÚÒ»²½</name>??
  54. ????????????????????<author>»¹²»ÖªµÀÄØ</author>??
  55. ????????????????????<date>2008</date>??
  56. ????????????????</book>??
  57. ????????????</datas>??
  58. ????????</mx:model>???? ??
  59. ????????<mx:label?width="100%"?color="#004080"?text="Ñ¡ÔñÒ»±¾Ê鹺Âò">??
  60. ????????<mx:datagrid?editable="true"?id="book_dg"?width="100%"?height="156"?itemeditend="checkinfo(event)"?rowcount="5"?dataprovider="{books.book}">??
  61. ????????????<mx:columns>??
  62. ????????????????<mx:datagridcolumn?datafield="name"?headertext="ÊéÃû">??
  63. ????????????????<mx:datagridcolumn?datafield="author"?headertext="×÷Õß">??
  64. ????????????????<mx:datagridcolumn?datafield="date"?headertext="³ö°æÈÕÆÚ"?itemeditor="view.datecell"?>??
  65. ????????????????<mx:datagridcolumn?headertext="¹ºÂò"?itemrenderer="view.cartcell"?editable="false">??
  66. ????????????</mx:columns>??
  67. ????????</mx:datagrid>??
  68. ???????? ??
  69. ????????<mx:canvas?height="150"?width="100%"?backgroundcolor="#ffffff">??
  70. ????????<mx:label?id="tip_txt"?text="»¹Ã»ÓÐÑ¡ÔñÊéÄ¿">??? ??
  71. ????????</mx:canvas>??
  72. ??
  73. </mx:application>??

<!----><mx:application xmlns:mx="http://www.adobe.com/2006/mxml" fontsize="12" creationcomplete="initApp()"> <mx:script> <!----> </mx:script> <mx:model id="books"> <datas> <book> <name>FlashµÚÒ»²½</name> <author>³Â±ù</author> <date>2006</date> </book> <book> <name>FlexµÚÒ»²½</name> <author>walktree</author> <date>2007</date> </book> <book> <name>ApolloµÚÒ»²½</name> <author>»¹²»ÖªµÀÄØ</author> <date>2008</date> </book> </datas> </mx:model> <mx:label width="100%" color="#004080" text="Ñ¡ÔñÒ»±¾Ê鹺Âò"> <mx:datagrid editable="true" id="book_DG" width="100%" height="156" itemeditend="checkInfo(event)" rowcount="5" dataprovider="{books.book}"> <mx:columns> <mx:datagridcolumn datafield="name" headertext="ÊéÃû"> <mx:datagridcolumn datafield="author" headertext="×÷Õß"> <mx:datagridcolumn datafield="date" headertext="³ö°æÈÕÆÚ" itemeditor="view.dateCell"> <mx:datagridcolumn headertext="¹ºÂò" itemrenderer="view.cartCell" editable="false"> </mx:columns> </mx:datagrid> <mx:canvas height="150" width="100%" backgroundcolor="#ffffff"> <mx:label id="tip_txt" text="»¹Ã»ÓÐÑ¡ÔñÊéÄ¿"> </mx:canvas></mx:application>

?

´ËÍ⻹ÓÐheaderRenderer ¿ØÖƱêÌâÀ¸µÄ½çÃæ ºÍ itemEditor ¿ØÖƵ¥Ôª¸ñÖб༭״̬ϵĽçÃ棬ʹÓøúitemRendererÒ»Ñù¡£ÒªÊ¹ÓÃitemEditor±ØÐ뽫DataGrid µÄeditable ÊôÐÔÉèΪtrue¡£»¹ÒªÉèÖú¯ÊýÀ´´¦Àí±à¼­Íê³Éʼþ£¬¸üÐÂÊý¾Ý¡£Ö÷³ÌÐò´úÂë¼ûÉÏÃæ ¡£

?

½Ó×ÅÎÒÃÇÔÙ¶¨ÒåÒ»¸ö×é¼þ£º

ÔÚÏÂÃæµÄ×é¼þÖУ¬Ê¹ÓÃÁËNumericStepper Êý×ÖÑ¡Ôñ¿Ø¼þÀ´Ìṩ±ã½Ý²Ù×÷¡£

ÔÚÓû§Íê³É±à¼­µ¥Ôª¸ñÊý¾Ýºó£¬itemEditEndʼþ½«±»´¥·¢£¬DataGridEvent ʼþ±»ÅÉ·¢³öÈ¥£¬Òò´ËʹÓüàÌýº¯Êý£ºitemEditEnd="checkInfo(event)"

if (evt.reason == DataGridEventReason.CANCELLED) ¼ì²éʼþµÄÀàÐÍ

Xml´úÂë

  1. <!---->??
  2. <mx:canvas?xmlns:mx="http: www.adobe.com="" 2006="" mxml"?width="180">??
  3. ????<mx:numericstepper?id="num_year"?x="0"?y="0"?minimum="1900"?maximum="2100"?value="{data.date}">??
  4. ????<mx:label?text="ÇëÑ¡ÔñÄê·Ý"?x="96"?y="2">??
  5. </mx:canvas>??

你可能感兴趣的:(xml,css,Flex,Flash,Adobe)