| Register
Saturday, May 17, 2008   

UML key concepts applied to Flash development

Created By  Carlos Rovira, at  8/2/2004 - 10 comments.

Click to view this author's website.

If you are thinking of starting an OOP Flash project from scratch, you must seriously consider planning and organizing your thoughts with the help of UML. The Unified Modeling Language has been around for less than a decade and has become one of the main tools of the application developer. For a Flash project you can use UML too, drawing diagrams representing your classes, interfaces and packages and the relation between them in order to start coding more eficiently. First though, you must learn about the UML graphical gadgets and their corresponding OOP concepts.

UML Relationship Key Concepts

As you can see in figure 1, there are some UML diagram elements representing OOP key concepts that you can use in order to construct a well-crafted diagram of your application packages, classes and interfaces. Let's go through the chart, commenting some aspects.

uml_relations (26k image)

Packages. Packages are used traditionally to prevent name collisions between classes. This is accomplished providing a namespace represented in code with the following notation: somepackage.someNestedPackage.classname. The given logical notation maps the physical folder structure. You can represent a package as a labeled box that surrounds its own classes and interfaces. The before-mentioned label is the name package.

Inheritance. As you know, one of the main concepts in Object Oriented Programing. Here the subclass "inherits" from the superclass, (i.e, subclass "is a" superclass or behaves as the superclass plus some features of his own that makes the difference). It's represented in the image with a line starting at the subclass and ending in a white arrow at the superclass.

Composition. In this relation the superclass instance "has a" subclass instance (or more than one). If the superclass instance is destroyed the same happens with subclass instances as they act as a whole. The diagram's representation for this relationship is a line starting at the superclass with a black diamond and ending in the subclass. Optionally you can specify how many subclass instances the superclass could hold.

Aggregation. This relation is similar to composition, but here the relationship depicted is a "uses a" relationship. The superclass is not owning the subclass instances so if it's destroyed the subclass instance is not. The representation is the same as the composition but changing the black diamond with a white one.

Dependency. Indicates that the dependent resource needs other independent resource. The dependent element may demand changes in case of changes in the independent element. The graphical representation is a dashed line with a simple arrow that points from the dependent object to the resource object.

Interfaces. In UML notation an interface is represented in the same way as a class but setting the <> stereotype at the top of the box as a way to diferenciate it. You can denote graphicaly that a class implements an interface by drawing a dashed line that starts in the class and ends in the interface with a white arrow.

Accessibility modifiers. Public and private modifiers for class members can be easily denoted with + and - symbols respectively. As in ActionScript there's no default accesibility modifier, if you don't write any symbol you may interpret this as a public modifier.

You can see figure 2 for a more detailed diagram of a tipical class, showing how to set members variables and methods and his accesibility modifiers.

uml_classdetail (5k image)

An UML Example Diagram.

Figure 3 is an example constructed to show you the before mentioned concepts.

uml_example (29k image)

Here we have an ui package that holds all the related classes of some imaginary user interface architecture.

The example is focused on a Window class that extends the MovieClip class in order to get all functionality that you need to display the window component on screen properly. At this point, you may consider to use the Flash v2 Component Framework. In that case you must to extends from the UIComponent Class (that inherits from UIOBject and finaly from MovieClip).

Window implements the IStackable interface. You may be more precise about IStackable interface and give the method or methods that you must implement in Window (what do you think about a -moveToTop():Void method in order to manage the z-order visibility of the windows instances of the class?, the minus let us know that is a private method).

Window has a composition relationship with the ToolBar class. The diagram tell us that "a window has one(and only one) toolBar". ToolBar has one or more IconButtons that extends or inherits from the BasicButton class. If you destroy a window then toolBar and buttons inside are destroyed in the same way. The retrofitted composition relationship in the Windows class represents that a window could behave as a container and create other windows inside itself.

There's another package called os that contains operating system related classes. The <> dependency relationship tell us that os package depends from ui package and changes in it must be taken into consideration in the previous one. The OsModule supports only one StageController that aggregates zero or more Windows. The StageController uses the windows to give support to the OsModule about windows related things. The windows aren't part of the StageController and if you destroy it the windows don't have to know anything about it.

Some Useful Links

You may use this article as and introduction point to UML applied to Flash. Now I want to share some useful links where you can go from here and continue improving your knowledge about this powerfull developer tool.


  • http://www.uml.org/. The Unified Modeling Languaje start page.

  • http://gmodeler.com/. The amazing application written by Flash guru Grant Skinner. You can use it to create your own diagrams and export to stub Flash code. A version 2 is under development.

Need Professional Help For Your ActionScript Project?
ActionScript.com Consulting Services provide top quality professional ActionScript consulting to businesses around the globe. If you have a professional project in need to world-class talent, tell us about your project by requesting a quote today.

Reader Comments

  1. Bernd  Replied:
    ( 8/27/2004 At 10:13 PM)

    check http://www.sparxsystems.com.au

  2. caseyc  Replied:
    ( 8/29/2004 At 11:38 AM)

    Check this out, a free uml tool with AS2 support that even has a tutorial!

  3. paul  Replied:
    ( 8/29/2004 At 11:59 AM)

    >> tool that generates actionscript 2.0

  4. Marliese  Replied:
    ( 9/7/2004 At 3:35 AM)

    to bernd!

  5. kouri  Replied:
    ( 9/8/2004 At 5:38 PM)

    CodeAlloy complement seems not working with latest version of argoUML :(

  6. Michael Asker  Replied:
    ( 9/10/2004 At 11:09 AM)

    1) I like what Rhapsody/I-Logix do today ...generated whoel applications for C,C++,(java) and ADA ... not stubs but whole applications are generated from the model. Air, Mil, Industry, Automotive adn Med use it today.... why are Macromedia slow when it comes to produce a similar tool?

  7. AOL  Replied:
    ( 9/15/2004 At 8:35 PM)

    I think the most important thing of UML , is not the class Diagram.First of all,I ofen use rational rose to draw the use case diagram .Second,From the use case event stream description analyse the object of this system.Third,Sequence Diagrams。Last,the result is Class Diagram.

  8. anonymous  Replied:
    ( 7/20/2005 At 3:07 PM)

    "detailed diagram of a tipical class,"
    a tipical mispelling.

  9. Yehia Shouman  Replied:
    ( 9/25/2005 At 12:30 AM)

    I made an XSLT that converts XMI generated by Enterprise Architect to Actionscript 2.0 classes. Features:
    *Support of full documentation copying from Enterprise XMI exported files
    *Support of inheritence
    *Support of Macromedia's Classes structure
    *automatic .as classes files creation with stub code
    Bad sides:
    *Support of interfaces
    *Support of "import" (uses relationship)

  10. Yehia Shouman  Replied:
    ( 10/4/2005 At 3:57 AM)

    It is a tool now (.net 1.1 based)
    -converts XMI generated by Enterprise Architect to Actionscript 2.0 classes.
    Features:
    *Support of full documentation copying from Enterprise XMI exported files
    *Support of Macromedia’s Classes structure
    *automatic .as classes files creation with stub code in their proper namespaces(folders)
    *selective export feature

Login to post your comments. If you do not have an account with us please Register.
Copyright 2005 by ActionScript, Inc.   |  Privacy Statement  |  Terms Of Use  |  ActionScript Client Extranet