as3 tween bug
Greetings fellow explores, = )
I've been at this for quite some time now and have sadly met my match. for the sake brevity ill be quick. i have a document class that runs a timer and programatically loads a movieclip and a for loop that stacks them one on top of the other. then a dynamic tween move them from one end of the stage to the other. here is the issue.When i run the swf occasionally one or two tweens stop mid-way and i havent a clue as to why that is.
document file
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 b: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);
}
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);
var brickTween = new Tween( obj,"x", None.easeNone , obj.x,obj.x - (stage.stageWidth + obj.width*2), 4, true);
}
b = 0;
//k = someArray[]
//
}
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);
var brickTweenBottom = new Tween( objBottom,"x", None.easeNone , objBottom.x,objBottom.x - (stage.stageWidth + objBottom.width*2), 4, true);
}
}
}
}
Brick class
package {
//import necessary flash files/libraries
import flash.display. *;
import flash.display.MovieClip;
import flash.events.*;
//import flash.transition.Tween;
//import flash.transition.easing.*;
//import flash.utils.Timer;
//import fl.transitions.Tween;
/*import fl.transitions.easing.*;
import fl.transitions.Tween;
import fl.transitions.easing.None;
import fl.transitions.TweenEvent;
*/
public class Brick extends MovieClip {
//declare varibles
//private var brickStack:Number = Math.floor(Math.random()* 5) + 1;//somenumber) + 1
//private var brickLoader:Timer = new Timer(2000,0);
//private var arrayOfBricks:Array = new Array(1,2,3,4,5);
public var _root = MovieClip(root);
//declare constuctor function no perameters
//reminder inoder for constuctor function to work Brick sprite must be loaded onto stage
public function Brick(){
//tells class what proporties it has
//brickLoader.addEventListener (TimerEvent.TIMER , brickTimer);
//brickLoader.start();
//var brickTween = new Tween(_root.Brick,"x", None.easeNone ,_root.Brick.x, _root.Brick.x - 1000, 5, true);
}
//function brickTimer(e:TimerEvent): void {
//trace("brickTimer");
//}
}
}
would have place this code in the Brick class but i do not know how reference Brick within its class's source code
would greatly appreciate any assistance .Thank you so very much
