从JavaScript传递变量闪光 [英] Passing variable from javascript to flash
问题描述
我有一个闪光的音乐播放器,我想通过一个按钮点击一个网站,以接受一个参数。我想我可以用JavaScript做到这一点,但不知道如何。
I have a flash music player that I would like to accept a parameter via a button click on a website. I'm thinking I could do this with javascript but not sure how.
没有任何人有任何样本code为JavaScript的,我会用它来请求变量中我的动作code是什么?
Does anybody have any sample code for both the javascript and what I would use to request the variable inside my actionscript code?
谢谢,我AP preciate了!
Thanks, I appreciate it!
推荐答案
的 http://painteddigital.com/2008/calling-flash-as3-functions-from-javascript/
在闪光灯添加一个回调的javascript函数:
In the flash add a callback for the javascript function:
import flash.external.ExternalInterface;
ExternalInterface.addCallback("sendTextToFlash", getTextFromJavaScript);
function getTextFromJavaScript(str):void {
trace(str);
}
在HTML / JS调用它:
In the html/js call it:
<script type="text/javascript">
var currentPage="Home";
function setCurrentPage(newPage) {
currentPage = newPage;
SendDataToFlashMovie(newPage);
}
JS调用功能在Flash:的getURL(JavaScript的:MyFunction的(););
Calling JS Function From Flash: getURL("javascript:myfunction();");
这篇关于从JavaScript传递变量闪光的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!