0
我仍然是flash的新手,但是有可能讓Flash從當前所在的服務器獲取文件,然後將這些文件發送到某處?如何訪問Flash中的服務器端文件
我仍然是flash的新手,但是有可能讓Flash從當前所在的服務器獲取文件,然後將這些文件發送到某處?如何訪問Flash中的服務器端文件
您需要使用server side scripting語言,例如PHP。
Flash會向服務器發送請求(PHP文件),服務器端腳本將檢索相關信息並將其發送回Flash。然後你可以用Flash從你想做的事情做起。
有關ActionScript 3.0的更多幫助,請查看forums at www.kirupa.com。
如果你只是想將文件加載到Flash(如圖像)來顯示它,請試試這個Actionscript。只需複製並將其放到「動作」面板中即可。 (從我的post on kirupa):
//Create instance of the Loader class
var loader:Loader = new Loader();
//Create instance of the URLRequest class and pass the URL as a string
var request:URLRequest = new URLRequest("myfile.jpg");
//Initiate the load process
loader.load(request);
//When the file finishes loading, the following will call addImageToMovieClip()
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, addImageToMovieClip);
function addImageToMovieClip(event:Event):void
{
trace("Your loaded content is of type " + event.target.content);
//Add the loaded content to the movieclip called "mc"
mc.addChild(event.target.content);
}
所以我也必須有一個PHP腳本,我不能只是用一個Flash文件做? Flash文件是否可以將PHP腳本提取到服務器? – flashnoob 2010-06-05 15:22:17
正確的需要PHP。 Flash是「客戶端」,不能直接與服務器通信。我不完全確定你的意思是提取。如果你的意思是把PHP代碼放在Flash文件中,那是行不通的。查看「URLLoader」和「URLRequest」的Actionscript 3規範。這些將允許您從服務器加載PHP文件。然而,在將其加載到Flash文件之前,PHP腳本將檢索您指示它在其代碼中執行的任何操作。 – 2010-06-05 15:25:39
這有道理嗎? – 2010-06-05 15:26:08