如何 startdrag() 舞台中的任何对象?

发布于 2024-10-12 06:00:46 字数 269 浏览 2 评论 0原文

我想开始拖动位于舞台中的对象。舞台中有影片剪辑,其中也包含很多对象。当我单击任何对象时,它应该开始拖动。您有什么解决方案吗?

addEventListener(MouseEvent.MOUSE_UP, targetMC);
function targetMC(MouseEvent:Event):void
{
    var curinstance = MouseEvent.target.valueOf();
    curinstance.startDrag();
}

I would like to start drag objects which is located in stage.There is movie clips in the stage which also encloses so many objects.when i click on any of the object it should be startdraged..Do u have any solution?

addEventListener(MouseEvent.MOUSE_UP, targetMC);
function targetMC(MouseEvent:Event):void
{
    var curinstance = MouseEvent.target.valueOf();
    curinstance.startDrag();
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

忆离笙 2024-10-19 06:00:46

您可以将侦听器分配给持有其他资源的 MC/Sprite 或 Root

root.addEventListener(MouseEvent.MOUSE_DOWN, targetMC);

您可以添加一个全局变量来查看正在移动或迭代的对象遍历所有对象以阻止它们向上拖动鼠标

或使用 hypeframework 调整器:

http:// www.hypeframework.org/02_examples/adjuster/content/01_adjuster/

you can assign the listener to the MC/Sprite or Root that holds the other resource

root.addEventListener(MouseEvent.MOUSE_DOWN, targetMC);

you can add a global var to see what object is being moved or iterate through all objects to stop them from draging on mouse up

or use hypeframework adjuster:

http://www.hypeframework.org/02_examples/adjuster/content/01_adjuster/

作业与我同在 2024-10-19 06:00:46

这是答案

package 
{

    import flash.utils.getTimer;
    import flash.display.MovieClip;
    import flash.net.URLLoader;
    import flash.events.Event;
    import flash.net.URLRequest;
    import flash.events.ProgressEvent;
    import flash.text.GridFitType;
    import flash.display.MovieClip;
    import flash.events.Event;
    import flash.display.Sprite;
    import flash.events.MouseEvent;
    import fl.transitions.Tween;
    import fl.transitions.*;
    import fl.transitions.easing.*;
    import flash.text.TextField;
    import flash.geom.Rectangle;
    import flash.sampler.NewObjectSample;
    import fl.controls.DataGrid;
    import fl.controls.dataGridClasses.DataGridColumn;
    import fl.data.DataProvider;
    import fl.controls.ScrollPolicy;

    public class Main extends MovieClip
    {


        public function Main():void
        {
            var mc:MovieClip = new MovieClip();
            var mc_arr:Object = new Object();
            addChild(mc);
            for (var j:int=0; j<10; j++)
            {
                var clips:Array = [];


    var mcm:MovieClip = new MovieClip();
    mcm.graphics.drawRect(10*j,100,40,40);
    mcm.graphics.beginFill(0x000000);
    mcm.name = "mc" + j;
    addChild(mcm);



            }

        }

        public function onDown(evt:MouseEvent):void
        {
            evt.target.startDrag();
        }
        public function onUp(evt:MouseEvent):void
        {
            evt.target.stopDrag();
        }
    }

}

here is the answer

package 
{

    import flash.utils.getTimer;
    import flash.display.MovieClip;
    import flash.net.URLLoader;
    import flash.events.Event;
    import flash.net.URLRequest;
    import flash.events.ProgressEvent;
    import flash.text.GridFitType;
    import flash.display.MovieClip;
    import flash.events.Event;
    import flash.display.Sprite;
    import flash.events.MouseEvent;
    import fl.transitions.Tween;
    import fl.transitions.*;
    import fl.transitions.easing.*;
    import flash.text.TextField;
    import flash.geom.Rectangle;
    import flash.sampler.NewObjectSample;
    import fl.controls.DataGrid;
    import fl.controls.dataGridClasses.DataGridColumn;
    import fl.data.DataProvider;
    import fl.controls.ScrollPolicy;

    public class Main extends MovieClip
    {


        public function Main():void
        {
            var mc:MovieClip = new MovieClip();
            var mc_arr:Object = new Object();
            addChild(mc);
            for (var j:int=0; j<10; j++)
            {
                var clips:Array = [];


    var mcm:MovieClip = new MovieClip();
    mcm.graphics.drawRect(10*j,100,40,40);
    mcm.graphics.beginFill(0x000000);
    mcm.name = "mc" + j;
    addChild(mcm);



            }

        }

        public function onDown(evt:MouseEvent):void
        {
            evt.target.startDrag();
        }
        public function onUp(evt:MouseEvent):void
        {
            evt.target.stopDrag();
        }
    }

}
梦罢 2024-10-19 06:00:46

这就是答案............

package 
{

    import flash.utils.getTimer;
    import flash.display.MovieClip;
    import flash.net.URLLoader;
    import flash.events.Event;
    import flash.net.URLRequest;
    import flash.events.ProgressEvent;
    import flash.text.GridFitType;
    import flash.display.MovieClip;
    import flash.events.Event;
    import flash.display.Sprite;
    import flash.events.MouseEvent;
    import fl.transitions.Tween;
    import fl.transitions.*;
    import fl.transitions.easing.*;
    import flash.text.TextField;
    import flash.geom.Rectangle;
    import flash.sampler.NewObjectSample;
    import fl.controls.DataGrid;
    import fl.controls.dataGridClasses.DataGridColumn;
    import fl.data.DataProvider;
    import fl.controls.ScrollPolicy;

    public class Main extends MovieClip
    {


        public function Main():void
        {
            var mc:MovieClip = new MovieClip();
            var mc_arr:Object = new Object();
            addChild(mc);
            for (var j:int=0; j<10; j++)
            {
                var clips:Array = [];


    var mcm:MovieClip = new MovieClip();
    mcm.graphics.drawRect(10*j,100,40,40);
    mcm.graphics.beginFill(0x000000);
    mcm.name = "mc" + j;
    addChild(mcm);



            }

        }

        public function onDown(evt:MouseEvent):void
        {
            evt.target.startDrag();
        }
        public function onUp(evt:MouseEvent):void
        {
            evt.target.stopDrag();
        }
    }

}

this is the answer..........

package 
{

    import flash.utils.getTimer;
    import flash.display.MovieClip;
    import flash.net.URLLoader;
    import flash.events.Event;
    import flash.net.URLRequest;
    import flash.events.ProgressEvent;
    import flash.text.GridFitType;
    import flash.display.MovieClip;
    import flash.events.Event;
    import flash.display.Sprite;
    import flash.events.MouseEvent;
    import fl.transitions.Tween;
    import fl.transitions.*;
    import fl.transitions.easing.*;
    import flash.text.TextField;
    import flash.geom.Rectangle;
    import flash.sampler.NewObjectSample;
    import fl.controls.DataGrid;
    import fl.controls.dataGridClasses.DataGridColumn;
    import fl.data.DataProvider;
    import fl.controls.ScrollPolicy;

    public class Main extends MovieClip
    {


        public function Main():void
        {
            var mc:MovieClip = new MovieClip();
            var mc_arr:Object = new Object();
            addChild(mc);
            for (var j:int=0; j<10; j++)
            {
                var clips:Array = [];


    var mcm:MovieClip = new MovieClip();
    mcm.graphics.drawRect(10*j,100,40,40);
    mcm.graphics.beginFill(0x000000);
    mcm.name = "mc" + j;
    addChild(mcm);



            }

        }

        public function onDown(evt:MouseEvent):void
        {
            evt.target.startDrag();
        }
        public function onUp(evt:MouseEvent):void
        {
            evt.target.stopDrag();
        }
    }

}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文