Skip to main content
April 25, 2006
Question

tracing the next variable?

  • April 25, 2006
  • 3 replies
  • 367 views
subMenuItem._visible = 0;
function theMenu(n) {
var newY = 0;
var newX = 0;
for (var i = 0; i<n; i++) {
duplicateMovieClip("subMenuItem", "selectc"+i, i);
this["selectc"+i]._x = newX;
this["selectc"+i].selectcText = _parent.subMenu ;
this["selectc"+i].ivar = i;
myMenuList.push(String("_level0.menu01.selectc"));
newX = newX+17;
}
}


this is a script i'm using to duplicate a button for each item in a menu, each button is allocated a 'selectcText' variable (which is taken from an external txt file).
on each frame of my _root. timeline i need to trace the next selectcText,
i.e. on frame 9, i need to trace the selectcText allocated to button selectc1
on frame 10, i need to trace the selectcText allocated to button selectc2
on frame 11, i need to trace the selectcText allocated to button selectc3
etc...

hope that makes sense. can anyone figure out how i would perform the trace?
This topic has been closed for replies.

3 replies

June 16, 2006
please help.
Participating Frequently
April 25, 2006
try this code:


onRelease = function () {
var traceVar = _root.myArray[_root.n];
trace(traceVar);
_global.lastTrace = selectcText;
_root.n++;
_root.nextFrame();
};

Before trying this code u r getting the value of n
Specify _root.n = 0 in first frame of movie in root level
April 25, 2006
thanks, but it's just not working...
is this script correct for tracing the 'selectcText' variable of each sub menu item?

_root.myArray.push(selectcText);

??

also i'm not sure the button code is tracing it properly...
i'm not a great scripter so i can't see where the problem lies.
thanks for trying.
April 27, 2006
^^^BUMP^^^

so i'm creating a set of menu buttons like this:

but it isnt working, can it be corrected?, or is there a new way???
Participating Frequently
April 25, 2006
While u r duplicating the button, that time u can put text into an array and trace the values of array from timeline, e.g:

subMenuItem._visible = 0;
_root.myArray = new Array();
function theMenu(n) {
var newY = 0;
var newX = 0;
for (var i = 0; i<n; i++) {
duplicateMovieClip("subMenuItem", "selectc"+i, i);
this["selectc"+i]._x = newX;
this["selectc"+i].selectcText = _parent.subMenu;
this["selectc"+i].ivar = i;
_root.myArray.push(text to be traced)
myMenuList.push(String("_level0.menu01.selectc"));
newX = newX+17;
}
}


now on main time line on frame no. 10 n = 0; increase the value of n every time when u go to next frame and tracethe value of from array on each frame by using
_root.myArray;

H
April 25, 2006
thanks... but i tried this...

subMenuItem._visible = 0;
_root.myArray = new Array();
function theMenu(n) {
var newY = 0;
var newX = 0;
for (var i = 0; i<n; i++) {
duplicateMovieClip("subMenuItem", "selectc"+i, i);
this["selectc"+i]._x = newX;
this["selectc"+i].selectcText = _parent.subMenu;
this["selectc"+i].ivar = i;
_root.myArray.push(selectcText);
myMenuList.push(String("_level0.menu01.selectc"));
newX = newX+17;
}
}


and now all my text is undefined!
any idea why?
April 25, 2006
sorry, my mistake, that was something else.
i'll try it again. cheers