Flash
  Home arrow Flash arrow Page 2 - Flash MX Prototyping Basics
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Moblin 
JMSL Numerical Library 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
FLASH

Flash MX Prototyping Basics
By: David Millington
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 10
    2004-06-09

    Table of Contents:
  • Flash MX Prototyping Basics
  • A Side Note on Paths
  • Dealing with Time
  • Self Containment

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    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);

    More Flash Articles
    More By David Millinton


     

    FLASH ARTICLES

    - Organizing Frames and Layers for Flash Anima...
    - Organizing Frames and Layers
    - Using XML and ActionScript with Flex Applica...
    - Interfaces and Events with ActionScript and ...
    - Manipulating Data with ActionScript in Flex ...
    - ActionScript Syntax for Flex Applications
    - ActionScript in Flex Applications
    - A Closer Look at Apollo`s File System API
    - Using the File System API
    - ActionScript 101
    - Flash Buttons
    - Advanced Flash Animation
    - Creating Your First Animated Movie with Flas...
    - Flash: Building Blocks
    - Building Preloaders






    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
    Stay green...Green IT