Flash Hacks

Book description

If you've ever seen an especially cool Flash effect on the web, gone straight to your trusty Flash book to find out how to do it, then turned away empty-handed--Flash Hacks is for you. This unique book offers a collection of expert Flash tips and tricks for optimization, creating interesting effects, ActionScript programming, sound and video effects, and much more--and you don't need to be an expert to use them (although you'll certainly look like one).With Flash technology, you can create compelling web content, expressive user interfaces, and rich applications for the Internet--all of which dramatically enhance the user experience. But Flash is not just practical, it's a wellspring of opportunities to unleash your creativity and have fun. Flash Hacks dives straight into all that's fun and creative about Flash, while presenting useful programming techniques and practical--although never mundane--hacks that can make your work easier.Geared to cover Flash MX, Flash MX 2004, and Flash MX Professional 2004, Flash Hacks begins with hacks on authoring, testing, and web environments. You'll learn how to beat the Flash bloat bug, realistically simulate the web, create a JavaScript-free Flash sniffer, and hack a spellchecker for Flash. Other hacks in the book are grouped in the following areas:

  • Primitives
  • Timelines
  • Symbols
  • Flash Assets (sound, video, and bitmaps)
  • Code hacks
  • Events and event handling
  • Advanced animation
  • UI design hacks
True to O'Reilly's popular Hacks series, Flash Hacks tackles problems and solutions that aren't dealt with elsewhere. You'll pick up insider tips from the experts, and learn about amazing and sometimes quirky aspects of Flash. If you want more than your average Flash user--you want to explore and experiment, unearth shortcuts, create useful tools, and come up with fun things to try on your own--Flash Hacks is the book you'll need.

Table of contents

  1. Contents
  2. Foreword
  3. Credits
    1. About the Author
    2. Contributors
    3. Acknowledgments
  4. Preface
    1. Why Flash Hacks?
    2. Who This Book Is For
    3. How to Use This Book
    4. How This Book Is Organized
    5. Conventions Used in This Book
    6. Using Code Examples
      1. Getting the Code Examples Working
      2. ActionScript 1.0 Versus ActionScript 2.0
      3. Case-Sensitivity
    7. Comments and Questions
  5. Visual Effects
    1. Fake Per-Pixel Transitions
      1. Make the Pixels
      2. Make Lots of Pixels
      3. Control the Pixels
      4. Create the Timers
      5. Using the Effect
      6. Extend the Effect
      7. Final Thoughts
    2. Per-Pixel Text Effects
      1. Final Thoughts
    3. Simulate Old Film Grain
      1. Create the Film Grain Bitmap
      2. Using a Bitmap in Flash
      3. Final Thoughts
    4. Create SWFs from Animated GIFs
      1. The GIF Animated Critter
      2. Create the Animation Assets
      3. Final Thoughts
    5. Animate Photoshop PSD Files with Flash
      1. Final Thoughts
    6. A Tree Grows in Brooklyn
      1. Fractals
    7. Blowin’ in the Wind: Simulate Tree Movement
      1. Final Thoughts
  6. Color Effects
    1. Video Color Effects
      1. The Boy Can’t Dance
      2. Color Coding
      3. Color Video Transforms
    2. Video Fade to Black and Fade to White
      1. Transitions Over Time
      2. Final Thoughts
    3. A Custom Color Transform Class
      1. An Object-Oriented Transformation
    4. Create and Organize Custom Swatches
      1. Importing Colors
      2. Final Thoughts
    5. Borrow Color Schemes from Nature
      1. Final Thoughts
    6. Simulate Sepia Effects
      1. Creating a Sepia Effect in Photoshop
      2. Reworking the Effect in Flash
      3. Using the Sepia Effect in Static Graphics
      4. Dynamic Sepia Effects with the Color Class
  7. Drawing and Masking
    1. Create Filled Circles Quickly at Runtime
      1. The Code
      2. Hacking the Hack
    2. Create Synthetic Art
      1. The Code
      2. Final Thoughts
    3. Create Seamless Tiles
      1. Negative Space
      2. Final Thoughts
    4. Fill Areas with Patterns
      1. Filling a Rectangular Area
      2. Filling a Nonrectangular Area
      3. Final Thoughts
    5. Imitate Escher
      1. The Divided Plane
      2. Final Thoughts
    6. Fix Alpha Property Inaccuracies
      1. The Five Alpha Values that Result in No Error
      2. Mirroring the _alpha Property
      3. Avoiding Alpha Errors via Classes/Prototypes
      4. Final Thoughts
    7. Use Complex Shapes as Masks
      1. Using Complex Masks
    8. Interference Patterns and Ripple Effects
      1. Final Thoughts
    9. Feather Bitmap Edges
      1. Feathering Bitmaps
    10. Add a Vector Edge to a Bitmap
      1. Final Thoughts
    11. Solve the Bitmap-Shift Bug
      1. How Not to Fix It
      2. How to Fix It (the Good Way)
      3. How to Fix It in Dynamically Loaded Files (the Effective Way)
    12. A Page-Turn Effect (Exploit Symmetry and Masking)
      1. A Mathematical Hall of Mirrors
      2. Page Turning
      3. Final Thoughts
  8. Animation
    1. Smooth Scripted Motion
      1. User-Actuated Movement (Breaking the onEnterFrame Monopoly)
      2. Final Thoughts
    2. Time-Controlled Movement
      1. The Code
      2. Final Thoughts
    3. Quick, Bandwidth-Efficient Character Animation
      1. Hacky Wacky Walking
      2. Final Thoughts
    4. alt-Flash: Motion Graphics Alternatives
      1. Processing
      2. KoolMoves
      3. Final Thoughts
    5. Deja New Animations
      1. Final Thoughts
    6. Hacking The Matrix
      1. Final Thoughts
    7. Computer-Generated Character Animation
      1. Automating Character Animation with Poser
      2. Using Poser to Create Animation Directly
      3. Final Thoughts
    8. Particle Effects
      1. Star Field
      2. Final Thoughts
    9. Shape Tweening Complex Shapes
      1. Final Thoughts
  9. 3D and Physics
    1. Simulate 3D
      1. Slice 2D to Create an Extra Dimension
      2. Cut Up the Tarsier
      3. Final Thoughts
    2. Panoramic Images
      1. Creating Panoramic Images
      2. Using Flash for Image Manipulation
      3. Final Thoughts
    3. An Optimized 3D Plotter
      1. Final Thoughts
    4. Use Acceleration to Simulate Gravity and Friction
      1. Final Thoughts
    5. Simulate a Throw
      1. Final Thoughts
    6. Detect Multiple Collisions
      1. A Collision Hierarchy
      2. Collisions in the Reverse Hierarchy
      3. Final Thoughts
    7. Turn Toward a Point
      1. Following a Moving Target
      2. Facing Toward a Point
      3. Adding Inertia
      4. Final Thoughts
  10. Text
    1. Fonts
    2. Keep Text Legible
      1. Read the Screen Dimensions
      2. Final Thoughts
    3. Autocomplete Text Fields
      1. The Code
      2. Final Thoughts
    4. Store a List of All Input Words
      1. Add New Words to the Dictionary
      2. The Code
      3. Save the Dictionary for Later Use
      4. Final Thoughts
    5. Import Complex Formatting in Flash
      1. Create Math-Formatted Text
      2. Import Formatted Text from Other Sources
      3. Final Thoughts
    6. HTML and CSS in Flash
      1. Formatting Text with HTML
      2. Formatting with CSS
      3. Embedding Images
      4. Final Thoughts
    7. Use Accessibility Text as Help Text
      1. Adding Accessibility Properties
      2. The Code
      3. Final Thoughts
    8. Text Effect Framework
      1. Create the Text
      2. Embed the Font
      3. Wrap It in a Movie Clip
      4. Place the Text Dynamically
      5. Final Thoughts
    9. Typewriter Effect
      1. The Code
      2. Final Thoughts
    10. Time-Based Text Effects
      1. Stand-Up Effect
      2. The Code
      3. Drop Effect
      4. Fade-in and Zoom Effect
      5. Final Thoughts
    11. Timeline Text Effects
      1. Breaking Apart Text
      2. Using the Envelope Tool
      3. Final Thoughts
  11. Sound
    1. Create a Flash Speech Synthesizer
      1. The Trouble with Lasers
      2. Using Sound.onSoundComplete Event
      3. Speech and Flash
      4. Fonetikally Speeking
      5. Final Thoughts
    2. A Talking, Lip-Synched Avatar
    3. The Ubiquitous Sound-Kicker Hack
      1. Final Thoughts
    4. Turn Low-Bandwidth Monaural Sounds into Stereo Sounds
    5. Real-Time Sound Effects
    6. Quickly Create UI Sounds
      1. Abandonware
      2. Creating UI Sounds by Time Stretching
      3. Final Thoughts
    7. Optimize Sound
      1. Hacking Around Quantization Noise
        1. Adobe Audition
        2. Audacity
      2. Hacking Around Aliasing Noise
      3. Final Thoughts
    8. Sound Time Codes (Cue Points)
    9. A Custom Sound Transform Class
  12. User Interface Elements
    1. Amit’s Dials (Interactive Testing)
      1. Using the Slider
      2. Final Thoughts
    2. Right and Middle Mouse Buttons
      1. Class of 800
      2. Final Thoughts
    3. Button Movie Clips
      1. Adding Button States
      2. Final Thoughts
    4. Dude, Where’s My Scrollbar?
      1. Final Thoughts
  13. Performance and Optimization
    1. Optimize Filesize and Download Time
    2. Optimize Graphics
    3. Increase Code Performance
    4. Beat Flash File Bloat
      1. Why the Big File?
      2. The Fix
      3. Final Thoughts
    5. Bandwidth Testing for Complex Sites
      1. Final Thoughts
    6. Hide Low-Quality Settings
      1. Use Noncontrasting Colors
      2. Use Horizontal/Vertical and Fast-Moving Shapes
      3. Use Pixel Fonts
      4. Final Thoughts
    7. Optimize Graphics for Performance
      1. Design with Speed in Mind
      2. Create and Test Optimized Graphics
      3. Final Thoughts
    8. Benchmark Runtime Performance
      1. Final Thoughts
    9. Adjust the Animation Complexity Dynamically
      1. Calculate the Achieved Frame Rate
      2. Adjust the Complexity Based on Performance
      3. Final Thoughts
    10. Performance Budget
      1. Areas of Focus
      2. Set Process Priorities
      3. Implementation
      4. Final Thoughts
    11. Substitute Bitmaps for Vectors
      1. Example One: Bitmaps Move Faster than Do Vectors
      2. Example Two: Avoid Antialias Calculations
      3. Final Thoughts
    12. Optimize Component Downloading and Usage
      1. Final Thoughts
  14. ActionScript
    1. Changes in Flash MX 2004
      1. New ActionScript in Flash Player 7
      2. Case Sensitivity and Strict Typing
      3. LiveDocs
    2. External Script Editors
      1. Final Thoughts
    3. Strict Typing and Casual Scripters
      1. How Strict Typing Helps
      2. Limitations of Strict Typing
        1. Dynamic properties are not type checked
        2. Conditional statements confuse type checking
      3. Final Thoughts
    4. Code Hints
    5. Clone an Object
      1. Cloning for Motion Graphics
      2. Final Thoughts
    6. An Idle Timer (Timeout Event)
      1. Final Thoughts
    7. Fast ActionScript Searches
      1. Final Thoughts
    8. Lock the actions Layer
      1. Locking a Layer
      2. Final Thoughts
    9. Debug with trace( )
      1. Final Thoughts
    10. Undocumented ActionScript
      1. Final Thoughts
    11. ASnative( ) Back Door
      1. Final Thoughts
    12. Obscure Operators
      1. Modulo: Clamp and Snap
      2. Optimize Range Checking
      3. Optimize Inertial Motion with Bit Shifting
      4. Final Thoughts
    13. Import ASC Files as XML
      1. ASC Files
      2. Import and Parse the ASC File
      3. Parse Each Line in an ASC File
      4. Final Thoughts
  15. Browser Integration
    1. Keep Your Site Browser Friendly
      1. Use a Flash Plugin Sniffer
      2. Test Using Many Browsers
      3. Design and Test for Search Engine Compatibility
      4. The Flash Context Menu
      5. Final Thoughts
    2. A Universal Flash Plugin Sniffer
      1. Five Seconds and Counting…
      2. Asking Flash to Run Itself
      3. Making It a Bit More Discerning
      4. Final Thoughts
    3. Test Multiple Flash Plugins
      1. Using Flash Plugin Switcher
      2. Final Thoughts
    4. Preferences and Publishing Defaults
      1. Changing the Preference Defaults
        1. General tab
        2. Editing tab
        3. Clipboard tab
        4. Warnings tab
        5. ActionScript tab
      2. Changing the Publishing Defaults
        1. HTML tab
        2. Flash tab
      3. Other Panels and Tabs
    5. Center Your SWF Without Scaling
    6. CSS-Based Browser Centering
      1. Centering Using the Publish Settings
      2. Centering Using HTML
      3. Centering a Flash MX 2004 SWF Using CSS
      4. Final Thoughts
    7. Dynamically Resize Content
      1. Measuring the Stage
      2. Final Thoughts
    8. Create HTML Links in Flash
      1. Final Thoughts
    9. Integrate the Back Button with Flash
      1. Creating the HTML
      2. Creating the Flash Content
      3. Final Thoughts
    10. Give the Flash SWF Keyboard Focus
      1. Final Thoughts
    11. Add Key Shortcuts to Your Site
      1. Detecting Keypresses
      2. Turning Keystrokes into Inputs
      3. Turning Combos into Inputs
      4. Final Thoughts
  16. Security
    1. Privacy Settings
    2. Cross-Domain Policy
    3. Handling Local Executables
    4. Recover Content from a SWF
      1. The ASV 3.0 Interface
      2. Extract ActionScript
      3. View the Original Timeline
      4. Extract the Library
      5. Final Thoughts
    5. Protect and Obfuscate Your Flash Files
      1. Protect the SWF
      2. Obfuscate (“Dummy”) the File Types
      3. Final Thoughts
    6. Make Your SWF Phone Home
      1. Cause the SWF to Fail
      2. Jump to Your Home Site
      3. Use Cross-Protection
      4. Final Thoughts
    7. Review Compiled ActionScript
      1. Flasm
      2. Using the Compiled Listing
      3. Working with Flasm
      4. Final Thoughts
  17. Index (1/4)
  18. Index (2/4)
  19. Index (3/4)
  20. Index (4/4)

Product information

  • Title: Flash Hacks
  • Author(s): Sham Bhangal
  • Release date: June 2004
  • Publisher(s): O'Reilly Media, Inc.
  • ISBN: 9780596153540