Using Load in dynamically created movieclips

Hi,

I’m new to Flash, although I do have some experience of scripting an actionscript does appear to be a lot like java, so i’m getting there slowly. :look:

Basically my problem is I’m trying to create a piece of flash that substitutes a movieclip based on a parameter passed to it from HTML (this bit I can get working), the problem is I want to load the movieclip in dynamically and attach a load event to the dynamically created clip so I can make use of an orbiting script I have used before.

Here is my code:

_global.severity = severity;
_global.errortype = errortype;

_root.onLoad = function() {
	trace ("_root onLoad called");
	//Create our Clip
	_root.createEmptyMovieClip("errordisplay", 1);
	//Attach event to clip.
	errordisplay.onLoad =  LoadOrbit;
	//loadMovie(LoadSeverity(), "errordisplay");
	//As a test I just want to make this line work before loading the Clip
	//corresponding to the parameter passed from the PHP page.
	errordisplay.attachMovie("warning_movie", "warning_movie1", 1);
	errordisplay._x = 80;
	errordisplay._y = 80;
	errordisplay.onEnterFrame = Orbit;
};

//For the object function to work both the Clips Load and EnterFrame
//events need to fire.
LoadOrbit = function() {
	trace ("errordisplay onLoad called");
	depthset = true;
	playclip = false;
	offsetx = 10;
	offsety = 45;
	y = 0;
	speed = 5;
	radius = 130;
	xcenter = _level0.LM._x + offsetx;
	ycenter = _level0.LM._y - offsety;
	zcenter = 100;
	angle = 0;
	fl = 150;
};

Orbit = function() {
	//trace ("Orbit called");
	z = Math.sin(angle * Math.PI / 180) * radius + zcenter;
	scale = fl / ((fl + z));
	x = Math.cos(angle * Math.PI / 180) * radius;
	setProperty ("",_x,x * scale + xcenter);
	setProperty ("",_y,y * scale + ycenter);
	setProperty ("",_xscale,scale * 100);
	angle = angle + speed;
	setProperty ("",_alpha,scale * 100);
	if (angle > 359) {
		angle = angle - 360;
		}
	if (scale < 0.7) {
		if (depthset == false) {
			_level0.LM.swapDepths(this);
			depthset = true;
			}
	} else {
		if (depthset == true) {
			_level0.LM.swapDepths(this);
			depthset = false;
			}
		depthset = false;
	}
};

//This decides what clip to run based on a gloabl variable being set.
function LoadSeverity() {
	switch (severity) {
		case 16:
			swfname = "critical.swf";
			break;
			
		case 48:
			swfname = "warning.swf";
			break;
			
		case 64:
			swfname = "information.swf";
			break;
			
		default:
			swfname = "warning.swf";
	}
	return swfname;
}

Basically I’ve seen a lot about this problem but no real solution, the Load event never fires so you never see the trace message in the output window when testing, however the EnterFrame event does fire, but because the variables are not set correctly in the Load event the clip will not orbit lke it should.

Please help! :ear: