I'm making a website for my Mum's little chocolate shop and I'm stuck.
She wants to allow users to create their own bags of chocolate drops. There are 9 flavors they can pick from and have any combination from 1 flavor to all 9 in a bag. (hehe sounds like a maths exam)
I'm pretty new to this kind of actionscripting... but I'm trying to learn how to do things the *right* way rather than cheating and going the long way round as I have for all these years!
I have a picture of the bag with all the drops on one side and some toggle buttons on the other where you can tick the flavors you want. I've managed to get it so when you toggle the flavors on and off it sets the flavor to true/false and counts the total number of flavors.
Within the bag I have 10 frames with each of the flavor combinations. So:
frame 1 = no drops,
frame 2 = 1 flavor drop,
frame 3 = 2 flavors of drop,
frame 4 = 3 flavors of drop etc
The drops themselves are the same movieclip repeated 74 times. Each one is made up of 9 frames with each flavor represented.
Now in the first frame I have:
______________________________________________
onEnterFrame = function () {
if (numberFlav == 0) {
bag.gotoAndStop(1);
}
if (numberFlav == 1) {
bag.gotoAndStop(2);
}
if (numberFlav == 2) {
bag.gotoAndStop(3);
}
if (numberFlav == 3) {
bag.gotoAndStop(4);
}
if (numberFlav == 4) {
bag.gotoAndStop(5);
}
if (numberFlav == 5) {
bag.gotoAndStop(6);
}
if (numberFlav == 6) {
bag.gotoAndStop(7);
}
if (numberFlav == 7) {
bag.gotoAndStop(8);
}
if (numberFlav == 8) {
bag.gotoAndStop(9);
}
if (numberFlav == 9) {
bag.gotoAndStop(10);
}
};
var numberFlav:Number = 0;
var gotMilk:Boolean = false;
var gotWhite:Boolean = false;
var gotPlain:Boolean = false;
var gotStrawberry:Boolean = false;
var gotOrange:Boolean = false;
var gotLemon:Boolean = false;
var gotCapp:Boolean = false;
var gotHoney:Boolean = false;
var gotCara:Boolean = false;
______________________________________________
This is working fine, the toggle buttons +1 or -1 to numberFlav which in turn tells the bag to display the right frame for the number of flavors.
Say the user wants an all white bag of drops. They tick the white option and "numberFlav = 1" and "gotWhite = true." BUT...now its getting tricky...
I'm guessing I need to adjust the above code so:
if (numberFlav == 1) {
bag.gotoAndStop(2);
if (gotMilk = true) {
bag.drop1.gotoAndStop("milk");
bag.drop2.gotoAndStop("milk");
bag.drop3.gotoAndStop("milk");
bag.drop4.gotoAndStop("milk");
...etc...
} else if (gotWhite = true) {
bag.drop1.gotoAndStop("white");
bag.drop2.gotoAndStop("white");
bag.drop3.gotoAndStop("white");
bag.drop4.gotoAndStop("white");
...etc...
} else if (gotPlain = true) {
bag.drop1.gotoAndStop("plain");
bag.drop2.gotoAndStop("plain");
bag.drop3.gotoAndStop("plain");
bag.drop4.gotoAndStop("plain");
...etc...
}
}
Now I know there MUST be a way to get flash to register drop1 -> drop 74 without me having to type every single one in... but I can't for the life in me figure out how. I found something similar on here (http://board.flashkit.com/board/show...ple+movieclips) but I can't seem to get it working... and as its from 2002 I wondered if things had changed since then.
I tried Googling "Controlling multiple movieclips Flash" but it just has the basics about controlling different named movieclips at the same time, D'oh! I also have a couple of Actionscripting books I've been working though, but I can't seem to adapt the code right.
Any help would be much appreciated!
Thanks!