hi everyone,

I'm using Flash8. Hope you can help with my problem. Thank you!

I'm trying to create an setInterval on a Stock object. When i create a new instance of it in the Main timeline, it works.

However, I need to manage a few instances of these "Stock" objects, so I created a Manager class, and I create new instances of Stock object in the constructor of the Manager class. I create a new instance of the Manager class in the main timeline. The setInterval now does not work.

I suspect it could be a special object reference, but i've tried passing in "this", "_root[ID]" (ID is the unique name of my Stock object).. just doesn't work.

my code:

Frame 1 in Main
Code:
// creates 1st rectangle
var me0:Object	= new Stock(10, 10);
// animates 1st rectangle
me0.playTV();

// 2nd rectangle is created and animated in the constructor of Manager class
var m = new Manager();
Manager.as
Code:
class Manager{
	
	public function Manager() {
		trace("Manager Created");

		//2nd rectangle created here
		var me1:Object	= new Stock(10, 70);
		//2nd rectangle animate here
		me1.playTV();
	}
}
Stock.as
Code:
import mx.transitions.Tween;
import mx.transitions.easing.*;

class Stock{
	
	var ID:String;
	var randomFactor:Number;
	var xCoord:Number;
	var yCoord:Number;
	var iMCL:MovieClipLoader;
	var timer_myTest:Number;

	public function Stock(iX, iY) {

		xCoord = iX;
		yCoord = iY;

		// force Unique Names/ID for each movie clip, otherwise will overwrite one another.
		randomFactor = 1000000000000000;
		ID = Math.floor((Math.random()*randomFactor))%randomFactor + "";

		_root.createEmptyMovieClip(ID, _root.getNextHighestDepth());
		_root[ID]._x = xCoord;
		_root[ID]._y = yCoord;
		drawRectangle(_root[ID], 50, 50, 0xCCFF00, 60);
	}
	
	public function getID():String {	return ID;	};

	public function playTV() {
		trace("**       now playing        **");
		// somehow not working for me1
		timer_myTest = setInterval(this, "mytest", 100);
	}
	
	private function mytest() {
		trace("TEST this.ID = " + ID);
		var twn_myTest = new Tween(_root[ID], "_x", Regular.easeIn, xCoord, xCoord+100, 1, true);
		twn_myTest.onMotionFinished = function() {
			trace("TEST setInterval - DONE");
		}
		clearInterval(timer_myTest);
	}

	private function drawRectangle(target_mc:MovieClip, boxWidth:Number, boxHeight:Number, fillColor:Number, fillAlpha:Number):Void {
		with (target_mc) {
			beginFill(fillColor, fillAlpha);
			moveTo(0, 0);
			lineTo(boxWidth, 0);
			lineTo(boxWidth, boxHeight);
			lineTo(0, boxHeight);
			lineTo(0, 0);
			endFill();
		}
	}
}