0
我的URL請求在Flash Pro中完美運行,但是當我在瀏覽器中測試它時,圖像根本不起作用。它不加載。是否有我需要使用的發佈設置?AS3 URLRequest在瀏覽器中不起作用
請幫忙,這很令人沮喪。 Here's它在瀏覽器中的樣子。
相關代碼:
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();
}
Flash無法從比它託管,除非一個有效的跨域政策的另外一個Web服務器加載數據是在目標服務器上進行。閱讀更多: - http://www.adobe.com/devnet/flashplayer/articles/cross_domain_policy.html –
這個答案幫了我很多,相同的問題 http://stackoverflow.com/questions/13131638/flash-cs6- AS3 - 測試 - 電影中的瀏覽器 - 不工作 –