存储在数组中的 AS3 URLRequest 现在需要加载,如何?
大家好,我这里有一些代码,可以从文件中随机提取 50 个图像并将它们推送到一个数组中。我现在需要从数组中随机拉取 350 次。我使用计时器代替 for 循环来从数组中获取图像。只要我不使用数组并且直接从文件循环图像,我的代码就可以正常工作。但这是非常缓慢且糟糕的形式。我想我可以做除了数组的 .load 之外的所有事情。我似乎无法让它发挥作用。我收到错误消息“#1009:无法访问空对象引用的属性或方法”或“1067:将 Array 类型的值隐式强制为不相关的类型 flash.net:URLRequest”。我想我明白了这些消息的要点,但我似乎无法弄清楚如何将 URLRequests 从数组中拉出来。请您提供任何帮助,我们将不胜感激。
var imgLoader:Loader;
var imgSource:URLRequest;
var imgArrayer:Array = new Array();
var imgNum:uint;
var timer1Count:uint;
var thumbFade:Tween;
var layerCount:uint = 0;
for(var i:uint = 0; i < 50; i++) {
imgNum = Math.random() * _imgCount;
imgSource = new URLRequest("thumbsFinal/img"+imgNum+".jpg");
imgArrayer.push(imgSource);
}
var myTimer:Timer = new Timer(_imgTrTime, _imgTrInt);
myTimer.addEventListener(TimerEvent.TIMER, timedFunction);
myTimer.start();
function timedFunction(e:TimerEvent):void{
imgLoader.load(imgArrayer);
thumbFade = new Tween(imgLoader, "alpha", Regular.easeIn, _thumbFaderB, _thumbFaderF, _thumbFaderSpd, true);
addChildAt(imgLoader, layerCount);
imageAdjust();
timer1Count++;
layerCount++;
if(timer1Count == _scrnFadeTimer) {
screenFade();
}
else if(timer1Count == _txtDeploy){
textTween();
}
}
Hey guys, I have a bit of code here that pulls, at random, 50 images from a file and pushes them into an array. I now need to pull, at random, 350 times from the array. I'm using a timer in place of the for loop to grab the images from the array. My code works fine as long as I do not use an array and I loop the images straight from the file. But that's very slow and bad form. I think I can do everything except the .load of the array. I can't seem to make it work. I'm getting errors that say "#1009: Cannot access a property or method of a null object reference" or "1067: Implicit coercion of a value of type Array to an unrelated type flash.net:URLRequest". I think I get the point of these messages, but I cannot seem to figure out how to pull the URLRequests back out of the array. Please, any help is much appreciated.
var imgLoader:Loader;
var imgSource:URLRequest;
var imgArrayer:Array = new Array();
var imgNum:uint;
var timer1Count:uint;
var thumbFade:Tween;
var layerCount:uint = 0;
for(var i:uint = 0; i < 50; i++) {
imgNum = Math.random() * _imgCount;
imgSource = new URLRequest("thumbsFinal/img"+imgNum+".jpg");
imgArrayer.push(imgSource);
}
var myTimer:Timer = new Timer(_imgTrTime, _imgTrInt);
myTimer.addEventListener(TimerEvent.TIMER, timedFunction);
myTimer.start();
function timedFunction(e:TimerEvent):void{
imgLoader.load(imgArrayer);
thumbFade = new Tween(imgLoader, "alpha", Regular.easeIn, _thumbFaderB, _thumbFaderF, _thumbFaderSpd, true);
addChildAt(imgLoader, layerCount);
imageAdjust();
timer1Count++;
layerCount++;
if(timer1Count == _scrnFadeTimer) {
screenFade();
}
else if(timer1Count == _txtDeploy){
textTween();
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
该位可能是:
拉动 350 次的位将是:
在该计时器中调用 350 次
this bit might be:
and the bit that pulls 350 times would be:
called in that timer 350 times