Skip to main content
STR_Kai
Participating Frequently
April 28, 2017
Question

Need to trigger a function within a loaded swf file

  • April 28, 2017
  • 1 reply
  • 538 views

This is my scenario, this week a colleague contacts me to tell me there is a problem with a piece of work put out by us 8 months ago. There is no source file but they need to make the content work with a clicker. So I decompile the swf and find the call to move on to the next slide, so far so good. I make a wrapper to load in the original swf file and set up the code for the clicker. The problem I am having is I am super rusty when it comes to AS3 and I cannot trigger the function within the loaded swf to move the content on.

This is the decompiled code in the loaded swf, I have highlighted the function I need to call:

My initial thought was to create a new instance of the class "ActionsContext" in my wrapper then use that to target the function but so far I am coming up short. As I say I am super rusty so if anyone could give me a hand I would REALLY appreciate it.

Thanks

Kai

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
April 28, 2017

your loader's content property is a reference to the main timeline of the loaded swf.  if that swf is a movieclip, you would use:

MovieClip(your loader.content) when loading is complete and the function to be referenced exists.

STR_Kai
STR_KaiAuthor
Participating Frequently
April 28, 2017

Thanks for the reply. I am creating a movieClip to load the swf into, below is my code:

var request:URLRequest = new URLRequest("start.swf");

var loader:Loader = new Loader()

loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loader_complete);

loader.load(request);

addChild(loader);

function loader_complete(evt:Event):void{

  trace("load complete");

  var embedSWF:MovieClip = MovieClip(evt.target.content);

  addChild(embedSWF);

  stage.addEventListener(KeyboardEvent.KEY_DOWN, myKeyDown);

  function myKeyDown(e:KeyboardEvent):void {

  if (e.keyCode == Keyboard.PAGE_DOWN){

  trace("PAGE_DOWN");

  }

  if (e.keyCode == Keyboard.PAGE_UP){

  trace("PAGE_UP");

  }

  }

}

kglad
Community Expert
Community Expert
April 28, 2017

embedSWF (which can't be used after loading completes) is a reference to the loaded swf's main timeline.  take it from there.