Click here to Skip to main content
15,904,416 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

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;
}

 

 

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.

Please, it's URGENT.

Regards.

Posted

It's ok folks. Since it was URGENT to me, i tried a lot, to fix that error & finally got succeeded.

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.

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.. 

 

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

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);
}

by,

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);
}

That's it.

 

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

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

 
Share this answer
 
is myMov possibly a child object? Is the parent intercepting the click?
 
Share this answer
 
function clickListener(e:MouseEvent):void{ myMov.scaleX*=1.01; myMov.scaleY*=1.01; }

 

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.

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900