2010-06-14 4 views
1

나는 최근에 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); 
} 
+0

당신이 타이머를 시도 : 아래

내가 지금까지 무엇을의 조각인가? – phwd

답변

2
//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; 
} 
관련 문제