0

我的 URL 请求在 Flash Pro 中运行良好,但是当我在浏览器中对其进行测试时,图像根本不起作用。它不加载。是否有我需要使用的发布设置或其他什么?

请帮忙,这很令人沮丧。是它在浏览器中时的样子。

相关代码:

    public function startSlidingPuzzle() {
        // blank spot is the bottom right
        blankPoint = new Point(numPiecesHoriz-1,numPiecesVert-1);

        // load the bitmap
        loadBitmap("http://fc07.deviantart.net/fs71/f/2014/030/d/7/slidingimage_by_nooodisaster-d74et6t.jpg");
    }

    // get the bitmap from an external source
    public function loadBitmap(bitmapFile:String) {
        var loader:Loader = new Loader();
        loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadingDone);
        var request:URLRequest = new URLRequest(bitmapFile);
        loader.load(request);
    }

    // bitmap done loading, cut into pieces
    public function loadingDone(event:Event):void {
        // create new image to hold loaded bitmap
        var image:Bitmap = Bitmap(event.target.loader.content);
        pieceWidth = image.width/numPiecesHoriz;
        pieceHeight = image.height/numPiecesVert;

        trace(numPiecesHoriz)

        // cut into puzzle pieces
        makePuzzlePieces(image.bitmapData);

        // shuffle them
        shufflePuzzlePieces();
    }
4

1 回答 1

1

您有一个安全错误:

SecurityError: Error #2122: Security sandbox violation: Loader.content: http://fc03.deviantart.net/fs71/f/2014/030/e/e/beyonce_slidingpuzzle___flash_diary_day_10_by_nooodisaster-d74er8h.swf cannot access http://i.stack.imgur.com/ls9QI.jpg. A policy file is required, but the checkPolicyFile flag was not set when this media was loaded.
at flash.display::Loader/get content()
at SlidingPuzzle/loadingDone()

尝试添加安全上下文:

public function loadBitmap(bitmapFile:String)
{
    var loader:Loader = new Loader();
    loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadingDone);

    var context:LoaderContext = new LoaderContext();
    context.applicationDomain = ApplicationDomain.currentDomain;
    context.securityDomain = SecurityDomain.currentDomain;
    context.checkPolicyFile = true;

    var request:URLRequest = new URLRequest( bitmapFile );
    loader.load( request, context );
}

如果这不能解决它,您需要将 crossdomain.xml 添加到托管您请求的图像的服务器。为什么不将图像保存在本地并将它们部署在与您的构建相同的范围内?

[1]:

于 2014-01-31T18:55:30.523 回答