本文介绍了通过MovieClip接收MouseEvent.CLICK的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

var swfLoader:Loader = new Loader();
swfLoader.load(new URLRequest("file1.swf"));
swfLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,loadswf);

var myMov:MovieClip;

function loadwf(e:Event):void {
myMov = e.target.content;
    myMov.scaleX * = 125/myMov.width;
    myMov.scaleY * = 125/myMov.height;
    myMov.x = 0;
    myMov.y = 0;
    addChild(myMov);
    myMov.addEventListener(MouseEvent.CLICK,clickListener);
}

function clickListener(e:MouseEvent):void {
    myMov.scaleX * = 1.01;
    myMov.scaleY * = 1.01;
}

var swfLoader:Loader=new Loader();
swfLoader.load(new URLRequest("file1.swf"));
swfLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,loadswf);

var myMov:MovieClip;

function loadswf(e:Event):void {
    myMov=e.target.content;
    myMov.scaleX*=125/myMov.width;
    myMov.scaleY*=125/myMov.height;
    myMov.x=0;
    myMov.y=0;
    addChild(myMov);
    myMov.addEventListener(MouseEvent.CLICK,clickListener);
}

function clickListener(e:MouseEvent):void{
    myMov.scaleX*=1.01;
    myMov.scaleY*=1.01;
}

 

 

在上面的代码中,我希望从外部加载MovieClip来接收MouseEvent.CLICK事件,但该movieclip实例未收到任何事件.

In above code, i wanted externally loaded MovieClip to receive MouseEvent.CLICK event, but that movieclip instance is not receiving any event.

有人可以让我知道原因吗?

Can anybody plz let me know the reason & help me doing that.

请,这很紧急.

致谢.

推荐答案

大约1的 这个问题的答案,这不是MovieClip缩放比例很小的问题,因为我只是用trace()替换了该语句;声明,这样我就必须注意到事件的调度.即便如此,它仍然无法正常工作.

About 1 of  the answer i''ve got for this question, it''s not the problem with very small scaling of MovieClip, because i just replaced that statement by a trace( ); statement, so that i must get noticed about events'' dispatch. Even then it wasn''t working.

在我修复了该错误之后,我开始了解一件事.使用Loader类加载MovieClip(也包括任何DisplayObject)之后,如果仅将加载的内容分配给另一个现有实例,就可以显示它们,但是无法使它们散布MouseEvent甚至KeyboardEvent.

As i''ve fixed that bug, i came to know one thing. After we load MovieClip ( any DisplayObject too) using Loader class, if we just assign the loaded content to another existing instance, we can just display them, but there''s no way to make them dispacth MouseEvent or even KeyboardEvent.. 

 

为此,我只是将加载的内容作为myMov实例的子项.然后一切都按我的预期工作.

To do so, i just made the loaded content as child for myMov instance. Then everything worked as i expected.

我是说,我替换了以下代码

I mean,  i replaced the following code

函数loadswf(e:Event):void {
    myMov = e.target.content;     myMov.scaleX * = 125/myMov.width;
    myMov.scaleY * = 125/myMov.height;
    myMov.x = 0;
    myMov.y = 0;
    addChild(myMov);
    myMov.addEventListener(MouseEvent.CLICK,clickListener);
}

function loadswf(e:Event):void {
    myMov=e.target.content;    myMov.scaleX*=125/myMov.width;
    myMov.scaleY*=125/myMov.height;
    myMov.x=0;
    myMov.y=0;
    addChild(myMov);
    myMov.addEventListener(MouseEvent.CLICK,clickListener);
}

通过,

函数loadwf(e:Event):void {
     myMov.addChild(e.target.content);
    myMov.scaleX * = 125/myMov.width;
    myMov.scaleY * = 125/myMov.height;
    myMov.x = 0;
    myMov.y = 0;
    addChild(myMov);
    myMov.addEventListener(MouseEvent.CLICK,clickListener);
}

function loadswf(e:Event):void {
    myMov.addChild(e.target.content);
    myMov.scaleX*=125/myMov.width;
    myMov.scaleY*=125/myMov.height;
    myMov.x=0;
    myMov.y=0;
    addChild(myMov);
    myMov.addEventListener(MouseEvent.CLICK,clickListener);
}

就是这样.

 

无论如何,都非常感谢您回应和我希望这个结果也能对其他人有所帮助.

Anyways THANKS a Lot for your responces & i hope this result would help someone else too.

有关ActionScript 3.0的任何讨论,请访问我的新博客http://se7encodes.blogspot.com/ 

For any disscussions about ActionScript 3.0, please visit my new blog http://se7encodes.blogspot.com/ 



 

您确定它不起作用吗?这种缩放比例是如此之小,我怀疑您会注意到,并且四舍五入可能会导致它无法累积工作.

Are you sure it''s not working ? That sort of scaling is so small, I doubt you''d notice, and rounding could cause it not to work cumulatively.

顺便说一句,这并不紧急.对我们来说,这毫无意义.说紧急很无礼,如果迫不及待需要免费帮助,然后找到可以付费的人来帮助您.

It''s not urgent, by the way.  It means nothing to us.  Saying it''s urgent is just rude, if it''s that urgent that you can''t wait for free help, then find someone you can pay to help you.


这篇关于通过MovieClip接收MouseEvent.CLICK的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-23 17:42