MX code needs converted to v5

My client changed his mind about v6 and wants the swf compatible with v5. Maybe I should have been more prepared for this, but I’m not. I’ve barely chugged along with a tutorial and figuring this out, and I’m completely lost with converting it to v5 code. Can anyone help get me started?

Here’s my code so far:

onClipEvent (load) {
	_global.ratio = 0;
	_global.popup = 0;
	imagehalf = -1668;
	xcenter = 2000;
	xspeed = 1/5;
	speedratio = 0;
	accel = 0;
	accel_amount = .1;
	setProperty("_root.button_left_ON", _visible, "0");
	setProperty("_root.button_right_ON", _visible, "0");
	setProperty("_root.popup_01", _visible, "0");
}
onClipEvent (enterFrame) {
	if (_global.ratio == 0) {  // slider is NOT being used
		accel = accel-accel_amount;  // create a deceleration value
		if (accel<0) {  // keep the deceleration value at 0 so the movement doesn't reverse
			accel = 0;
		}
	} else {  // slider IS being used
		speedratio = _global.ratio;		// use the slider position to calculate the speed of the scroll
		accel = 1;		// set acceleration to full
	}
	var xdistance = speedratio*accel;	// determine how far to move the movie clip based on how far the slider is moved
	_x -= (xdistance*xspeed);	// actually reposition the movie clip
	if (_x>0) {		// test if the movie clip needs to loop from the left
		_x = imagehalf;
	}
	if (_x<imagehalf) {		// test if the movie clip needs to loop from the right
		_x = 0;
	}
	if (_global.ratio<0) {   // light up the buttons appropriately
		setProperty("_root.button_left_ON", _visible, "1");
		setProperty("_root.button_stop_ON", _visible, "0");
		setProperty("_root.button_right_ON", _visible, "0");
	}
	if (_global.ratio == 0) {
		setProperty("_root.button_left_ON", _visible, "0");
		setProperty("_root.button_stop_ON", _visible, "1");
		setProperty("_root.button_right_ON", _visible, "0");
	}
	if (_global.ratio>0) {
		setProperty("_root.button_left_ON", _visible, "0");
		setProperty("_root.button_stop_ON", _visible, "0");
		setProperty("_root.button_right_ON", _visible, "1");
	}
}

It’s for a scrolling image controlled with a slider. You can see my MX swf here.

I hope someone can help with this because I am so lost.

Thanks,
Dan

I think the code works okay on Flash 5! Try exporting you SWF to Flash 5 and see if it works ok.

that’s good stuff right there! works in flash 5 or not. =)

good luck with it. =)

*Originally posted by comicGeek *
**I think the code works okay on Flash 5! Try exporting you SWF to Flash 5 and see if it works ok. **
Flash 5 had no ‘_global’ as far as i can remember…

Yeah, _global is Flash 6 only.

setProperty is Flash 4 sintax… so thats way behind date anyway.

To fix the _global thing just put the variables in the _root timeline and target them with _root.variable instead of _global.variable :slight_smile:

Thats all you should need.

But having never used Flash 5 I can’t really say for sure :stuck_out_tongue:

Thanks everyone for the replies!

I did get it all working. You were right…this code was all v5 compliant, except for the _global parts. I ended up using local variables to this mc, and referencing them from other mc’s with _root.mcname.varname and it worked perfect!

As far as the setProperty being old…what’s the current v6 syntax? Would _root.instancename._visible = 0; work?

Thanks again…

Dan

Yes… _root.instancename._visible = 0 will work, and that is the Flash 5 and Flash 6 syntax :slight_smile: