0

Is there any way to call from javascript to actionscript, not using JSON object.

thanks, Ravi

3 Answers 3

4

ExternalInterface could be your friend :

http://livedocs.adobe.com/flex/3/langref/flash/external/ExternalInterface.html

or

http://livedocs.adobe.com/flex/3/html/help.html?content=passingarguments_5.html

(I'm not sure the second link will work, though ... )

Sign up to request clarification or add additional context in comments.

3 Comments

So from actionscript to javscript and vice versa, using ExternalInterface only. am i correct?
Yes, you can either call a function declared in JS from AS, or register an AS function so that it can be called by JS.
By the way, ExternalInterface communicates using XML-encoded objects, not JSON. The encoding/decoding is done behind the scenes, transparent to your use, but the calls could take a long time if it has to encode a complex object in XML.
2

You can call a function inside your Flash with the following Javascript:

 <script>
 function callToFlash(param)
 {
      var fl = document.getElementById('idOfFlashObject');
      if(fl != null)
      {
          fl.functionInFlash(param);
      }
 }
</script>

More about this can be found at the Adobe Knowledge Base: http://kb2.adobe.com/cps/156/tn_15683.html

1 Comment

You have to register the function (using ExternalInterface.addCallback) in Flash first before it can be called from JavaScript.
0

You might want to consider using the Flex-Ajax Bridge.

Read: About the Flex Ajax Bridge

Enjoy!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.