2012-03-07 30 views
0

此處爲第一個計時器。打包適用於Android/IOS的​​Flash Builder應用程序 - 資產目錄Q

我一直在編寫一個旨在部署到移動平臺(iOS和Android)上的應用程序。這使用Flash Builder 4.6的Android構建目標 - 它使用/ assets /目錄中的子目錄,其中包含任意數量的.png文件。

我的代碼目錄裝載機這樣:

public function LoadFromDirectory(directoryName:String, store:Vector.<BitmapData>):Boolean 
{ 
    //Changed here: this should work on both the development environment, AND the device. 
    //Guess what... 

    imageDirectory = File.applicationDirectory.resolvePath("assets/" +directoryString); 

    //This is triggering on Android. Doesn't do so in ADL. Not tested on iOS yet, 
    //but come on, if it doesn't work here, it won't work on iOS... 

    if (!imageDirectory.isDirectory) 
    { 
     trace("Directory not found:" +imageDirectory.url); 
     return false; 
    } 

    /*Snip loop through the contents of this directory, loading anything that is 
    a PNG and storing the bitmapData of all loaded PNGs into the vector, one by one*/ 

    /*This of course, ALL works in ADL*/ 
} 

這工作在空氣中的虛擬設備,但不工作在移動設備或部署。這是我卡住的地方。

編輯:好吧,我走了,並減少了文件代碼只有一行。我應該使用resolvePath來實現跨平臺兼容性;另外,Flash Builder的打包程序除非將其放在「bin-debug \」中,否則不會看到「assets \」子目錄,因爲這是編譯的SWF去的地方。

仍然沒有解決問題 - 至少在Android版本中,我可以看到apk中的資源文件夾(通過將其重命名爲.zip並將其全部提取),並且它是正確的(旁邊應用程序的XML文件和SWF)。

apk安裝並運行,但當我在設備本身上進行調試(再次,不在ADL上 - 僅在設備上)時,isDirectory仍然返回false。如果評論整個if ...段會導致應用程序崩潰,因爲它無法找到assets \目錄。

我很接近解決問題;如果有人幫助我完成了最後一步,我會很感激,因爲它正在花費血腥的時間。 PS:我很樂意簡單地將這些圖像嵌入FLA或SWC中,我之前已經完成了它的工作。不幸的是,該特定目錄中的圖像的數量和名稱是任意;我唯一確定的是受支持的擴展。

PPS:此功能的用法:LoadImagesFromDirectory(「imagesdirectory」),它應該在任何平臺的app/assets/images目錄下查找。布爾返回值用於調試(如果不存在該名稱的目錄,則返回false)

回答

3

...好的,我不知道這是否有記錄,但顯然我調用了LoadImagesFromDirectory作爲目錄名這是全部大寫,因爲在PC上,目標目錄也是全部大寫。

所以在測試平臺中,目錄解析爲「app:/ assets/IMAGESDIRECTORY」。 但是在導出時,設備顯示的目錄改爲解析爲「app:/ assets/Imagesdirectory」,因此對IMAGESDIRECTORY的調用無效。

奇怪的是,尋找「Imagesdirectory」適用於個人電腦和設備,無需更改文件夾佈局和名稱。

看起來像我一直被困 - 記住永遠不要給全部大寫的目錄名稱...

+0

這幫了我:) – ThanksBro 2013-09-06 11:43:39

相關問題