AS3组合框非常基本的例子

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了AS3组合框非常基本的例子相关的知识,希望对你有一定的参考价值。

This is the most simple example of a ComboBox created in AS3, based mostly on Adobe's example from http://help.adobe.com/en_US/ActionScript/3.0_UsingComponentsAS3/WS5b3ccc516d4fbf351e63e3d118a9c65b32-7fa9.html

Inside the zip file you will find two folders. The first is this example with a ComboBox dragged onto the stage of the FLA with a supporting .AS file to populate it and make it work. The second example shows a ComboBox created and populated entirely by actionscript.
  1. package {
  2. import flash.display.MovieClip;
  3. import flash.events.Event;
  4.  
  5. import fl.events.ComponentEvent;
  6. import fl.controls.ComboBox;
  7. import fl.data.DataProvider;
  8.  
  9.  
  10.  
  11.  
  12. public class AS3_combobox2 extends MovieClip {
  13. var comboData:Array = new Array(
  14. {label:"Choice One", data:"one"},
  15. {label:"Choice Two", data:"two"}
  16. );
  17.  
  18. var combobox_cb:ComboBox = new ComboBox();
  19.  
  20. public function AS3_combobox2() {
  21. combobox_cb.dropdownWidth = 210;
  22. combobox_cb.width = 200;
  23. combobox_cb.move(150, 50);
  24. combobox_cb.prompt = "Make a Choice";
  25. combobox_cb.dataProvider = new DataProvider(comboData);
  26. combobox_cb.addEventListener(Event.CHANGE, changeHandler);
  27.  
  28. addChild(combobox_cb);
  29. }
  30. public function changeHandler(event:Event):void {
  31. // do something based on the selected item's value
  32. switch(combobox_cb.selectedItem.data) {
  33. case "one":
  34. trace("One was chosen!");
  35. break;
  36. case "two":
  37. trace("Two was chosen!");
  38. break;
  39. }
  40. }
  41.  
  42.  
  43.  
  44.  
  45. }
  46. }

以上是关于AS3组合框非常基本的例子的主要内容,如果未能解决你的问题,请参考以下文章

AS3组合框“onSelect”更改

单击按钮时如何删除组合框组件 flash as3

通过AS3组合框文本格式

网格视图组合框

ActionScript 3 AS3 ComboBox极其基本的例子

组合选项框和组合框以将记录添加到右表