kildre
07-19-2002, 04:30 PM
Below is some code I did to make dynamic images change across, what I need to know is it possible to make a loop to create a variable to hold an item within an array?
Like if I have 5 items called "product" and I wanted to make vars of products 1 - 5 like product1, product2, product3 etc. would this then work to call back out?
for (x=0; x<=5; x++;){
Array[outside]="product"+array[x];
}
so if I wanted to assign product3 = 6 persay it would be
Array[2]=6;
or can I call it directly product3= 6?
See below what I am trying to make that gunk below into one object I can load dynamically.
Code snippet........................................... ....
var hope = flashVars.portObject[0].hope;
var plan = flashVars.portObject[0].plan;
pill1Top._alpha=60;
pill1Top._y = (boundBox._y + ((boundBox._height/2)+(pill1Top._height/2))) - (((hope/topVal)*boundBox._height));
pill1Bottom._alpha=60;
pill1Bottom._y=(boundBox._y + ((boundBox._height/2)-(pill1Bottom._height/2))) - ((plan/bottomVal));
pill1Middle._alpha=60;
//trace(pill1Bottom._y - pill1Bottom._height);
pill1Middle._height = ((pill1Bottom._y - pill1Bottom._height/2)-(pill1Top._y+pill1Top._height/2))+1;
//trace(pill1Middle._height);
pill1Middle._y=(pill1Top._y)+(pill1Top._height/2)+(pill1Middle._height/2)-.3;
var expect = flashVars.portObject[0].expect;
pill1Expect._y = (boundBox._y + boundBox._height/2 + (pill1Expect._height/2)) - (((expect/topVal)* boundBox._height) - pill1Top._height);
//boundBox._y + ((boundBox._height/2)+(pill1Expect._height/2))) - (((expect/topVal)*boundBox._height));
/* Pill two -----------------------------------------------*/
var hope = flashVars.portObject[5].hope;
var plan = flashVars.portObject[5].plan;
pill2Top._alpha=60;
pill2Top._y = (boundBox._y + ((boundBox._height/2)+(pill2Top._height/2))) - (((hope/topVal)*boundBox._height));
pill2Bottom._alpha=60;
pill2Bottom._y=(boundBox._y + ((boundBox._height/2)-(pill2Bottom._height/2))) - ((plan/bottomVal));
pill2Middle._alpha=60;
//trace(pill2Bottom._y - pill2Bottom._height);
pill2Middle._height = ((pill2Bottom._y - pill2Bottom._height/2)-(pill2Top._y+pill2Top._height/2))+1;
//trace(pill2Middle._height);
pill2Middle._y=(pill2Top._y)+(pill2Top._height/2)+(pill2Middle._height/2)-.3;
var expect = flashVars.portObject[5].expect;
pill2Expect._y = (boundBox._y + boundBox._height/2 + (pill2Expect._height/2)) - (((expect/topVal)* boundBox._height) - pill2Top._height);
/* Pill three --------------------------------------------------*/
var hope = flashVars.portObject[10].hope;
var plan = flashVars.portObject[10].plan;
pill3Top._alpha=60;
pill3Top._y = (boundBox._y + ((boundBox._height/2)+(pill3Top._height/2))) - (((hope/topVal)*boundBox._height));
pill3Bottom._alpha=60;
pill3Bottom._y=(boundBox._y + ((boundBox._height/2)-(pill3Bottom._height/2))) - ((plan/bottomVal));
pill3Middle._alpha=60;
//trace(pill3Bottom._y - pill3Bottom._height);
pill3Middle._height = ((pill3Bottom._y - pill3Bottom._height/2)-(pill3Top._y+pill3Top._height/2))+1;
//trace(pill3Middle._height);
pill3Middle._y=(pill3Top._y)+(pill3Top._height/2)+(pill3Middle._height/2)-.3;
var expect = flashVars.portObject[10].expect;
pill3Expect._y = (boundBox._y + boundBox._height/2 + (pill3Expect._height/2)) - (((expect/topVal)* boundBox._height) - pill3Top._height);
/* Pill four ------------------------------------------------------*/
var hope = flashVars.portObject[19].hope;
var plan = flashVars.portObject[19].plan;
pill4Top._alpha=60;
pill4Top._y = (boundBox._y + ((boundBox._height/2)+(pill4Top._height/2))) - (((hope/topVal)*boundBox._height));
pill4Bottom._alpha=60;
pill4Bottom._y=(boundBox._y + ((boundBox._height/2)-(pill4Bottom._height/2))) - ((plan/bottomVal));
pill4Middle._alpha=60;
//trace(pill4Bottom._y - pill4Bottom._height);
pill4Middle._height = ((pill4Bottom._y - pill4Bottom._height/2)-(pill4Top._y+pill4Top._height/2))+1;
//trace(pill4Middle._height);
pill4Middle._y=(pill4Top._y)+(pill4Top._height/2)+(pill4Middle._height/2)-.3;
var expect = flashVars.portObject[19].expect;
pill4Expect._y = (boundBox._y + boundBox._height/2 + (pill4Expect._height/2)) - (((expect/topVal)* boundBox._height) - pill4Top._height);
/* Pill five ---------------------------------------------------------*/
var hope = flashVars.portObject[20].hope;
var plan = flashVars.portObject[20].plan;
pill5Top._alpha=60;
pill5Top._y = (boundBox._y + ((boundBox._height/2)+(pill5Top._height/2))) - (((hope/topVal)*boundBox._height));
pill5Bottom._alpha=60;
pill5Bottom._y=(boundBox._y + ((boundBox._height/2)-(pill5Bottom._height/2))) - ((plan/bottomVal));
pill5Middle._alpha=60;
//trace(pill5Bottom._y - pill5Bottom._height);
pill5Middle._height = ((pill5Bottom._y - pill5Bottom._height/2)-(pill5Top._y+pill5Top._height/2))+1;
//trace(pill5Middle._height);
pill5Middle._y=(pill5Top._y)+(pill5Top._height/2)+(pill5Middle._height/2)-.3;
var expect = flashVars.portObject[20].expect;
pill5Expect._y = (boundBox._y + boundBox._height/2 + (pill5Expect._height/2)) - (((expect/topVal)* boundBox._height) - pill5Top._height);
trace("Hope : "+hope);
trace("expect : "+expect);
trace("plan : "+plan);
trace("top : "+topVal);
trace("bottom : "+bottomVal);
Thanks,
Kildre:confused:
Like if I have 5 items called "product" and I wanted to make vars of products 1 - 5 like product1, product2, product3 etc. would this then work to call back out?
for (x=0; x<=5; x++;){
Array[outside]="product"+array[x];
}
so if I wanted to assign product3 = 6 persay it would be
Array[2]=6;
or can I call it directly product3= 6?
See below what I am trying to make that gunk below into one object I can load dynamically.
Code snippet........................................... ....
var hope = flashVars.portObject[0].hope;
var plan = flashVars.portObject[0].plan;
pill1Top._alpha=60;
pill1Top._y = (boundBox._y + ((boundBox._height/2)+(pill1Top._height/2))) - (((hope/topVal)*boundBox._height));
pill1Bottom._alpha=60;
pill1Bottom._y=(boundBox._y + ((boundBox._height/2)-(pill1Bottom._height/2))) - ((plan/bottomVal));
pill1Middle._alpha=60;
//trace(pill1Bottom._y - pill1Bottom._height);
pill1Middle._height = ((pill1Bottom._y - pill1Bottom._height/2)-(pill1Top._y+pill1Top._height/2))+1;
//trace(pill1Middle._height);
pill1Middle._y=(pill1Top._y)+(pill1Top._height/2)+(pill1Middle._height/2)-.3;
var expect = flashVars.portObject[0].expect;
pill1Expect._y = (boundBox._y + boundBox._height/2 + (pill1Expect._height/2)) - (((expect/topVal)* boundBox._height) - pill1Top._height);
//boundBox._y + ((boundBox._height/2)+(pill1Expect._height/2))) - (((expect/topVal)*boundBox._height));
/* Pill two -----------------------------------------------*/
var hope = flashVars.portObject[5].hope;
var plan = flashVars.portObject[5].plan;
pill2Top._alpha=60;
pill2Top._y = (boundBox._y + ((boundBox._height/2)+(pill2Top._height/2))) - (((hope/topVal)*boundBox._height));
pill2Bottom._alpha=60;
pill2Bottom._y=(boundBox._y + ((boundBox._height/2)-(pill2Bottom._height/2))) - ((plan/bottomVal));
pill2Middle._alpha=60;
//trace(pill2Bottom._y - pill2Bottom._height);
pill2Middle._height = ((pill2Bottom._y - pill2Bottom._height/2)-(pill2Top._y+pill2Top._height/2))+1;
//trace(pill2Middle._height);
pill2Middle._y=(pill2Top._y)+(pill2Top._height/2)+(pill2Middle._height/2)-.3;
var expect = flashVars.portObject[5].expect;
pill2Expect._y = (boundBox._y + boundBox._height/2 + (pill2Expect._height/2)) - (((expect/topVal)* boundBox._height) - pill2Top._height);
/* Pill three --------------------------------------------------*/
var hope = flashVars.portObject[10].hope;
var plan = flashVars.portObject[10].plan;
pill3Top._alpha=60;
pill3Top._y = (boundBox._y + ((boundBox._height/2)+(pill3Top._height/2))) - (((hope/topVal)*boundBox._height));
pill3Bottom._alpha=60;
pill3Bottom._y=(boundBox._y + ((boundBox._height/2)-(pill3Bottom._height/2))) - ((plan/bottomVal));
pill3Middle._alpha=60;
//trace(pill3Bottom._y - pill3Bottom._height);
pill3Middle._height = ((pill3Bottom._y - pill3Bottom._height/2)-(pill3Top._y+pill3Top._height/2))+1;
//trace(pill3Middle._height);
pill3Middle._y=(pill3Top._y)+(pill3Top._height/2)+(pill3Middle._height/2)-.3;
var expect = flashVars.portObject[10].expect;
pill3Expect._y = (boundBox._y + boundBox._height/2 + (pill3Expect._height/2)) - (((expect/topVal)* boundBox._height) - pill3Top._height);
/* Pill four ------------------------------------------------------*/
var hope = flashVars.portObject[19].hope;
var plan = flashVars.portObject[19].plan;
pill4Top._alpha=60;
pill4Top._y = (boundBox._y + ((boundBox._height/2)+(pill4Top._height/2))) - (((hope/topVal)*boundBox._height));
pill4Bottom._alpha=60;
pill4Bottom._y=(boundBox._y + ((boundBox._height/2)-(pill4Bottom._height/2))) - ((plan/bottomVal));
pill4Middle._alpha=60;
//trace(pill4Bottom._y - pill4Bottom._height);
pill4Middle._height = ((pill4Bottom._y - pill4Bottom._height/2)-(pill4Top._y+pill4Top._height/2))+1;
//trace(pill4Middle._height);
pill4Middle._y=(pill4Top._y)+(pill4Top._height/2)+(pill4Middle._height/2)-.3;
var expect = flashVars.portObject[19].expect;
pill4Expect._y = (boundBox._y + boundBox._height/2 + (pill4Expect._height/2)) - (((expect/topVal)* boundBox._height) - pill4Top._height);
/* Pill five ---------------------------------------------------------*/
var hope = flashVars.portObject[20].hope;
var plan = flashVars.portObject[20].plan;
pill5Top._alpha=60;
pill5Top._y = (boundBox._y + ((boundBox._height/2)+(pill5Top._height/2))) - (((hope/topVal)*boundBox._height));
pill5Bottom._alpha=60;
pill5Bottom._y=(boundBox._y + ((boundBox._height/2)-(pill5Bottom._height/2))) - ((plan/bottomVal));
pill5Middle._alpha=60;
//trace(pill5Bottom._y - pill5Bottom._height);
pill5Middle._height = ((pill5Bottom._y - pill5Bottom._height/2)-(pill5Top._y+pill5Top._height/2))+1;
//trace(pill5Middle._height);
pill5Middle._y=(pill5Top._y)+(pill5Top._height/2)+(pill5Middle._height/2)-.3;
var expect = flashVars.portObject[20].expect;
pill5Expect._y = (boundBox._y + boundBox._height/2 + (pill5Expect._height/2)) - (((expect/topVal)* boundBox._height) - pill5Top._height);
trace("Hope : "+hope);
trace("expect : "+expect);
trace("plan : "+plan);
trace("top : "+topVal);
trace("bottom : "+bottomVal);
Thanks,
Kildre:confused: