-1

我是 AS3 的新手,我正在做一些简单的 UI。我想创建一个带有几个选项的下拉列表。我已经阅读了很多包含数百行用于制作下拉列表的教程。真的吗?一百行的下拉列表?我只想创建一种简单的 HTML SELECT。如果您知道也可以使用的教程。

对于这种问题,我真的很抱歉,但我真的找不到任何用 as3 写的东西。

我已经检查了 adobe 给出的那个是它的页面adobe 参考 DropDownList但该示例使用 XML。

4

3 回答 3

1

基于纯 AS3 的类:

package
{
    import flash.display.MovieClip;
    import flash.events.Event;
    import flash.events.MouseEvent;
    import flash.events.TimerEvent;
    import flash.utils.Timer;

    import com.greensock.*;
    import com.greensock.easing.*;

    public class MouseOverMenu extends MovieClip {

        public var _sMouseOver:MovieClip;
        public var _sMenu:MovieClip;

        private var _menuTimer:Timer;
        private var _menuOpen:Boolean = false;

        public function MouseOverMenu():void {
            addEventListener(Event.ADDED_TO_STAGE, init, false, 0, true);
        }

        private function init(e:Event):void {

            _sMouseOver.buttonMode = true;
            _sMouseOver.addEventListener(MouseEvent.MOUSE_OVER, showMenu, false, 0, true);
            _sMouseOver.addEventListener(MouseEvent.MOUSE_OUT, startClose, false, 0, true);
            _sMouseOver.addEventListener(MouseEvent.MOUSE_OVER, cancelClose, false, 0, true);

            _menuTimer = new Timer( 50 );
            _menuTimer.addEventListener ( TimerEvent.TIMER, doCloseMenu );

            _sMenu.visible = false;
            _sMenu.alpha = 0;
            _sMenu.addEventListener(MouseEvent.MOUSE_OUT, startClose, false, 0, true);
            _sMenu.addEventListener(MouseEvent.MOUSE_OVER, cancelClose, false, 0, true);
        }
        private function showMenu(e:MouseEvent):void {
            _menuOpen = true;
            _sMenu.visible = true;
            TweenLite.to(_sMenu, .5, {y:73, alpha:1});
        }
        private function startClose ( e:Event ):void {
            //trace('startClose ' + e.target);
            _menuTimer.start();
        }
        private function cancelClose ( e:Event ):void {
            //trace('cancelClose ' + e.target);
            _menuTimer.stop();
        }
        private function doCloseMenu ( e:Event ) {
            closeMenu();
        }
        private function closeMenu ():void {
            if ( _menuOpen ) {
                TweenLite.to(_sMenu, .5, {y:50, alpha:0, onComplete: hideMenu});
            }
            _menuTimer.stop();
            _menuOpen = false;
        }
        private function hideMenu():void {
            _sMenu.visible = false;
        }
    }
}
于 2012-11-16T13:43:57.323 回答
0

我没有看到您提到的示例中使用了 XML,无论如何这是 Flex 中使用 arrayCollection 的 Dropdownlist 的简单代码。

 <?xml version="1.0" encoding="utf-8"?>
    <!-- http://blog.flexexamples.com/2009/03/07/using-the-dropdownlist-in-flex-gumbo/ -->
    <s:Application name="Spark_DropDownList_test"
            xmlns:fx="http://ns.adobe.com/mxml/2009"
            xmlns:s="library://ns.adobe.com/flex/spark"
            xmlns:mx="library://ns.adobe.com/flex/mx">
        <s:layout>
            <s:BasicLayout />
        </s:layout>

        <s:DropDownList id="dropDownLst"
                requireSelection="true"
                horizontalCenter="0" top="20">
            <s:dataProvider>
                <s:ArrayList source="[The,quick,brown,fox,jumps,over,the,lazy,dog]" />
            </s:dataProvider>
        </s:DropDownList>

    </s:Application>
于 2012-11-16T11:44:49.107 回答
0

如果您不想使用 MXML,可以通过代码来完成:

yourDropDownInstance.dataProvider = new ArrayCollection(["The","quick",
                                                         "brown","fox",
                                                         "jumps","over",
                                                         "the","lazy","dog"]);
于 2012-11-16T13:42:13.283 回答