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

Gathering the data part 2
on (release) {
// did they enter an email addy yet?
if (_root.email != "" && _root.email != null) {
// This code generates a (hopefully) unique session
// ID for this card. If you end up with overlaps you're either
// very succesful or extremely unlucky
myDate = new Date();
ranNum = Math.round(Math.random()*1000000);
ranChar = chr(Math.round(Math.random()*24)+97);
session = (mydate.getMonth()+""+myDate.getDate()+""
+mydate.getFullYear()+""+ranNum+ranChar);
// Now we construct the layoutString which goes to the reader.swf
layoutLength = items.length;
for (j=0; j<layoutLength; j++) {
name = items[j];
xpos = _root[name+j+"x"];
ypos = _root[name+j+"y"];
text = escape(_root[name+j].text);
// if the layoutString exists, append data
if (layoutString != null) {
layoutString = layoutString+","+name+","+xpos+","+ypos+","+text;
} else {
// layoutString doesn't exist, create it
layoutString = name+","+xpos+","+ypos+","+text;
}
}
// Since we're now going to send variables to a script,
// let's clean up those we don't need
delete items;
delete j;
delete name;
delete myDate;
delete ranNum;
delete ranChar;
delete layoutLength;
delete xpos;
delete ypos;
delete text;
// Passing the variables:
// Here I'm using LoadVariables because I want the user to
// stay IN the flash file when they send their card. If you
// want them to be re-directed to your PHP page use get URL
// getURL ("e-card.php", "", "GET");
loadVariablesNum ("e-card.php", 0, "GET");
} else {
// no email addy enterred, report error
_root.email = "You didn't enter an email! :)";
}
}
Note that some lines have been manually line wrapped for tutorial layout neatness.
Once again, welcome to those of you who weren't scared off by that long paragraph of code :o) By reading the comments and using your ActionScripting knowledge you will see that it's actually all quite straight forward stuff. All it does is convert all the important data in our movie into a nice long string, which we then pass to our PHP file. Speaking of which, let's turn the page...

