2012-02-27 35 views
1

早上正義聯盟的Stackoverflow,Actionscript 2.0,BitmapData和本地vs遠程圖像

我在這裏有一個問題,可能會殘留面板。

我正在爲即將發生的事件創建交互式發佈,它允許我們使用sql數據庫併發布推文,調查問卷和圖像。我們已經開始使用Twitter API和調查,所以這些都是A-OK。

問題在於從本地交互板的服務器以外的位置加載圖像。

如果圖像本身是本地託管的,則它加載得很好。 如果圖像託管在其他地方,即使我在所述圖像的URL上有跟蹤,圖像也不會加載。

我正在通過XML加載加載所有推文,調查和圖片,並且所有數據都正確加載。

我AM通過平滑過濾器加載圖像,以便「稍後」輕微旋轉時,它們不會鋸齒狀。下面是該代碼:

import flash.display.*; 

var srcImg = _parent._parent.varContent; 
urlText.text = srcImg; 
var mainHolder = this.createEmptyMovieClip("main", this.getNextHighestDepth()); 
var original = mainHolder.createEmptyMovieClip("original", mainHolder.getNextHighestDepth()); 
var smooth = mainHolder.createEmptyMovieClip("smooth", mainHolder.getNextHighestDepth()); 
var mclListener:Object = new Object(); 
mclListener.onLoadInit = function() { 
    var w = original._width; 
    var h = original._height; 
    var bmpData1:BitmapData = new BitmapData(w, h, true, 0x000000);//true and 0 color allows for transparency 
    bmpData1.draw(original); 
    smooth.attachBitmap(bmpData1,2,"auto",true);//true for SMOOTHING, ;) 
    reSize(smooth); 
    original.removeMovieClip(); 
    mainHolder._x = -(smooth._width/2); 
    mainHolder._y = -(smooth._height/2); 
}; 
var image_mcl:MovieClipLoader = new MovieClipLoader(); 
image_mcl.addListener(mclListener); 
image_mcl.loadClip(srcImg,original); 

function reSize(target) { 
    if (target._width > target._height) { 
     s = Math.floor((300.85/target._height) * 100); 
    } 

    if (target._width < target._height) { 
     s = Math.floor((320.90/target._width) * 100); 
    } 
    target._xscale = s; 
    target._yscale = s; 
} 

這是一個兩個部分腳本,圖像中的批量加載,並將其放在一個空的動畫片段,然後添加平滑濾波器。第二部分是自動調整圖像大小並保持縱橫比的調整器

這是踢球者。當我測試閃存片(不是嵌入在HTML中)時,這個東西可以100%工作。 只要我把swf放入html並在網頁上查看它,遠程圖像就不會加載。

我有點難住這是爲什麼,這可能是防火牆或安全問題?因爲我在高安全防火牆環境中工作。

任何在這方面的指導將不勝感激。

謝謝你的時間。

+0

您是否有跨域訪問正在加載的圖像?如果你不這樣做,那麼嘗試執行位圖操作將不起作用。 – shanethehat 2012-02-27 15:12:24

+0

我在哪裏可以知道我是否有跨域訪問? – Murphy1976 2012-02-27 15:13:01

+0

我認爲它是一個位圖數據安全的東西。本文的第二部分應該有所幫助:http://www.onegiantmedia.com/as3---load-a-remote-image-from-any-domain-with-no-security-sandbox-errors – Zevan 2012-02-27 15:14:54

回答

1

默認情況下,flash不允許跨域加載數據作爲安全功能,但可以覆蓋它。

這可能會幫助: 的allowDomain(方法的Security.allowDomain),如果你能得到的圖像服務器

http://livedocs.adobe.com/flash/9.0/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00002104.html

跨域策略文件也可以在服務器上使用授予對運行的SWF訪問swf: http://help.adobe.com/en_US/AS2LCR/Flash_10.0/help.html?content=00000470.html

+0

好的...說這個應用程序託管在公共服務器上,並且所有我需要加載的圖像被FTP'd到這個相同的盒子,我不需要擔心任何這種安全的東西,對嗎? – Murphy1976 2012-02-27 16:39:14

+0

只要圖像在同一個域上,就不應有安全限制。 – Evert 2012-02-28 00:47:11