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

C# to Actionscript function call, externalinterface callfunction silent fail

New Here ,
Feb 27, 2013 Feb 27, 2013

Copy link to clipboard

Copied

Hi,

I'm trying to call an Actionscript 3 function exposed using externalinterface.addcallback from C# using callfunction(). When I use the XML API, it returned </invalid>. I tried using some code I found for Externalinterfaceproxy class on Google but it also is unresponsive.

I've tried adding the .swf to Flash Player's global security settings, no change. Within Actionscript the functions are called successfully. Externalinterface.available is true. AllowScriptAccess is set to "always" for the C# axshockwaveflash control.

Any idea what's missing? Can anyone point to working example code of C# -> Actionscript 3 function calls? Is there any procedure for troubleshooting the externalinterface API?

Thanks,

Alex

TOPICS
ActionScript

Views

3.0K

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
New Here ,
Mar 04, 2013 Mar 04, 2013

Copy link to clipboard

Copied

Anybody?

Is there any well-documented method of calling Actionscript 3 functions from 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
LEGEND ,
Mar 04, 2013 Mar 04, 2013

Copy link to clipboard

Copied

The last time that I had to do something like that, I needed to use VBScript on the html page to "go-between" the C# and Actionscript. You can use ExternalInterface to communicate with VBScript.

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
New Here ,
Mar 04, 2013 Mar 04, 2013

Copy link to clipboard

Copied

Thanks for the reply. This is for a desktop Windows application; I'm using an axShockwaveFlash control in a Windows Form so there's no HTML page in between.

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
LEGEND ,
Mar 04, 2013 Mar 04, 2013

Copy link to clipboard

Copied

Then I'm no help at all. I've never tried that.

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
New Here ,
Mar 04, 2013 Mar 04, 2013

Copy link to clipboard

Copied

Thanks anyway.

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
New Here ,
Mar 06, 2013 Mar 06, 2013

Copy link to clipboard

Copied

Update: it appears that the ExternalInterface function is actually being called (I set a return value and I can see it coming back) but the problem is that my call to gotoAndStop isn't happening:

MovieClip(root).gotoAndStop("approved");

This is strange because I'm using a gotoAndStop in the Document Class constructor and it appears to be working, it's just not working when the function is called from ExternalInterface. Has anyone seen something like this or am I imagining things?

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
New Here ,
Mar 06, 2013 Mar 06, 2013

Copy link to clipboard

Copied

package

{

    import flash.display.MovieClip;

    import flash.external.ExternalInterface;

          import flash.events.*;

          import flash.utils.Timer;

          import flash.events.TimerEvent;

   

    public class MyRoot extends MovieClip

    {

        public function MyRoot()

        {

        ExternalInterface.addCallback("idle", idle);

                    ExternalInterface.addCallback("authorizing", authorizing);

                    ExternalInterface.addCallback("approved", approved);

                    ExternalInterface.addCallback("failed", failed);

                    ExternalInterface.addCallback("serving", serving);

 

                    serving("now");

 

 

//                    var myTimer:Timer = new Timer(8000, 8); // 8 second delay

//                    myTimer.addEventListener(TimerEvent.TIMER, runOnce);

//                    myTimer.start();

//

//                    //Only necessary for troubleshooting

//                    function runOnce(event:TimerEvent):void {

//                              myTimer.stop();

//                              approved("now");

//                              }

 

        }

       

                    public function idle(val:String):String

                    {

          //                    this.gotoAndPlay(1);

                              MovieClip(root).gotoAndStop("idle");

                              return "ok idling";

                    }

 

 

 

                    public function authorizing(val:String):String

                    {

                              //this.gotoAndPlay(19);

                              //MovieClip(root).gotoAndStop("authorizing");

                              MovieClip(root).gotoAndPlay("authorizing");

                              MovieClip(root).stage.invalidate();

                              return "ok authorizing";

                    }

 

 

 

                    public function approved(val:String):String

                    {

                              //this.gotoAndPlay(29);

                              MovieClip(root).gotoAndStop("approved");

                              return "ok approved";

                    }

 

 

 

                    public function failed(val:String):String

                    {

                              //this.gotoAndPlay(41);

                              MovieClip(root).gotoAndStop("failed");

                              return "ok failed";

                    }

 

 

 

                    public function serving(val:String):String

                    {

                              //this.gotoAndPlay(51);

                              MovieClip(root).gotoAndStop("serving");

                              return "ok serving";

                    }

 

    }

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
New Here ,
Mar 06, 2013 Mar 06, 2013

Copy link to clipboard

Copied

Another issue: the call to stage.invalidate() causes  HRESULT E_FAILED to occur when running inside C# but does not cause any problem when testing the .swf on its own. I tried adding that line to see if it would force the gotoAndPlay() to work.

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
New Here ,
Mar 08, 2013 Mar 08, 2013

Copy link to clipboard

Copied

Solved: adding play() before gotoAndStop() solved the problem.

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
New Here ,
Nov 24, 2020 Nov 24, 2020

Copy link to clipboard

Copied

LATEST

hay man im also doing windows form game from swf files and i wondered how can i get what exactly the game request, how do i use callfunction, getvariable and setvariable in 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