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

The Re-constructor: pulling it all together
Jesse Stratford
Jesse lives in Melbourne Australia and is the Cofounder and webmaster of http://ActionScript.org. Once a full-time Flash enthusiast, teacher, author, freelancer and speaker Jesse's now leads a double life -- management consultant by day, http://ActionScript.org director by night. He enjoys participating actively in community and the wider Flash scene when he has time.
View all articles by Jesse StratfordThis is the reconstructor. You will note that the library contains much the same items as the Writer.swf library, with the same linkage names. Can you guess what we're going to do? That's right! We're going to load up the data from the session file (whose name we know because we've just passed it using Reader.php), and rebuild the layout from the ground up using setProperty and some other nifty tricks.
The Preparation Scene does exactly what the name would suggest. It loads the variables from the session file and loops until the contentLoaded variable has a value (now you see the reason for using that extra variable!) and then proceeds to the next scene.
The Content Layout Scene is where all the actions happen and all the code's on Frame 1:
stop ();
// prepare loaded variables
// there are 4 elements in each of my array
// entries in the form:
// [mc name, _x, _y, text]
// thus I set my arrayLength = 4
arrayLength = 4;
// our loaded array has been loaded as a string
// which we must now convert into a valid array
// using the split object
locationArray = locationString.split(",");
// numOfElems tells how many objects are fully
// defined in the
// loaded array
numOfElems = locationArray.length/arrayLength;
// now we loop and place those elements defined
// in our array,
loopCount = 1;
for (j=0; j<=numOfElems; j++) {
mc = locationArray.shift();
xpos = Number(locationArray.shift());
ypos = Number(locationArray.shift());
text = unescape(locationArray.shift());
_root.attachmovie(mc, mc+j, j);
_root[mc+j]._x = xpos;
_root[mc+j]._y = ypos;
_root[mc+j].text = text;
}
More long code. All it does is takes the locationString variable from the session text file and convert it to an array. Then it loops through the elements and attaches movies and adapts their properties, like _x and _y appropriately... read though it and I'm sure you'll understand it. (For those of you who don't know, array.shift() takes the first element from an array and returns it, but unlike array[0] it actually removes it from the array.)
Finally note that you have to CHMOD the directory these files are uploaded into to 777 because we're creating new text files on the server. If you don't know how to do that, ask on the forums or do a search on the web, it's not hard.
That's all everyone, you now know the basic idea behind these sorts of applications. If you can think of a dazzling particle application be sure to let us know. If you have comments or suggestions please feel free to email me.
| Jesse Stratford is the Co-Master of ActionScript.org and a freelance Flash developer and teacher. He is based in Australia and enjoys all things Flash. NB: If you have comments or feedback please feel free to email me, but please do not email me Flash questions; the forums are provided for that purpose and you will get a faster answer by posting you question there. |
If you have found this tutorial helpful, I hope that you will take 30 seconds to visit The Hunger Site where, with just one click you can make a free donation of food to a starving person in a third-world country. We do not benefit financially from this action; it is purely an act of charity. |
| This tutorial is protected by International Intellectual Property Rights laws and may not be reproduced or redistributed in full or part, without the prior written consent of the author. Unauthorized reproduction of this tutorial or its contents may result in prosecution. I've worked hard on this tutorial, please don't steal it. |
Spread The Word
Related Articles
1 Response to "E-Cards and other Dynamic Systems" 
|
said this on 13 Oct 2009 6:33:45 AM CST
Hi, this sounds all good
|



Author/Admin)