Home arrow Flash arrow Page 2 - Flash MX Prototyping Basics
FLASH

Flash MX Prototyping Basics


Flash MX prototyping allows you to extend your movies in ways you never thought possible. By using prototyping you can share an effect or function among several movies without the need to replicate the code. This leads to your movies being more efficient, smaller in size and easier to code. Prototyping is not for the faint of heart so if you’re new to ActionScript or just programming in general you may want to brush up on the basics first. This article will provide the foundations to begin prototyping for yourself as well as provide some solutions to commonly asked questions in the forum.

Author Info:
By: David Millington
Rating: 4 stars4 stars4 stars4 stars4 stars / 10
June 09, 2004
TABLE OF CONTENTS:
  1. · Flash MX Prototyping Basics
  2. · A Side Note on Paths
  3. · Dealing with Time
  4. · Self Containment

print this article
SEARCH DEVARTICLES

TOOLS YOU CAN USE

advertisement
Flash MX Prototyping Basics - A Side Note on Paths
(Page 2 of 4 )

An important factor when writing prototypes is getting your paths correct. In the centerAlign function, the _x and _y are set using this as the target. That's because it's written in the scope of the movie clip and not _root where the code is actually written. Let's run through some examples of what can go wrong.

You have a movie clip that has a child movie clip and they both have the same instance name, let's call them both subMenu. You write a new prototype in the first key frame of _root that should change the position of the child clip, like expanding a sub menu.  Inside the prototype you have:

subMenu._x += 100;

That's not actually referring to the child as you might imagine, instead it is referring to the main movie clip in _root. To get the scope right, you must refer to it like:

this.subMenu._x += 100;

A similar problem occurs when using variables. If the variable is not used in the right scope, all kinds of chaos can arise. A typical example of variable problems might be when a user reports "I'm sure the data is getting added correctly but when I try and use it it's not there". That's because the data has been successfully added to a variable in a different scope.

MovieClip.prototype.mover = function()
   {
      this.createEmptyTextField("debugText", 1, 0, 0, 100, 10);
      this.debugText.variable = debugVar;
      debugVar = "This is in the wrong scope";     
      // The correct way to address this
      // this.debugVar = "This is the correct scope";
   }
myMovie.mover();
// This will return undefined
trace(myMovie.debugVar);
// This shows that the sentence we meant to assign to the text box in myMovie was actually created in the parent.
Trace(debugVar);


blog comments powered by Disqus
FLASH ARTICLES

- More Top Flash Game Tutorials
- Top Flash Game Tutorials
- Best Flash Photo Gallery Tutorials
- The Top Flash Tutorials for Menus
- 7 Great Flash Tutorials
- Adobe Creative Suite 5.5 Now Available
- Critical Flash Vulnerability Heats Up the Web
- More on Nonpersistent Client-Side Remote Sha...
- Nonpersistent Client-Side Remote Shared Obje...
- Using the Decorator Pattern for a Real Web S...
- Using Concrete Decorator Classes
- Delving More Deeply into the Decorator Patte...
- The Decorator Pattern in Action
- A Simple Decorator Pattern Example
- Decorator Pattern

Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 



© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 4 - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials