Skip to main content
Known Participant
December 24, 2011
Question

click a button from main movie on external swf

  • December 24, 2011
  • 1 reply
  • 647 views

Hello:

I need to click on a button that is on an external swf loaded in the main movie with a loader.

I'm trying this but does not work:

//  main movie

function openswf(queFoto:String)

{

    imgLoader = new Loader();

    imgLoader.load(new URLRequest("mySWF.swf"));

    addChild(imgLoader);

}

I need something like this:

btfake.dispatchEvent(new MouseEvent(MouseEvent.CLICK,true));

that trigger my button on swf external.

// external movie

Manyt thanks.

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
December 24, 2011

if you want to dispatch a click event to your button that's in the external swf , your swf is a movieclip, your button is btfake and btfade is on your external swf's main timeline, you can use:

//  main movie

function openswf(queFoto:String)

{

    imgLoader = new Loader();

imgLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,loadCompleteF);

    imgLoader.load(new URLRequest("mySWF.swf"));

    addChild(imgLoader);

}

function loadCompleteF(e:Event):void{

var mc:MovieClip=MovieClip(e.target.loader.content);

mc.btfake.dispatchEvent(new MouseEvent(MouseEvent.CLICK,true));

}