DonJuma
DonJuma

Reputation: 2094

Trigger jquery with flash

I would like to know if it is possible to trigger a jquery function to hide something after a Mouse event in flash.

I want this to run when something is clicked in flash:

  $("#googframe").click(function() {
    $("#googframe").hide();
  });

i know how to monitor a click in AS3 but how do i get it to trigger this. By the way i am very basic so a good explanation is much appreciated.

Thanks.

Upvotes: 0

Views: 1155

Answers (3)

Fosco
Fosco

Reputation: 38526

From this source: http://codingrecipes.com/calling-a-javascript-function-from-actionscript-3-flash

try in Actionscript:

import flash.external.ExternalInterface;

...

ExternalInterface.call("hideFrame");

and put your hide function in a regular function in JS:

function hideFrame() {
   $("#googframe").hide();
}

Upvotes: 2

mway
mway

Reputation: 4392

As @Fosco said, use ExternalInterface, however the syntax should be as follows:

In AS2/AS3:

import flash.external.ExternalInterface;
ExternalInterface.call('myJsFunction'[, args...])

In Javascript:

function myJsFunction() {
    ...
}

The rest of the arguments after the first are parameters to the function that will be called (parameter list, varargs, etc).

So, as an example:

AS2/AS3:

ExternalInterface.call('addIntegers', 1, 2);

JS:

function addIntegers(a, b) {
    doSomethingWith(a + b);
    // etc.
}

Upvotes: 1

Scott
Scott

Reputation: 3977

In flash call this when you need it to:

            url = "javascript:hideFlash();";
            request = new URLRequest(url);
            try
            {
                navigateToURL(request, "_top");
            }
            catch (e:Error)
            {
                trace("Error occurred!");
            }

then create you JS function called hideFlash();

Upvotes: 0

Related Questions