如何使用actionscript 3.0代码上传背景图片? [英] How to upload a background image using actionscript 3.0 code?
本文介绍了如何使用actionscript 3.0代码上传背景图片?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
需要你的帮助。我正在尝试第一次。
我已经使用下面的代码。
但是我在控制台中得到了这个结果:
开始加载文件
SecurityError:Error#2000:No active security context。
我的图片网址与我的脚本文件位于同一个文件夹中。
var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event。 COMPLETE,fileLoaded);
loader.load(new URLRequest(C:\Documents and Settings\Owner\Desktop\23Aug\demo1\microp),context);
var context:LoaderContext = new LoaderContext();
context.applicationDomain = ApplicationDomain.currentDomain;
trace(开始加载文件);
addChild(loader);
函数fileLoaded(event:Event):void
{
trace(file loaded);
$ / code $ / pre
解决方案抛出securityError异常的原因。 试图访问安全沙箱不允许访问的URL,尝试访问已被用户拒绝的设备(例如: )。 ,相机,麦克风。)
试试这个
private var _loader:Loader = new Loader();
private var _context:LoaderContext = new LoaderContext();
private var _url:URLRequest = new URLRequest(demo1 / mic.jpg);
_context.checkPolicyFile = false;
_loader.contentLoaderInfo.addEventListener(Event.COMPLETE,onImageloaded);
//_loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR,onIOError);
_loader.load(_url,_context);
private function onImageloaded(e:Event):void {
addChild(e.target.content);
}
Need your help. I am trying it first time.
I have used following code.
But i get this in my console:
started loading file
SecurityError: Error #2000: No active security context.
and my image url is in same folder as my script file.
var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, fileLoaded);
loader.load(new URLRequest("C:\Documents and Settings\Owner\Desktop\23Aug\demo1\mic.jpg"), context);
var context:LoaderContext = new LoaderContext();
context.applicationDomain = ApplicationDomain.currentDomain;
trace("started loading file");
addChild(loader);
function fileLoaded(event:Event):void
{
trace("file loaded");
}
解决方案 Reasons to throw securityError exception.
- Invalid path,
- Trying to access a URL, that not permitted by the security sandbox,
- Trying a socket connection, that exceeding the port limit, and
- Trying to access a device, that has been denied by the user(Ex., camera, microphone.)
try this
private var _loader:Loader = new Loader();
private var _context:LoaderContext = new LoaderContext();
private var _url:URLRequest = new URLRequest("demo1/mic.jpg");
_context.checkPolicyFile = false;
_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onImageloaded);
//_loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, onIOError);
_loader.load(_url, _context);
private function onImageloaded(e:Event):void{
addChild(e.target.content);
}
这篇关于如何使用actionscript 3.0代码上传背景图片?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文