In first example tween(s) occasionally prematurely stop:
package {
//are main stage is a movieclip
import flash.display.MovieClip;
import flash.events.Event;
import flash.utils.Timer;
import flash.utils.*;
import flash.events.*;
import fl.transitions.Tween;
import fl.transitions.easing.*;
import fl.transitions.easing.None;
import fl.transitions.TweenEvent;
public class Game extends MovieClip {
//varibles
public var brickStack1:Array = new Array(1);
public var brickStack2:Array = new Array(1,1);
public var brickStack3:Array = new Array(1,1,1);
public var brickStack4:Array = new Array(1,1,1,1);
public var brickStack5:Array = new Array(1,1,1,1,1);
public var arrayOfBricks:Array = new Array(brickStack1,brickStack2,brickStack3,brickStack4,brickStack5);
public var brickLoader:Timer = new Timer(2000,0);
//public var arrayLength:int = 0;
public var brickStack:int = 0;
public var brickStackBottom:int = 0;
var arrayLength:int = 0;
var arrayLengthBottom:int = 0;
var brickTween:Tween;
public function Game() {
trace("game");
//addEventListener (TimerEvent.TIMER , loop);
brickLoader.addEventListener (TimerEvent.TIMER , loop);
brickLoader.start();
//create a new instance of the Brick
//var brickTween = new Tween( k,"x", None.easeNone , k.x,k.x - 1000, 5, true);
}
function loop(e:TimerEvent):void {
//declare a varible for the for loop with Math.random
brickStack = Math.floor(Math.random() * 5) ;
//trace(brickStack);
if(brickStack == 0) {
brickStackBottom = 4;
}
if(brickStack == 1) {
brickStackBottom = 3;
}
if(brickStack == 2) {
brickStackBottom = 2;
}
if(brickStack == 3) {
brickStackBottom = 1;
}
if(brickStack == 4) {
brickStackBottom = 0;
}
arrayLength = arrayOfBricks[brickStack].length;
arrayLengthBottom = arrayOfBricks[brickStackBottom].length;
trace(arrayLengthBottom);
//arrayOfBricks[brickStack];
//brick load ratio 1:5 2:4 3:3 4:2 5:1
//+4*5/5 +2*4/4 +0*3/3 -2*2/2 -4*1/1
//formulate a mathmatically loader paradiam
for(var i:int = 0;i < arrayLength; i++){
bottomLoop();
var obj:Brick = new Brick();
obj.x = stage.stageWidth + obj.width;
obj.y = (i*40);
addChild(obj);
brickTween = new Tween( obj,"x", None.easeNone , obj.x,obj.x - (stage.stageWidth + obj.width*3), 4, true);
}
}
function bottomLoop() {
for(var o:int = 0;o < arrayLengthBottom; o++){
var objBottom:Brick = new Brick();
objBottom.x = stage.stageWidth + objBottom.width;
objBottom.y = (stage.stageHeight - 40) - (o*40);
addChild(objBottom);
brickTween = new Tween( objBottom,"x", None.easeNone , objBottom.x,objBottom.x - (stage.stageWidth + objBottom.width*3), 4, true);
}
}
}
}
In this example tween(s) prematurely but than moments later continue.
package {
//are main stage is a movieclip
import flash.display.MovieClip;
import flash.events.Event;
import flash.utils.Timer;
import flash.utils.*;
import flash.events.*;
import fl.transitions.Tween;
import fl.transitions.easing.*;
import fl.transitions.easing.None;
import fl.transitions.TweenEvent;
public class Game extends MovieClip {
//varibles
public var brickStack1:Array = new Array(1);
public var brickStack2:Array = new Array(1,1);
public var brickStack3:Array = new Array(1,1,1);
public var brickStack4:Array = new Array(1,1,1,1);
public var brickStack5:Array = new Array(1,1,1,1,1);
public var arrayOfBricks:Array = new Array(brickStack1,brickStack2,brickStack3,brickStack4,brickStack5);
public var brickLoader:Timer = new Timer(2000,0);
//public var arrayLength:int = 0;
public var brickStack:int = 0;
public var brickStackBottom:int = 0;
var arrayLength:int = 0;
var arrayLengthBottom:int = 0;
var arrayOfObjects:Array = new Array();
var i:int = 0;
public function Game() {
trace("game");
//addEventListener (TimerEvent.TIMER , loop);
brickLoader.addEventListener (TimerEvent.TIMER , loop);
brickLoader.start();
//create a new instance of the Brick
//var brickTween = new Tween( k,"x", None.easeNone , k.x,k.x - 1000, 5, true);
}
var brickTween:Tween;
function loop(e:TimerEvent):void {
//declare a varible for the for loop with Math.random
brickStack = Math.floor(Math.random() * 5) ;
//trace(brickStack);
if(brickStack == 0) {
brickStackBottom = 4;
}
if(brickStack == 1) {
brickStackBottom = 3;
}
if(brickStack == 2) {
brickStackBottom = 2;
}
if(brickStack == 3) {
brickStackBottom = 1;
}
if(brickStack == 4) {
brickStackBottom = 0;
}
arrayLength = arrayOfBricks[brickStack].length;
arrayLengthBottom = arrayOfBricks[brickStackBottom].length;
trace(arrayLengthBottom);
//arrayOfBricks[brickStack];
//brick load ratio 1:5 2:4 3:3 4:2 5:1
//+4*5/5 +2*4/4 +0*3/3 -2*2/2 -4*1/1
//formulate a mathmatically loader paradiam
for(i = 0;i < arrayLength; i++){
bottomLoop();
var obj:Brick = new Brick();
obj.x = stage.stageWidth + obj.width;
obj.y = (i*40);
addChild(obj);
arrayOfObjects.push(obj);
}
tween();
}
function tween() {
for(i=0;i <arrayOfObjects.length;i++){
brickTween = new Tween( arrayOfObjects[i],"x", None.easeNone , arrayOfObjects[i].x,arrayOfObjects[i].x - (stage.stageWidth + 240), 6, true);
}
}
function bottomLoop() {
for(var o:int = 0;o < arrayLengthBottom; o++){
var objBottom:Brick = new Brick();
objBottom.x = stage.stageWidth + objBottom.width;
objBottom.y = (stage.stageHeight - 40) - (o*40);
arrayOfObjects.push(objBottom)
addChild(objBottom);
}
}
}
}