javascriptjqueryactionscript-3actionscriptexternalinterface

JavaScript onClick function to trigger ActionsScript3 Event


Before I begin I will explain that I am relatively new to ActionScript, also newish to JavaScript but have a handle on what I can/need to do.

I have done some hunting online to find out what is needed to do this, however I am not 100% sure on how to do it.

The only tutorials I am able to find are about sending text from one to the other and vice versa.

What I am trying to achieve:

[JavaScript]

HTML element is clicked.

[ActionScript]

Performs an Event and passes Boolean back to JavaScript on success/error.

[JavaScript]

Dependent on true/false will have methods in place to continue.

I am NOT asking you to do this for me, however if you know of any good documentation/tutorials that you can point me to I would appreciate it. I am wanting to learn how to do this, not get shown/told how to do it.

Tutorials I have already read:

AGAIN thanks for any help / useful links that come my way :)


Solution

  • Well I have found a possible answer to my prayers!

    A very nice gentleman on REDDIT pointed out the best way for me to achieve this.

    Every tutorial / suggestion I could find was doing it the opposite way to what was required.

    I needed [ACTIONSCRIPT] to have an Event fire when a [JAVASCRIPT] element was triggered onClick so that a function could be called.

    The answer given to me was :

    Register a handler in Flash with:

    ExternalInterface.addCallback('jsFunction', asHandler);

    After this I can call my function in JavaScript on the Flash Movie Object.

    This appears to work, I will leave this question open for the next couple of days to see if anyone has any objections to this being the accepted answer.