0

我只是在学习 Flash/Actionscript 3,我正在尝试使用已经放置在场景中的对象创建一个新对象,这是它的代码:

package 
{

import flash.display.MovieClip;
import flash.events.MouseEvent;

public class Scene1 extends MovieClip
{
    {
        {
            {
                var theRoot:MovieClip = MovieClip(root);
                var mouse:mouse1 = new mouse1();


                //Scene1(void);
                //onClipEvent(30);


                function Scene1():void
                {               this.addEventListener(MouseEvent.MOUSE_MOVE, Joe);



                }


                public function Joe(event:MouseEvent):void
                {
                    mouse.x = mouseX;
                    mouse.y = mouseY;
                    mouse.x = 160;
                    mouse.y = 160;
                    trace(mouse.x + " " + mouse.y + " " + mouse.z);
                }
            }
        }
        }}};

它确实跟踪了应有的位置(160,160),bu 对象不会渲染,即使我更改 Z .. 虽然,无论如何,没有任何对象会在他们的视野中阻挡它。

这是鼠标1:

package 
{

import flash.display.MovieClip;
import flash.events.MouseEvent;


public class mouse1 extends MovieClip
{
    {
        {
            var theRoot:MovieClip = MovieClip(root);


            mouse1(void);
            //onClipEvent(30);


            function mouse1():void
            {
                //this.z = -20;

                trace("WROKZZZ");
            }


            public function Joe(event:MouseEvent):void
            {
                //this.x = mouseX;
                //this.y = mouseY;
            }
        }
    }
    }};
4

1 回答 1

1

除了使用 来创建对象new外,还需要在渲染之前将其添加到显示列表中(请参见此处:http: //www.adobe.com/devnet/flash/quickstart/display_list_programming_as3.htmlstage.addChild(mouse) ),因此请使用这个。

于 2013-08-02T23:11:45.200 回答