将Javascript隐藏在SWF文件中

Hide Javascript inside SWF file

本文关键字:文件 SWF Javascript 隐藏      更新时间:2023-09-26

与其使用低隐形图隐藏我的.JS,我更喜欢使用 .SWF 文件来隐藏我的.JS。

问题是我对 ActionScript 3 一无所知,所以我想也许有人可以在隧道尽头给我一盏灯,告诉我必须下载什么应用程序才能对 Swf 文件进行编程以及我必须使用什么代码才能工作。

如果有人没有解开,我会说清楚:我想用SWF文件调用Javascript。

谢谢,对不起英语不好,再见。

在Windows上,你可以下载FlashDevelop IDE,它会要求你下载Flex SDK(as3的免费编译器)。

您需要了解类外部接口(参考)。

出于安全原因,您需要使用闪存播放器在网络服务器上运行代码。

在HTML中,你需要参数allowScriptAccess。

.HTML 调用Javascript

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