Archive for March, 2006

Duplicating Movie Clips Completely

Thursday, March 30th, 2006
ActionScript 2.0

The duplicateMovieClip() function, and its method cousin, MovieClip.duplicateMovieClip(), both do what their names imply: they duplicate movie clips.  But there’s a catch.  Let’s read a small excerpt from the ActionScript Language Reference for each feature.  Keep reading »

Why Doesn’t _root.gotoAndPlay() Work with Scenes?

Monday, March 27th, 2006
ActionScript 2.0

You may have seen this one in the forums; it comes up from time to time.  Everyone knows that gotoAndPlay() supports Scene names as an optional parameter, right?  You can either supply a frame number or frame label …

gotoAndPlay(15);
gotoAndPlay("roll-out animation");

… or a Scene name and a frame number …

gotoAndPlay("game over", 1);

… and that works.  So what’s the deal? — why does it break if you specify _root (or some other path) in front of that gotoAndPlay() function?  Keep reading »

Lifting the Veil:  Debugging

Friday, March 24th, 2006
ActionScript 2.0

This article was significantly updated and accepted for publication by Adobe.  It now lives here:

http://www.adobe.com/devnet/flash/articles/debugging_actionscript.html

How to Reference Objects Dynamically

Wednesday, March 22nd, 2006
ActionScript 2.0

Sometimes it’s useful to reference a movie clip (or any object) by combining individual pieces of its instance name dynamically.  In coding up a version of Space Invaders, for example, you might employ a dozen instances of the same movie clip symbol to represent a dozen alien space ships.  Each clip will have its own instance name, of course, which might be alien0, alien1, alien2, and so on.  Rather than create an array to hold each instance name or reference, you might rather combine the string “alien” with the numbers 0, 1, 2, etc., to formulate your reference.  Keep reading »

Objects:  Your ActionScript Building Blocks (AS2)

Monday, March 20th, 2006
ActionScript 2.0

Think about your approach to ActionScript like this:  LEGO® bricks.  Each brick has its own unique qualities, which determine how it may be used most effectively.  The standard 2×4 bricks are good for constructing walls, 2x2s are good for towers, 1x6s are good for … you get the idea.  The characteristics of each brick dictate its use.

In ActionScript, you have similar such building blocks.  They’re called objects.  In programming terms, an object is a discrete collection of variables and functions:  it is a “thing” comprised of certain characteristics that perform certain actions and respond to certain others.

Just about everything in ActionScript may be represented by an object, including palpable items like movie clips, buttons, and text fields, as well as non-visual items like dates, arrays, and sounds.  Even ethereal concepts like text formatting, colors, and math functions can be summed up by an object.  Once you become familiar with the objects in ActionScript, you may use them like bricks to build whatever you please.  Keep reading »