2

This is my problem:

I have this class in JavaScript:

var c = new MyClass();
c.myFunction();
c.myFunction2();
c.myFunction3();
//and so on...

How can I reference this with ExternalInterface.call?

I can't do this: ExternalInterface.call("c.myFunction"));

3 Answers 3

4

In order for this to work, the object you are trying to call from Flash needs to have global scope. I.e., this will not work:

// closure to keep vars out of global scope - generally a good thing!
(function() {
    var c;

    function MyClass() {
    }
    MyClass.prototype.myFunction = function() {
        alert('Do something!');
    }

    c = new MyClass();
})();

... meanwhile, in Flash ...

ExternalInterface.call("c.myFunction");

What you need is a global entry-point for the object. What errors are you getting, though? Are you getting null back from the call? Is any specific Error being thrown?

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

1 Comment

thank you for reminding. when people started using jQuery, they just forget what is what and start wondering why it's not working.
3

Yes, you can (do this: ExternalInterface.call("c.myFunction")).

2 Comments

It doesn't work Omer. I don't see a difference from what I posted.
+1 It should work, if its not you have a bug some where else. What scope is "c" in?
0

Publish it to a server and call the html page that way.
ExternalInterface has issues when running in the flex project file system.
Mostlikely its an embed/crossdomain issue.

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.