Skip to main content
SourceSkyBoxer
Known Participant
February 8, 2015
Question

How do i call method from externel swf like ExternalInterface or LocalConnection??

  • February 8, 2015
  • 1 reply
  • 1250 views

Hello dear ladies & sirs,

i have tested our example from http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/system/ApplicationDomain.html#includeExamplesSummary.

I have added "callMethod(method:Object)"

/**

  * For custom callMethod like you load function from swf when i want call "greet()" from loaded swf than it should be showing.

  */

  private function callMethod(method:Object):void

  {

  var runtimeClassRef:Class = loader.getClass("RuntimeClasses");

  var greeter:Object = new runtimeClassRef();

  tf.text = greeter(Object(method));

  }

  /**

  * End of CallMethod

  */

Than i call access function from loaded swf:

private function classLoadedHandler(e:Event):void {

  var runtimeClassRef:Class = loader.getClass("RuntimeClasses");

  var greeter:Object = new runtimeClassRef();

  //tf.text = greeter.greet();

  callMethod("greet()");

  }

And i test ApplicationDomainExample and it does not show from callMethod("greet()");

How do i call method from external loaded swf if accessing function is here from loaded swf. How do i access?

Thanks best regards!

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
February 8, 2015
SourceSkyBoxer
Known Participant
February 8, 2015

But you missunderstand because i mean

Mainswf:

loader, loaderInfo and Object

function callmethod(functionName:String):void

{

var loaderInfo:LoaderInfo = e.target as LoaderInfo;

  addChild(e.target.content);

  var swf:Object = loaderInfo.content;

if(swf.hasOwnProperty(functionName))

  {

  swf[functionName];

  }

}

private function ZG_LoadLibrary(swlPath:String, functionName:String):void

{

  var _swlExtension:String = ".swl";

  var loader:Loader = new Loader();

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

  loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, onLoaderError);

  loader.load(new URLRequest(swlPath+_swlExtension));

  function onLoadComplete(e:Event):void {

  var loaderInfo:LoaderInfo = e.target as LoaderInfo;

  addChild(e.target.content);

  var swf:Object = loaderInfo.content;

 

  if(swf.hasOwnProperty(functionName))

  {

  swf[functionName];

  }

  }

}

private function onLoaderError(ioe:IOErrorEvent):void

{

  ZG_ERROR("Error: Unable to load engine.swl");

}

RDIT:::

Ops... I am sorry for seeing accessible function obj.MainEngine(); I am shy But i can not access function or variable from external swf if i use simple call method with object How do i rush with function or variable from external swf

kglad
Community Expert
Community Expert
February 8, 2015

i think there's a language issue.

in any case, i do not understand what you're trying to do.

it looks like you're trying to call a function that's in a loaded swf.  is that true?