[Previous entry: "Nantucket"] [Cliffs - Home] [Next entry: "Headstand"]

06/09/2003: "Last ActionScript Hero"

Friends of ED is dead, and with it their FOUNDATION series on Macromedia Flash. This entry is about, and with thanks to, Brits Sham Bhangal and Ben Renow-Clarke and their book ActionScript for Macromedia Flash MX. Who is Sham; he writes in his dedication of an earlier work in the series "this is for Karen, without whom this book would have been written much faster", and Ben, just take in his keeki.com web site for a peek at who he is. This is a great technical book that can be read without ergonomically correct seating. A sample from chapter 6 of 13 follows:

Being a programmer will, of course, give you a leg up, but the only required background is enough Flash (4,5 or 6) experience to set up a movie with simple tween animations and publish it. This exercise is not even half way through the book and look at this: click to see.
This completely centralized code creates movie clips on the fly and loads them with dynamic content using new objects created inside an array Blah Blah (get the book) and they covered this stuff, it was not just winging it. They cover the material entertainingly and you don't need to be at your computer with the application open to follow the logic. Good stuff.

All of the code.

// Initialize useful variables and picture array
cellWidth = reel_mc.cell_mc._width;
center = Stage.width/2;
pics = new Array();
// Handler to move showreel left and right across the stage
_root.onEnterFrame = function() {
reelSpeed = (_xmouse-center)/10;
reel_mc._x += reelSpeed;
// Apply limits to reel position
leftStop = center-reel_mc._width+cellWidth/2;
rightStop = center-cellWidth/2;
if (reel_mc._x < leftStop) {
reel_mc._x = leftStop;
} else if (reel_mc._x > rightStop) {
reel_mc._x = rightStop;
}
};
// Define constructor function for Picture objects
Picture = function (name, link, color, description) {
this.name = name;
this.link = link;
this.color = color;
this.description = description;
};
// Define function for creating cells in the showreel
NewCell = function (num, details) {
// Create a new cell
originalClip = _root.reel_mc.cell_mc;
newClip = originalClip.duplicateMovieClip("cell"+num, num);
// Set cell position and text fields
newClip._x = num*300;
newClip.name_txt.text = num+1 + ". " + details.name;
newClip.description_txt.text = details.description;
// Set cell content
content = newClip.placeholder_mc;
content.loadMovie(details.link);

// Set color of cell background
myColor = new Color(newClip.bgnd_mc);
myColor.setRGB(details.color);
};
// Set up picture objects
pics[0] = new Picture("cobblestones", "cobblestones.jpg", 0xFF9999, "from an English country lane...");
pics[1] = new Picture("planet", "planet.jpg", 0x99FF99, "the view from 400km up...");
pics[2] = new Picture("water", "water.jpg", 0x9999FF, "ripples in a pond...");
// Loop through array of picture objects, creating a new cell for each
for (i=0; i NewCell(i, pics[i]);
}

If you're not excited yet or you just want to look at the .fla (zipped) click here.


Note to readers:
Readers with Internet Explorer can use these links to "Add to Favorites." The rest of you are on your own. Remember, Cliffs Notes dot Info.
Click here to add this page to your favorites!
Click here to add this site to your favorites!

If you've enjoyed Cliff's Notes, click here to find lots more blogs. This link opens in a new window in case you realize you were better off here.
Last but not least, if anything interesting comes to mind about the above post that you would like to share, blurt it out in the form below. If you enter a "homepage," your "name," as you entered it, will become a link to your site. E-mail addresses, if entered, may be harvested by spammers.

Replies: 2 Comments

Yes, the publisher is still on line at www.friendsofed.com.

Cliff said @ 06/17/2003 11:06 PM CST

Can you still get the downloads?

Excited said @ 06/17/2003 07:44 PM CST


Powered by Greymatter