PDA

View Full Version : loop / function & xml problems??


loaded
03-24-2003, 03:52 PM
Hi there,

I'm making an xml based menu.
However I face 3 problems:

in the for loop I make the buttons + actions.
However the following doesn't work right:

_root.menu[mcName+n].onRollOver = function() {
setDir(_root.follow["pointer"], _root.menu[mcName+n]._x+100*n);
//trace(disc[n]);
_root.disc.text = "rollover: "+disc[n];
_root.menu[mcName+n].gotoAndPlay("1");
}


1)the setDir function only works on the first mouseover???
2) the trace(disc[n]); works fine, however _root.disc.text = "rollover:".... only shows "rollover:"???
3) _root.menu[mcName+n].gotoAndPlay("1"); does not play the mc???

I'm a bit of a flash n00b, I mostly work with php.
So guess there's something very different in the basic coding rulez somewhere???

Hope someone can help?

Example: http://www.lodesite.nl/menu/

Jesse
03-25-2003, 04:57 AM
Flash doesn't really support frame labels beginning with numbers. As you have it that command is directing flash to gotoAndPlay a label called "1". If you are in fact using labels you will need to rename your abel. If you want to jump to frame 1, you don't need the quotes around it.
Try that and if your other problems continue, let me know.

loaded
03-25-2003, 05:26 AM
Well I can't seem to figure it out...????

Jesse
03-25-2003, 06:01 AM
The problem stems from the reference structure you use. All your onRollOver actions, etc. are making reference to the variable 'n' AFTER the user mouses over the button, which is always after your FOR loop is finished, so all the clip shave the same value for the variable n, meaning they all pass the same values to the function.
You need to explicitly set the value of n in each separate clip:
//mouse functions
// ADD THIS NEXT LINE, then change the references to 'n' to 'this.n' as shown below.
_root.menu[mcName+n].n = n
_root.menu[mcName+n].onRollOver = function() {
setDir(_root.follow["pointer"], _root.menu[mcName+this.n]._x+100);
//trace(disc[n]);

loaded
03-25-2003, 03:50 PM
Yup this makes it better again, hope to finish it soon!!