Trigger jquery with flash

邮差的信 提交于 2019-12-25 01:15:49

问题


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.


回答1:


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();
}



回答2:


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.
}



回答3:


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();



来源:https://stackoverflow.com/questions/4125518/trigger-jquery-with-flash

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!