0

So in my AS file I want to call a function like

        public function JS(streamUri:String):void{
        JavascriptCommand(streamUri)
        }

to get my JS code running...

How to do such thing (Example needed)

2 Answers 2

3

It sounds like you're looking for ExternalInterface.call(). Adobe has an article about how to use it to call JavaScript from ActionScript.

You can also use ExternalInterface to expose ActionScript to JavaScript and call functions internal to your SWF from JavaScript.

Let's say you have a JavaScript function that looks like this:

function specialAlert(msg) {
  alert(msg);
}

From your flash file you can call it like this:

import flash.external.*;

ExternalInterface.call("specialAlert", "Hi mom!");

And your JavaScript function should be called and alert the user "Hi mom!".

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

Comments

2

Here's how to call JS from flex: http://www.switchonthecode.com/tutorials/flex-javascript-basics-using-externalinterface

1 Comment

And Is there a way to send a full body of JS functions?

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.