我宁愿使用.SWF文件隐藏我的.JS,而不是使用低密码术隐藏我的.JS。
问题是我对ActionScript 3一无所知,所以我想也许有人可以在隧道尽头给我一个灯,并告诉我我必须下载什么APP来编写Swf文件和什么代码我必须用它来工作。
如果有人没有发现我会说清楚:我想用SWF文件调用Javascript。
谢谢你,对不起的英语和再见感到抱歉。
答案 0 :(得分:1)
在Windows上,您可以下载FlashDevelop IDE,它会要求您下载Flex SDK(as3的免费编译器)。
您需要了解ExternalInterface类(Reference)。
出于安全原因,您需要在网络服务器上运行您的代码。
在HTML中,您需要param allowScriptAccess。
HTML CallJavascript
<script src="js/swfobject.js"></script>
<script src="http://code.jquery.com/jquery-1.11.2.min.js"></script>
<script>
var flashvars = {
};
var params = {
menu: "false",
scale: "noScale",
allowFullscreen: "true",
allowScriptAccess: "always",
bgcolor: "",
wmode: "direct" // can cause issues with FP settings & webcam
};
var attributes = {
id:"CallJavascript"
};
swfobject.embedSWF(
"CallJavascript.swf",
"altContent", "250", "250", "10.0.0",
"expressInstall.swf",
flashvars, params, attributes);
$( document ).ready(function() {
var flash = document.getElementById("CallJavascript");
$( "#btnSend" ).click(function() {
flash.jsMySecretMethod( $( "#field" ).val() );
});
});
</script>
<style>
html, body { height:100%; overflow:hidden; }
body { margin:0; background-color:#c0c0c0 }
</style>
</head>
<body>
<div id="altContent">
<h1>CallJavascript</h1>
<p><a href="http://www.adobe.com/go/getflashplayer">Get Adobe Flash player</a></p>
</div>
<input id="field" type="text"/><button id="btnSend">Send</button>
</body>
</html>
AS3
package
{
import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.Event;
import flash.external.ExternalInterface;
import flash.text.TextField;
/**
* ...
* @author
*/
public class Main extends Sprite
{
private var _textfield:TextField;
public function Main():void
{
if (stage) init();
else addEventListener(Event.ADDED_TO_STAGE, init);
}
private function init(e:Event = null):void
{
removeEventListener(Event.ADDED_TO_STAGE, init);
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
_textfield = new TextField();
_textfield.multiline = true;
_textfield.wordWrap = true;
_textfield.x = 20;
_textfield.y = 20;
_textfield.width = 200;
_textfield.height = 200;
_textfield.textColor = 0x000000;
_textfield.text = "start";
_textfield.border = true;
addChild( _textfield );
if ( ExternalInterface.available ) {
ExternalInterface.addCallback( "jsMySecretMethod", mySecretMethod );
}
}
private function mySecretMethod( str:String ):void {
trace( str );
_textfield.appendText( str );
}
}
}