Groups | Blog | Home
all groups > flash actionscript > july 2007 >

flash actionscript : scrolling pics imported via xml


NickTheNameless
7/9/2007 10:12:56 PM
i have pics imported via an xml file and i would like to display the pics by
allowing the user to use a left and right button to scrxoll through them. i
would like the center pic in the "spotlight" to be displayed with no distortion
and 4 pictures on each side of that are skewed a bit. i would also like the
scrolling to loop, so that when you reach the last picture, the first one is
the next one in line. the effect i want is much like the movies section of
iTunes (without the slide bar).

i'm very close to getting the effect to work, but it's off a bit. what would
be the best way to accomplish this scrolling effect? when i import this
pictures in flash, i get a count of how many there are; call numOfItems. i've
been trying to use this number to determine which picture is being displayed as
the center spotlight, which pictures should be skewed to either side of the
spotlight picture, and when to start over with the first picture (or the last
picture, depending on which direction you go... left or right).

does this make sense? if not, but you think you could help, please ask me
some questions or ask me to post some more code. right now i'm posting the
initial frame that places the pictures after they have been loaded from the xml
file. when this frame plays it plays through 5 more frames that make the
animation happen. in that last 5th frame, depending on the direction clicked,
it adds or subtracts 1 to the spotlight count and then send it back to this
frame.



if ((dir == "right") && (spotlight == -1)) {
spotlight = numOfItems;
}
if ((dir == "left") && (spotlight == numOfItems)) {
spotlight = 0;
}
if (dir == "firstRun") {
eval("screened"+[spotlight-5]).transform.matrix = F6toP0;
eval("screened"+[spotlight-4]).transform.matrix = F1toP0;
eval("screened"+[spotlight-3]).transform.matrix = F1toP1;
eval("screened"+[spotlight-2]).transform.matrix = F1toP2;
eval("screened"+[spotlight-1]).transform.matrix = F1toP3;
eval("screened"+spotlight).transform.matrix = F1toP4;
eval("screened"+[spotlight+1]).transform.matrix = F1toP5;
eval("screened"+[spotlight+2]).transform.matrix = F1toP6;
eval("screened"+[spotlight+3]).transform.matrix = F1toP7;
eval("screened"+[spotlight+4]).transform.matrix = F1toP8;
eval("screened"+[spotlight+5]).transform.matrix = F1toP9;
home.stop();
}
if (spotlight == [numOfItems-4]) {
eval("screened"+[numOfItems-8]).transform.matrix = F1toP0;
eval("screened"+[numOfItems-7]).transform.matrix = F1toP1;
eval("screened"+[numOfItems-6]).transform.matrix = F1toP2;
eval("screened"+[numOfItems-5]).transform.matrix = F1toP3;
eval("screened"+spotlight).transform.matrix = F1toP4;
eval("screened"+[numOfItems-3]).transform.matrix = F1toP5;
eval("screened"+[numOfItems-2]).transform.matrix = F1toP6;
eval("screened"+[numOfItems-1]).transform.matrix = F1toP7;
home.screened0.transform.matrix = F1toP8;
home.screened1.transform.matrix = F1toP9;
} else if (spotlight == [numOfItems-3]) {
eval("screened"+[numOfItems-7]).transform.matrix = F1toP0;
eval("screened"+[numOfItems-6]).transform.matrix = F1toP1;
eval("screened"+[numOfItems-5]).transform.matrix = F1toP2;
eval("screened"+[numOfItems-4]).transform.matrix = F1toP3;
eval("screened"+spotlight).transform.matrix = F1toP4;
eval("screened"+[numOfItems-2]).transform.matrix = F1toP5;
eval("screened"+[numOfItems-1]).transform.matrix = F1toP6;
home.screened0.transform.matrix = F1toP7;
home.screened1.transform.matrix = F1toP8;
home.screened2.transform.matrix = F1toP9;
} else if (spotlight == [numOfItems-2]) {
eval("screened"+[numOfItems-6]).transform.matrix = F1toP0;
eval("screened"+[numOfItems-5]).transform.matrix = F1toP1;
eval("screened"+[numOfItems-4]).transform.matrix = F1toP2;
eval("screened"+[numOfItems-3]).transform.matrix = F1toP3;
eval("screened"+spotlight).transform.matrix = F1toP4;
eval("screened"+[numOfItems-1]).transform.matrix = F1toP5;
home.screened0.transform.matrix = F1toP6;
home.screened1.transform.matrix = F1toP7;
home.screened2.transform.matrix = F1toP8;
home.screened3.transform.matrix = F1toP9;
} else if (spotlight == [numOfItems-1]) {
eval("screened"+[numOfItems-5]).transform.matrix = F1toP0;
eval("screened"+[numOfItems-4]).transform.matrix = F1toP1;
eval("screened"+[numOfItems-3]).transform.matrix = F1toP2;
eval("screened"+[numOfItems-2]).transform.matrix = F1toP3;
eval("screened"+spotlight).transform.matrix = F1toP4;
home.screened0.transform.matrix = F1toP5;
home.screened1.transform.matrix = F1toP6;
home.screened2.transform.matrix = F1toP7;
home.screened3.transform.matrix = F1toP8;
home.screened4.transform.matrix = F1toP9;
} else if (spotlight == 0) {
eval("screened"+[numOfItems-3]).transform.matrix = F1toP0;
eval("screened"+[numOfItems-2]).transform.matrix = F1toP1;
eval("screened"+[numOfItems-1]).transform.matrix = F1toP2;
home.screened0.transform.matrix = F1toP3;
home.screened1.transform.matrix = F1toP4;
home.screened2.transform.matrix = F1toP5;
home.screened3.transform.matrix = F1toP6;
home.screened4.transform.matrix = F1toP7;
home.screened5.transform.matrix = F1toP8;
home.screened6.transform.matrix = F1toP9;
} else if (spotlight == 1) {
eval("screened"+[numOfItems-2]).transform.matrix = F1toP0;
eval("screened"+[numOfItems-1]).transform.matrix = F1toP1;
home.screened0.transform.matrix = F1toP2;
home.screened1.transform.matrix = F1toP3;
home.screened2.transform.matrix = F1toP4;
home.screened3.transform.matrix = F1toP5;
home.screened4.transform.matrix = F1toP6;
home.screened5.transform.matrix = F1toP7;
home.screened6.transform.matrix = F1toP8;
home.screened7.transform.matrix = F1toP9;
} else if (spotlight == 2) {
eval("screened"+[numOfItems-1]).transform.matrix = F1toP0;
home.screened0.transform.matrix = F1toP1;
home.screened1.transform.matrix = F1toP2;
home.screened2.transform.matrix = F1toP3;
home.screened3.transform.matrix = F1toP4;
home.screened4.transform.matrix = F1toP5;
home.screened5.transform.matrix = F1toP6;
home.screened6.transform.matrix = F1toP7;
home.screened7.transform.matrix = F1toP8;
home.screened8.transform.matrix = F1toP9;
} else if (spotlight == 3) {
home.screened0.transform.matrix = F1toP0;
home.screened1.transform.matrix = F1toP1;
home.screened2.transform.matrix = F1toP2;
home.screened3.transform.matrix = F1toP3;
home.screened4.transform.matrix = F1toP4;
home.screened5.transform.matrix = F1toP5;
home.screened6.transform.matrix = F1toP6;
home.screened7.transform.matrix = F1toP7;
home.screened8.transform.matrix = F1toP8;
home.screened9.transform.matrix = F1toP9;
} else {
eval("screened"+[spotlight-4]).transform.matrix = F1toP0;
eval("screened"+[spotlight-3]).transform.matrix = F1toP1;
NickTheNameless
7/9/2007 11:37:01 PM
i made some progress, so thought i'd post it here even though i'm pretty sure
this won't get any response as it's very hard to explain in a forum.

anyweezer, as with most of my problems, it was caused by syntax (funny how it
checked out just fine though). lines like...

if (spotlight == [numOfItems-4]) {

....are incorrect. i had to take away the [ and ], although they are
necessary in the eval statements where i add string on to a computation. crazy
syntax. this solved some of my major problems. if it solved all of them i'll
mark this resolved.

if anyone does run across this, i'd like some critique on how i accomplished
this effect. the movie only has 8 frames and there are no tweens, but i do
make use of the timeline actually playing. i'd love to see this done in one
frame. possible?
AddThis Social Bookmark Button