PDA

View Full Version : Why not for Player 7?


michey
07-26-2007, 12:36 AM
Hi

Does somebody know, why this script, FP 6, AS1 ,is not working exactly anymore, if published for Player7?

stop();
centerx = Stage.width/2;
centery = Stage.height/2;
var menuholder = this.createEmptyMovieClip("menuholder", -1);
menuholder._y = centery;
menucount = 5;
menuitems = [];
miwidth = 50;
miborder = 2;
startx = centerx-((menucount-1)*(miwidth+miborder))/2;
//trace(startx);
for (var i = 0; i<menucount; i++) {
var menuitem = this.menuholder.attachMovie("menuitem"+i, "menu"+i, i);
menuitem._x = startx+i*(miwidth+miborder);
menuitem.id = i;
menuitem.onRollOver = function() {
_root.selected = this;
};
menuitems.push(menuitem);
}
onEnterFrame = function () {
var width = 0;
for (var i = 0; i<menucount; i++) {
var xxm = menuitems[i]._xmouse;
var yym = menuitems[i]._ymouse;
var xm = Math.sqrt(xxm*xxm+yym*yym);
if (xm<50) {
menuitems[i]._xscale = menuitems[i]._yscale += ((200-xm)-menuitems[i]._yscale)/3;
} else {
menuitems[i]._xscale = menuitems[i]._yscale += (100-menuitems[i]._yscale)/3;
}
width += menuitems[i]._width;
}
width += (menucount-1)*miborder;
var xpos = Math.round(centerx-width/2);
for (var i = 0; i<menucount; i++) {
xpos += menuitems[i-1]._width/2+miborder+menuitems[i]._width/2;
menuitems[i]._x = xpos;
}
};

atomic
07-26-2007, 03:48 AM
Well, Player 7 definately doesn't like the [i-1] in this line...

xpos += menuitems[i-1]._width/2+miborder+menuitems[i]._width/2;

...'Cause xpos then traces NaN...

But how to fix it, is another story...

Some other guru here will have to look into it... Sorry!

michey
07-26-2007, 11:25 AM
Thanks a lot for your reply, atomic.
At least, now i have an exact question to formulate :rolleyes: :)

michey
07-26-2007, 01:39 PM
And here comes the solution (thanks to rendner[i] of Flashforum.de):

for (var i = 0; i<menucount; i++) {
if (i == 0) {
xpos += miborder+menuitems[i]._width/2;
menuitems[i]._x = xpos;
} else {
xpos += menuitems[i-1]._width/2+miborder+menuitems[i]._width/2;
menuitems[i]._x = xpos;
}
}
};

atomic
07-26-2007, 01:55 PM
Curious! I had tried something similar - if (i<0){i = 0} with the else - and that didn't work... Oh well, glad you got that answer... ;)