如何访问Flash中的服务器端文件

时间:2010-06-05 15:13:35

标签: flash

我仍然是flash的新手,但是有可能让Flash从当前服务器上获取文件,然后将这些文件发送到某个地方吗?

1 个答案:

答案 0 :(得分:0)

您需要使用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);
}