- Home
- Tutorials
- Flash
- Intermediate
- E-Cards and other Dynamic Systems

Breaking the problem down
If I come up to you in street and whisper something in your ear, then tell you to pass it on to some other guy down the road, you would have to store a fair bit of data in your head. You would have to store the string, or sentence I whispered to you - like "You're ugly" (no offense) - as well as where I was when I told you, and where you were and indeed, what I look like, and which guy you were supposed to pass it on to. This way, when you walk down the street and tell the big muscley guy I pointed out "You're ugly", and he punches you in the face, you know how to track me down to beat me up :o)
This example's a bit off the point but it's indicative of what we have to do when creating these sorts of systems. There is a fair bit of information we need to collect and pass around. So those of you who were thinking "How did he get Flash to save a SWF file?" have probably worked out by now that I didn't. All I did was store the important information about the structure you created, then pass that information on to you when you came back to view the card. Then, using that info I reconstructed the structure in a new Flash file. Pretty neat huh? I think so too.
It's about now that you should be opening up those source files you just downloaded and taking a look. Start with:
Writer.fla
The more astute of you will have noticed that the SWF embedded above isn't the same as the movie you were sent to when you got your notification email. In fact they are completely different files, and most of you can guess from the names that one writes the data and one reads it back in and reconstructs.
Start on the "Choose" scene, that's the one with the big red and green buttons. OK let's break this down. Frame 1 has the following code:
stop ();
items = new Array();
// dropItem removes an unwanted item from an array
function dropItem (item) {
for (j=0; j<=items.length; j++) {
if (items[j] == item) {
fst = items.slice(0, j);
snd = items.slice(j+1, items.length);
items = fst.concat(snd);
}
}
}
Like I say, I'm not going to lead you by the hand in this tutorial, so that means, no line by line breakdowns of code functionality. Suffice to say this dropItem() function removes an element from an array if it exists. Enough of that, take a look at the buttons (let's look at the red and green buttons under the word "blue"):
The green button has:
on (release) {
// add this object to the list of chosen object
_root.items.push("blue");
}
The red button has:
on (release) {
// remove this object from the list of chosen object
_root.dropItem("blue");
}
