The new forums will be named Coin Return (based on the most recent vote)! You can check on the status and timeline of the transition to the new forums here.
The Guiding Principles and New Rules document is now in effect.

Actionscripting question

JasconiusJasconius sword criminalmad onlineRegistered User regular
edited July 2007 in Help / Advice Forum
I'm working on a Flash document that will let my coworkers create Flash navigation without all the dirty mess. It will dynamically create it's various levels of navigation, etc, by evaluating the length of the arrays that contain the link data.

Anyway, I am having some problems with the eval function, which allows you to use variables when calling objects.

The code!
var toplevel_orient:Boolean = true;
//True = Horizontal, False = Vertical
//Attaching nav movie clips and setting to invisible. This is for evaluating the properties of the movieclip
//to be used later when dynamically laying the nav out.
this.attachMovie("mc_toplevel", "mc_toplevel_eval", this.getNextHighestDepth(), {_visible:false});
var toplevel:Array = Array();
toplevel[0] = "Sup";
toplevel[1] = "Hooooola";
toplevel[2] = "Blarg";
for (i=0; i<=toplevel.length; i++) {
	var xvalue:Number = mc_toplevel_eval._width*i;
	var yvalue:Number = mc_toplevel_eval._height*i;
	//trace(xvalue);
	this.attachMovie("mc_toplevel", "mc_toplevel_"+i, this.getNextHighestDepth());
	if (toplevel_orient) {
		eval("mc_toplevel_"+i)._x = xvalue;
	} else {
		eval("mc_toplevel_"+i)._y = yvalue;
	}
	eval("mc_toplevel_"+i).createTextField("toplevel_text_"+i, this.getNextHighestDepth(), 0, 0, mc_toplevel_eval._width, mc_toplevel_eval._height);
	mc_toplevel_0.toplevel_text_0.text = "hello";
	eval("mc_toplevel_"+i).eval("toplevel_text_"+i).text = "test";
	trace(eval("mc_toplevel_"+i).eval("toplevel_text_"+i).text);
}

As you can see near the bottom, when I try to use multiple eval functions to reference different layers of movie clips on the same line, the code breaks, somehow, and doesn't ever actually target what it's supposed to (as far as I can tell it targets nothing). I know that the TextFields are being created properly, because as a debug, I have hard coded "hello" into the first one.

Is there a better way to do this? Eval seems primative, but is exactly the type of function I need to pull off what I am attempting to do.

Thanks.

this is a discord of mostly PA people interested in fighting games: https://discord.gg/DZWa97d5rz

we also talk about other random shit and clown upon each other
Jasconius on
Sign In or Register to comment.