Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Need to trigger a function within a loaded swf file

Community Beginner ,
Apr 28, 2017 Apr 28, 2017

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:

AS3.jpg

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

TOPICS
ActionScript
499
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 28, 2017 Apr 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 28, 2017 Apr 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");

  }

  }

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 28, 2017 Apr 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 02, 2017 May 02, 2017

Sorry but I am going to need more help, as I say my AS3 skills are super rusty.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 02, 2017 May 02, 2017
LATEST

what's the path from the loaded swf's main timeline to the function you want to call?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines