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 に答える