Groups | Blog | Home
all groups > flash actionscript > september 2005 >

flash actionscript : problem using 'this' in a function


kglad
9/17/2005 12:00:00 AM
try:

m_length =eval("menu"+i);
shottogan
9/17/2005 9:09:59 AM
hey, i'm having trouble with this code. i really dont know why it wont work.
the code works fine on it's own, just running when the timeline comes across
it, but if i define it as a function and then try to call it, even from within
that same frame, it causes a 'A Script Is Causing Flash To Run Slowly, Would
You Like To Abort It?' kinda message to pop up. i even tried replacing all the
'this's with _root.movieClipName so that it would be hard coded.. but it still
does the same thing. what part of my code does not allow it to run in a
function?

thanks a lot. also, if you see any inefficient/outdated methods, please
correct me. thanks.

-jarod

.

var build:Function = function () {
if (_root.clearance == 0) {
var menu1:Array = new Array("about", "leadership", "philanthropy",
"scholarships", "events / news", "calendar");
var link1:Array = new Array("", "", "", "", "", "");
var menu2:Array = new Array("about", "annual convention", "ed. foundation",
"capitol campaign", "newsletter archive");
var link2:Array = new Array("", "", "", "", "");
var menu3:Array = new Array("actives profiles");
var link3:Array = new Array("");
var menu4:Array = new Array("view albums");
var link4:Array = new Array("");
} else if (_root.clearance == 8) {
var menu1:Array = new Array("about", "leadership", "philanthropy",
"scholarships", "events / news", "events / news", "events / news", "events /
news", "calendar");
var link1:Array = new Array("", "", "", "", "", "", "", "", "");
var menu2:Array = new Array("about", "annual convention", "ed. foundation",
"capitol campaign", "newsletter archive");
var link2:Array = new Array("", "", "", "", "");
var menu3:Array = new Array("pledges profiles", "actives profiles", "alumni
profiles", "your account", "create account", "message inbox", "compose
message");
var link3:Array = new Array("", "", "", "", "", "", "");
var menu4:Array = new Array("view albums", "add photos", "create albums");
var link4:Array = new Array("", "", "");
}
for (i=1; i<=4; i++) {
m_length = this["menu"+i].length;
this["m"+i].tab.g._height = m_length*20+20;
this["m"+i].tab.g._y = -20-m_length*20;
this["m"+i].tab.l1._y = -10-m_length*20;
this["m"+i].tab.l1.t.text = this["menu"+i][0];
this["m"+i].tab.l1.link = this["link"+i][0];
for (l=2; l<=m_length; l++) {
duplicateMovieClip(this["m"+i].tab.l1, "l"+l, 100+l);
this["m"+i].tab["l"+l]._y = -30-(m_length-l)*20;
this["m"+i].tab["l"+l].t.text = this["menu"+i][l-1];
this["m"+i].tab["l"+l].link = this["link"+i][l-1];
}
this["g"+i].tab.g1._height = m_length*20+20;
this["g"+i].tab.g1._y = -20-m_length*20;
this["g"+i].tab.g2._y = 40;
this["m"+i].mNum = i;
this["m"+i].m_size = m_length*20+20;
}
};
build();
shottogan
9/18/2005 12:00:00 AM
kglad
9/18/2005 12:00:00 AM
i prefer to use bracket notation, but there are times when it doesn't work.
this is one of those situations where your use of var makes your arrays local
to your function and bracket notation won't resolve that reference to a
timeline.
AddThis Social Bookmark Button