Flash
  Home arrow Flash arrow Page 4 - Flash Hacks: Simulate 3D and Add a Vector ...
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  
Dedicated Servers  
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 Hacks: Simulate 3D and Add a Vector Edge to a Bitmap
By: O'Reilly Media
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 13
    2004-08-10

    Table of Contents:
  • Flash Hacks: Simulate 3D and Add a Vector Edge to a Bitmap
  • Masking
  • Event Handlers
  • Hack 23: Add a Vector Edge to a Bitmap
  • Move the Vector Outline

  • 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 Hacks: Simulate 3D and Add a Vector Edge to a Bitmap - Hack 23: Add a Vector Edge to a Bitmap


    (Page 4 of 5 )

    Hack 23: Add a Vector Edge to a Bitmap

    When you need a graphic that contains textures and a sharp edge, you are stuck. A vector shape will give you the sharp edge but is not able to show complex textures. A bitmap can show complex textures but will have no sharp edge. Create the best of both vectors and bitmaps in Flash—a bitmap with a vector edge.

    For some images (particularly logos or other graphics that contain text or a “spiky” edge rather than the smoothly curving butterfly wing), the feathering technique [Hack #22] loses the sharp edges of the original. In such cases, we can do the opposite—create a sharp vector edge.

    In this hack, we hide the jaggies by covering them with a vector stroke or by masking them out with a vector mask.

    We perform the bitmap manipulation in Photoshop, but you can achieve similar results in other programs, including Fireworks.

    Select the image created in the preceding hack [Hack #22] and export it as a PNG using File -> Save As. You also need to export a second image in which you have turned all the nonzero pixels to black, as shown in Figure 3-40. You can do this in Photoshop by selecting Image -> Adjustments -> Bright-ness/Contrast. Set both the brightness and contrast sliders in the Brightness/ Contrast window all the way to the left to turn all pixels to black.

     bhangal

    Import both of the images into Flash using File -> Import -> Import to Stage. Select the black silhouette and convert it to a vector using Modify -> Bitmap -> Trace Bitmap. This leaves you with a black vector shape. You can add a stroke around the shape to create an outline of your bitmap.

    You can either use the stroke outline, as seen in Figure 3-41, as a cookie cutter or use the shape as a standard vector mask. The latter method is immediately obvious, but the former is more efficient computationally because it doesn’t require Flash to constantly apply the mask (which is helpful if you need to animate the bitmap later).

     bhangal

    When you convert the PNG into a vector, you do not end up with the black shape encased in a white shape (which would happen if you imported a bitmap consisting of a shape on a white background). Because there is no background in our PNG (and because Flash can correctly convert zero alpha pixels into “no vector”), your vector conversion is faster, with less cleanup afterward.

    So let’s move forward with the cookie-cutter method, given that it is by far the more hacky and nonobvious.

    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

    - 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
    - Fun Things to Do with Movie Clips in Flash MX







    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway