Skip navigation
Currently Being Moderated

ExternalInterface: Type? String, Object and any types?

Apr 13, 2012 2:34 PM

Tags: #flex #titanium #4.6 #javascript_bridge

Hello dear guys,

 

i want know about ExternalInterface - just i have same problem with String or Array - if i like this.

But i am working with AS3 with in-block Javascript like trick by Facebook Api Libraries.

 

I know same functions for Boolean and Object right..

Code is MyLibrary.as

package ....

{

          import flash.external.ExternalInterface;

 

          public class MyLibraray

          {

                    /**

                     *           MyLibrary Exit

                     */

                    private static var _exit:Object;

                    public static function Exit():void

                    {

                              try{

                                        if(ExternalInterface.available){

                                                  _exit = ExternalInterface.call(jsBirdge.script());

                                                  _exit = ExternalInterface.call("JSL.jsExit"); //

                                        }

                              }catch( error:Error) {}

                    }


}

}

 

And jsBirdge.as <- It is in-block with Javascript into XML Format and Doement Format like Javascript Version into Actionscript

package ...

{

          import flash.external.ExternalInterface;

 

 

          public class jsBirdge

          {

                    private static var NS:String = "JSL";

 

                    public static function script():String

                    {

                              try{

                                        if(ExternalInterface.available){

                                                  ExternalInterface.call(script_js);

                                                  ExternalInterface.call("JSL.setSWFObject", ExternalInterface.objectID);

                                        }

                              }catch( error:Error) {}

 

                              return NS;

                    }

 

                    private static const script_js:XML =

                              <script>

                                        <![CDATA[

                                                  function (){

                                                            var curwin = Titanium.UI.currentWindow;

                                                            JSL= {

                                                                      setSWFObjectID: function( swfObjectID ) {

                                                                                 JSL.swfObjectID = swfObjectID;

                                                                      },

 

                                                                      /*          Same Functions  */

 

                                                                      jsExit : function(){

  Titanium.exit();

                                                                      } 

                                                            };

                                                  }

                                        ]]>

                              </script>;

          }

}

How does ExternalInterace work with currect type?

 

If i use custom call like exit for Titanium Desktop than ExternalInterface will check currect type - like function type exit() = Titanium.exit(); as Type "String"

Or another example: File, FileSystem and FileStream are types as object, is it right?

Or Booleam Example true or false as type Booleam. ...

 

Is it posskible that externalInterface works fine with any types/functions?

 

I have been tested with ExternalInterface and In-Block Javascript = IT works fine... Look out! http://developer.appcelerator.com/question/135288/how-do-you-know-flas h-and-titanium

 

But i hate disturbated communication function like GWT external / fscommand...

 

I want use only AS3 / JS. Just i miss this nice example because i don't forget - where are nice examples? I wish because you would say me about currect result

 

Thanks i hope because i get nice answer / result for currect types / function for externalinterface via inblock: Javascript.

 
Replies
  • Currently Being Moderated
    Apr 16, 2012 5:30 AM   in reply to Jens Eckervogt

    Hi,

     

         I am not really clear with your above post. But you can communicate with javascript from flex by the below way.

     

    Javascript:

     

    function CallMe()

    {

         alert("Call Me");

    }

     

    function CallMeWithArg(value)

    {

         alert("This is your value: " + value);

    }

     

    Action Script:

     

    ExternaInterface.call('CallMe'); //without argument.

    ExternaInterface.call('CallMeWithArg', 'HelloWorld'); //with argument.

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 22, 2012 9:51 PM   in reply to Jens Eckervogt

    as far as i know, you can only pass strings to javascript. i am not sure about complex data types.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points