动作3:检查外部文件是否存在,如果是取消隐藏的MovieClip [英] actionscript 3: Check if an external file exists and if so unhide a movieClip
本文介绍了动作3:检查外部文件是否存在,如果是取消隐藏的MovieClip的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想检查外部文件是否存在,如果是更改某个影片剪辑真正的可见性的价值。我知道该怎么做,在AS2,但我在AS3工作。
I'm trying to check if an external file exists and if so change the value of the visibility of a certain movie clip to true. I know how to do it in AS2, but I'm working in AS3.
这是AS2 code,我曾经工作:
This is the AS2 code that I used to work with:
onClipEvent (load) {
fileExists = new LoadVars();
fileExists._parent = this;
fileExists.onLoad = function(success) {
//success is true if the file exists, false if it doesnt
if (success) {
_root.visiblity = 1;
//the file exists
}
};
fileExists.load('visibility.exe');//initiate the test}
}
如何使它在AS3工作?谢谢!
How to make it work in AS3? Thanks!
推荐答案
类 flash.net.URLLoader
。从的Adobe的ActionScript 3.0参考:
var urlRequest:URLRequest = new URLRequest("visibility.exe");
var urlLoader:URLLoader = new URLLoader();
urlLoader.dataFormat = URLLoaderDataFormat.BINARY;
urlLoader.addEventListener(Event.COMPLETE, urlLoader_complete);
urlLoader.addEventListener(IOErrorEvent.IO_ERROR, urlLoader_error);
urlLoader.load(urlRequest);
function urlLoader_complete(evt:Event):void {
trace("file found");
}
function urlLoader_error(evt:IOErrorEvent):void {
trace("file obviously not found");
}
不要忘了导入所需的类。
Don't forget to import required classes.
这篇关于动作3:检查外部文件是否存在,如果是取消隐藏的MovieClip的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文