加载动作脚本的问题
我可以在actionscript-3中执行以下操作吗? :
我想创建一个应用程序,通过向本地文件夹发出 URLRequests 来使用 Loader 加载一些图像。我可以构建应用程序并以某种方式包含此文件夹,以便当我将其从服务器发送到客户端时,URLRequests 在客户端正常运行吗?另外,如果可能的话,客户端可能无法查看/访问该文件夹,而只能通过其附带的 Flash 应用程序查看/访问该文件夹? 例如,这段代码在我的机器上本地运行良好,如果我将其发送到客户端,它将继续在其机器上运行。能否以某种方式将文件夹和 SWF 作为一个对象发送?
private function clothesOn( outfit:String ) {
var clothier:Loader = new Loader();
var item:String = "clothes/" + outfit + ".gif";
var getItem:URLRequest = new URLRequest( item );
clothier.load( getItem );
this.addChild( clothier );
}
ps:代码取自actionscript设计模式。
Can i do the following in actionscript-3? :
I want to make an application that loads some images with a Loader by making URLRequests to a local folder. Can i build the application and include somehow this folder so when i send it from a server to a client the URLRequests operate normally on clients side? Also if this is possible, the folder may be not viewable/accessible by the client but only from the Flash application that comes with it?
So for example, this piece of code that runs nicely, locally, to my machine, if i send it to a client will continue to run to its machine. Can somehow send the folder and the SWF as one object?
private function clothesOn( outfit:String ) {
var clothier:Loader = new Loader();
var item:String = "clothes/" + outfit + ".gif";
var getItem:URLRequest = new URLRequest( item );
clothier.load( getItem );
this.addChild( clothier );
}
ps:code taken from actionscript design patterns.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
除非将文件作为库资源添加到 Flash 文件本身中,否则无法将文件发送到客户端。
但是,如果该文件夹在服务器上的相对位置与本地计算机上的相对位置相同,并且您指示 flash 文件使所有路径都相对于自身(使用 base:'.' 参数),则 flash 文件应该能够找到您的图像文件,而无需先将它们发送给客户端。
基本参数是您在页面中嵌入 Flash 文件时可以指定的值。请参阅此处:
http://kb2.adobe.com/cps/127/tn_12701.html
使用 SWFObject,代码将如下所示:
设置该参数后,Flash 文件中的 url 将相对于文件本身的位置。因此,假设您的服务器上有这样的结构:
Flash 文件将很好地加载像
'folder/img1.jpg'
这样的 url。There's no way to send files to the client unless they're added as library assets in the flash file itself.
However, if the folder is on your server in the same relative location as it is on your local machine, and you instruct the flash file to make all paths relative to itself (using the base:'.' param) then the flash file should be able to find your image files without needing to send them to the client first.
The base param is a value you can specify when embedding your flash file in your page. See here:
http://kb2.adobe.com/cps/127/tn_12701.html
Using SWFObject, the code would look something like this:
Once that param is set, urls within your flash file will be relative to the location of the file itself. So assuming you have a structure like this on your server:
a url like
'folder/img1.jpg'
will be loaded by the flash file just fine.