对象的间歇/交错加载

发布于 2024-09-05 09:06:37 字数 539 浏览 10 评论 0原文

我最近刚刚尝试使用 ActionScript 3,但遇到了障碍。 我如何间歇性地渲染立方体(cube1),即。交错装载。我需要立方体在瞬间相互加载。

以下是我迄今为止所掌握的内容的片段:

var rows:int = 5;
var cols:int = 3;
var spacery:int = 100;
var spacerx:int = 120;
var box_count:int = 8;

for(var i:int; i < box_count; i++)   {                                              
    cube1 = new Cube(ml,100,10,80,1,1,1);               
    cube1.y = ((i % rows)) * (cube1.x + spacery);
    cube1.x = Math.floor(i/rows) * (cube1.x +spacerx);
    cube1.z = 0;

    bigBox.addChild(cube1); 
}

I've just recently tried my hand at actionscript 3 and have come across a road block.
How do I go about rendering the cubes (cube1) intermittently, ie. staggered loading. I need the cubes to load a split second from each other.

Below is a snippet of what I have so far:

var rows:int = 5;
var cols:int = 3;
var spacery:int = 100;
var spacerx:int = 120;
var box_count:int = 8;

for(var i:int; i < box_count; i++)   {                                              
    cube1 = new Cube(ml,100,10,80,1,1,1);               
    cube1.y = ((i % rows)) * (cube1.x + spacery);
    cube1.x = Math.floor(i/rows) * (cube1.x +spacerx);
    cube1.z = 0;

    bigBox.addChild(cube1); 
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

帅气称霸 2024-09-12 09:06:37
//Create an array out side the function; as a global (instance) variable:
var cubes:Array = [];

//instead of bigBox.addChild(cube1), store them in the array:
cubes.push(cube1);

//initialize a timer outside after for loop
//Fire every 100 milliseconds, box_count times
var timer:Timer = new Timer(100, box_count);
timer.addEventListener(TimerEvent.TIMER, onTick);
timer.addEventListener(TimerEvent.TIMER_COMPLETE, onTickDone);

function onTick(e:Event):void
{
  bigBox.addChild(cubes[timer.currentCount]);
}
function onTickDone(e:Event):void
{
  cubes = null;
  timer.removeEventListener(TimerEvent.TIMER, onTick);
  timer.removeEventListener(TimerEvent.TIMER_COMPLETE, onTickDone);
  timer = null;
}
//Create an array out side the function; as a global (instance) variable:
var cubes:Array = [];

//instead of bigBox.addChild(cube1), store them in the array:
cubes.push(cube1);

//initialize a timer outside after for loop
//Fire every 100 milliseconds, box_count times
var timer:Timer = new Timer(100, box_count);
timer.addEventListener(TimerEvent.TIMER, onTick);
timer.addEventListener(TimerEvent.TIMER_COMPLETE, onTickDone);

function onTick(e:Event):void
{
  bigBox.addChild(cubes[timer.currentCount]);
}
function onTickDone(e:Event):void
{
  cubes = null;
  timer.removeEventListener(TimerEvent.TIMER, onTick);
  timer.removeEventListener(TimerEvent.TIMER_COMPLETE, onTickDone);
  timer = null;
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文