Flash
  Home arrow Flash arrow Page 4 - Flash Hack A Custom Color Transform Class
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  
Mobile Linux 
App Generation ROI 
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 Hack A Custom Color Transform Class
By: O'Reilly Media
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 14
    2004-10-12

    Table of Contents:
  • Flash Hack A Custom Color Transform Class
  • Code Listing: A Custom Transform Class
  • A Closer Look at the Code
  • Constructor Function Transform()
  • Enhancing the Custom Class

  • 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 Hack A Custom Color Transform Class - Constructor Function Transform()


    (Page 4 of 5 )

    Next, notice the constructor function, Transform( ), optional in Action-Script 2.0, which is used to initialize instances of the class. Our constructor accepts the target clip to be used later by other methods of the class. The class then defines several public methods that can be invoked on instances of the class, such as invert( ) and fadeToWhite( ), and private methods that are for internal use only.

    Notice in particular the form of the setInterval( ) invocation. In this case, the first parameter passed is an object. We invoke setInterval( ) with the keywordthis, which represents the current object (i.e., the instance of the Transform class on which applyTransform( ) was invoked). The second parameter is the name of the method to invoke onthis, namely"transition"(which must be specified as a string). Thus, at the appropriate time, the Transform.transition( ) method is invoked on the current instance,this. Invoking a method on the current instance ensures that instance properties, such asintervalandcolorObj, are in scope within transition( ). The fourth and fifth parameters passed to setInterval( ),diffTransandduration, are passed as parameters to transition( ), when it is invoked. The transition( ) method performs the specified transform over the specified duration and clears the interval when complete.

    To use the code, first instantiate an instance of the Transform class, as follows (wheremyVideo_mcis an existing movie clip whose instance name has been set in the Properties panel):

    var transformer:Transform = new Transform(myVideo_mc);

    Then, invoke any methods of the class on the object:

    transformer.invert(3000); // Invert the colors for 3 seconds transformer.fadeToWhite(2000); // Fade to white over 2 seconds

    To clean up when you are done, use:

    transformer.die();
    delete transformer;

     

     

    Buy the book!If you've enjoyed what you've seen here, or to get more information, click on the "Buy the book!" graphic. Pick up a copy today!

    Visit the O'Reilly Network http://www.oreillynet.com for more online content.

    More Flash Articles
    More By O'Reilly Media


     

    FLASH ARTICLES

    - Decorator Pattern
    - 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






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