开发者

AS3 functions and accessing variables

开发者 https://www.devze.com 2023-01-06 21:52 出处:网络
I\'m trying to create a JW player plugin, a part of the source code is shown below: public function initPlugin(player:IPlayer, config:PluginConfig):void {

I'm trying to create a JW player plugin, a part of the source code is shown below:

        public function initPlugin(player:IPlayer, config:PluginConfig):void {
        api = player;

        var streamUrl:String = 'xxx';
        var streamSecret:String = 'xxx';
        var xid:String = config['xid'];

        var request:URLRequest = new URLRequest("xxx"+xid);
        request.method = URLRequestMethod.POST;

        var loader:URLLoader = new URLLoader();
 开发者_JAVA技巧       loader.dataFormat = URLLoaderDataFormat.VARIABLES;
        loader.addEventListener(Event.COMPLETE, completeHandler);
        loader.load(request);

        var fileName:String, drive:String, userFolder:String, t_hex:String, linkType:String

        function completeHandler(evt:Event) {
            linkType = evt.target.data.linkType;
            fileName = evt.target.data.filename;
            drive = evt.target.data.drive;
            userFolder = evt.target.data.userFolder;
            t_hex = evt.target.data.t_hex;

            if (linkType == "1")
            {
                /*
                PHP will generate these variables for the plugin.
                fileName, drive, userFolder, t_hex
                */

                var relPath:String = "/"+drive+"/"+userFolder+"/"+fileName;
                var md5Hash = MD5.encrypt (streamSecret+relPath+t_hex);

                var link:String = streamUrl+md5Hash+"/"+t_hex+relPath;
            } else
            {
            }

            api.load('http://music-stream.burst-dev.com/test.flv');
            api.play();

        }

I'm currently stuck on getting api.load('') to actually load the file. I've tested through anthropod and the variables getting added in are a-okay and the link generates perfectly.

I think my error is trying to get api = player to be accessed by function completeHandler, but it is not able to. Anyone got any ideas?


The code above worked, using Anthropod, I found out that it still was a crossdomain issue. I solved it by loading all files under the same URL basename. For example, xxx.burst-dev.com. api.load however can load files abroad, despite the crossdomain need in AS3 files.

0

精彩评论

暂无评论...
验证码 换一张
取 消