在ActionScript 3中在舞台上加载可拖动的影片剪辑

时间:2012-05-04 17:14:35

标签: actionscript-3

我被困在这个我正在做的小界面上。这是我第一次在AS3中认真编码,我想这是我目前的可能性!

我要做的是:

  1. 一个dropDown菜单,用于在点击时加载HTML文件,并将影片剪辑加载到舞台上(此部分可以正常工作)

  2. 我加载的movieClip是可拖动的....在这里我休息我的情况!

  3. 我认为使其工作的关键是嵌入使其在影片剪辑内部可拖动的代码;这样,当我加载MC它已经可以拖动了......这是正确的吗?

    主要代码是:

    import flash.net.URLRequest;
    import flash.events.Event;
    import flash.display.MovieClip;
    import flash.sampler.NewObjectSample;
    
       //define texts for the HEADING and for the PANEL's children (b1,2,3,4)
    menu_event.heading.myText.text = "EVENT";
    menu_event.panel.b1.myText.text = "press";
    menu_event.panel.b2.myText.text = "pressNeighbour";
    menu_event.panel.b3.myText.text = "bla";
    menu_event.panel.b4.myText.text = "blabla";
    
    menu_actions.heading.myText.text = "ACTIONS";
    menu_actions.panel.b1.myText.text = "ledOn";
    menu_actions.panel.b2.myText.text = "ledOff";
    menu_actions.panel.b3.myText.text = "ledFlash";
    menu_actions.panel.b4.myText.text = "ledDim";
    
    menu_blocks.heading.myText.text = "BLOCKS";
    menu_blocks.panel.b1.myText.text = "state";
    menu_blocks.panel.b2.myText.text = "broadcast";
       menu_blocks.panel.b3.myText.text = "onEntry";
    menu_blocks.panel.b4.myText.text = "onExit";
    //tell the MENU to do something depending on which target is clicked
    menu_event.addEventListener(MouseEvent.CLICK, clickHandler);
    menu_actions.addEventListener(MouseEvent.CLICK, clickHandler);
    menu_blocks.addEventListener(MouseEvent.CLICK, clickHandler);
    
    
    function clickHandler(event:MouseEvent):void {
    if (event.target == menu_event.panel.b1)
    {
        navigateToURL(new URLRequest("event_1.html"));
        // Create a new MovieClip
        var myMovieClip:MovieClip = new event_obj(); 
        // Add the new MovieClip to the MainTimeline
        // so that we can see it.
        addChild(myMovieClip);
        // Set the location of the new MovieClip
        myMovieClip.x = 150;
        myMovieClip.y = 210;
    }
    if (event.target == menu_event.panel.b2)
    {
        navigateToURL(new URLRequest("event_1.html"));
    }
    if (event.target == menu_event.panel.b3)
    {
        navigateToURL(new URLRequest("event_2.html"));
    }
    if (event.target == menu_event.panel.b4)
    {
        navigateToURL(new URLRequest("event_3.html"));
    }
    ////////////////////////////////////////////////////////////////////
    if (event.target == menu_actions.panel.b1)
    {
        navigateToURL(new URLRequest("actions_1.html"));
    }
    if (event.target == menu_actions.panel.b2)
    {
        navigateToURL(new URLRequest("actions_2.html"));
    }
    if (event.target == menu_actions.panel.b3)
    {
        navigateToURL(new URLRequest("actions_3.html"));
    }
    if (event.target == menu_actions.panel.b4)
    {
        navigateToURL(new URLRequest("actions_4.html"));
    }
    ////////////////////////////////////////////////////////////////////
    if (event.target == menu_blocks.panel.b1)
    {
        navigateToURL(new URLRequest("blocks_1.html"));
    }
    if (event.target == menu_blocks.panel.b2)
    {
        navigateToURL(new URLRequest("blocks_2.html"));
    }
    if (event.target == menu_blocks.panel.b3)
    {
        navigateToURL(new URLRequest("blocks_3.html"));
    }
    if (event.target == menu_blocks.panel.b4)
    {
        navigateToURL(new URLRequest("blocks_4.html"));
    }
    }
    

0 个答案:

没有答案