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

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

Explorer ,
Feb 08, 2015 Feb 08, 2015

Copy link to clipboard

Copied

Hello dear ladies & sirs,

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

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!

TOPICS
ActionScript

Views

831

Translate

Translate

Report

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 ,
Feb 08, 2015 Feb 08, 2015

Copy link to clipboard

Copied

Votes

Translate

Translate

Report

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
Explorer ,
Feb 08, 2015 Feb 08, 2015

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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 ,
Feb 08, 2015 Feb 08, 2015

Copy link to clipboard

Copied

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?

Votes

Translate

Translate

Report

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
Explorer ,
Feb 08, 2015 Feb 08, 2015

Copy link to clipboard

Copied

Yes i am trying to call a function that's in a loaded swf. I am sorry for bad English 😮

Votes

Translate

Translate

Report

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 ,
Feb 08, 2015 Feb 08, 2015

Copy link to clipboard

Copied

the link i posted in message 1 shows exactly how to do that.

if you're trying to create a class member (eg, instance) from a loaded swf (eg, test.swf) that defines class C, use:

var s:String = "C";

load("test.swf",s);

function load(urlS:String, classS:String) {

    var ldr:Loader = new Loader();

    ldr.contentLoaderInfo.addEventListener(Event.COMPLETE, function(e:Event){loadCompleteF(e,classS);});

    ldr.load(new URLRequest(urlS));

}

function loadCompleteF(e:Event,classS:String):void {

    var loadedAppDomain:ApplicationDomain = e.target.content.loaderInfo.applicationDomain;

    var C:Class = loadedAppDomain.getDefinition(classS) as Class;

    var instance:* = new C();

}

Votes

Translate

Translate

Report

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
Explorer ,
Feb 14, 2015 Feb 14, 2015

Copy link to clipboard

Copied

Thank you for answer. Sorry for late.. But i am using simple public function load(urlS:String) {     var ldr:Loader = new Loader();     ldr.contentLoaderInfo.addEventListener(Event.COMPLETE, function(e:Event){loadCompleteF(e,classS);});     ldr.load(new URLRequest(urlS)); } function onLoadComplete(e:Event):void { var loaderInfo:LoaderInfo = e.target as LoaderInfo; addChild(e.target.content); var swf:Object = loaderInfo.content; swf.MainLSWL(); if (swf == false){ throw new Argement("Error: Shockwave Library does not get matter Main_SWL()"); } } That is better than access class of method. only loader with access function 🙂 P.S: How do i translate from C++ into AS3? example: int myVar(void) { ] into AS3: function myVar(myInt:Number):void { } or andother? Thanks!

Votes

Translate

Translate

Report

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 ,
Feb 14, 2015 Feb 14, 2015

Copy link to clipboard

Copied

LATEST

your code is not readable (by me).  format it.

Votes

Translate

Translate

Report

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