开发者

Problem Setting URLRequest Path

开发者 https://www.devze.com 2022-12-11 09:25 出处:网络
fla files which is calling default page . but it\'s not able to find the default page.. my default.aspx page is in root directory ,

fla files which is calling default page . but it's not able to find the default page.. my default.aspx page is in root directory , and my fla file is in ../capture/image.fla . here is my code

function onSaveJPG(e:Event):void{
    var myEncoder:JPGEncoder = new JPGEncoder(100);
    var byteArray:ByteArray = myEncoder.encode(bitmapData);

    var header:URLRequestHeader = new URLRequestHeader("Content-type", "application/octet-stream");

    var url:String = "../../default.aspx";

    var saveJPG:URLRequest = new URLRequest(url);
    saveJPG.requestHeaders.push(header);
    saveJPG.method = URLRequestMethod.POST;
    saveJPG.data = byteArray;



    var urlLoader:URLLoader = new URLLoader();
    urlLoader.addEventListener(Event.COMPLETE, sendCompl开发者_如何转开发ete);
    urlLoader.load(saveJPG);

    function sendComplete(event:Event):void{
        warn.visible = true;
        addChild(warn);
        warn.addEventListener(MouseEvent.MOUSE_DOWN, warnDown);
        warn.buttonMode = true;
    }

Any pointer or suggestion how to set virtual path in flash?? Thanks


The safest route is to use absolute paths instead of relative paths. in your case you could do

var url:String = "/default.aspx";

Flash looks at paths from the point the swf file is included into the HTML so if your default.aspx is also serving the flash embed code the relative path would be "default.aspx"

If you want to test while exporting from FLASH CS4 you will have to use a complete URL like

var url:String = "http://localhost/default.aspx"

I usually include this bit of code to make testing easier

import flash.system.Capabilities;

    ...
        var url:String = "/default.aspx";
        //test if playing in external player or in a browser
        if(Capabilities.playerType == "External") {
            url = "http://localhost"+url;
        }
    ...


check using this...

var url:String = "~/default.aspx";
0

精彩评论

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