250 likes | 345 Views
Optimizing Macromedia Flash Assets in Director (session #MC002W). Bruce Epstein Principal, Zeus Productions October 28, 2002. Optimizing Flash Assets in Director. Bruce Epstein - Zeus Productions bruce@zeusprod.com http://www.zeusprod.com/devcon2002 Books Director in a Nutshell
E N D
Optimizing Macromedia Flash Assets in Director (session #MC002W) Bruce Epstein Principal, Zeus Productions October 28, 2002
Optimizing Flash Assets in Director • Bruce Epstein - Zeus Productions • bruce@zeusprod.com • http://www.zeusprod.com/devcon2002 • Books • Director in a Nutshell • Lingo in a Nutshell • ActionScript for Flash MX: The Definitive Guide by Colin Moock
What You’ll Learn • Optimizing Assets for Playback • Planning ahead • Preparing SWF files while in Flash • Playing back Flash sprites imported into Director • Techniques • Sending messages to Director via ActionScript • Controlling Flash sprites using Lingo
Planning Ahead • What Director Projects Benefit from Flash? • Repurpose existing assets • Incorporating Full Flash Presentations • Build larger shell around existing Flash movie • Incorporating Smaller Flash assets • Animations vs. interactivity • Recreating assets in Director (without Flash)
Director Support for Flash Asset Xtras • Director 8 supported Flash 4 SWFs • Director 8.5 supports Flash 5 SWFs • Benefit from Flash features, such as XML • Flash MX (Flash 6) Asset Xtra for Director • Expected for Director 8.5 • Will it support Director 8.0 or earlier versions • Waiting for Godot MX
Your Flash “Budget” • Number of Simultaneous Flash Sprites • Simultaneous Non-Flash Content • Complexity of Each Flash Asset • Curves • Frame Rate (and Duration!!!!!) • Transparencies • ActionScript
Your Flash “Budget” • Flash Footprint • Memory usage (Xtra instance plus content) • Processor usage • Screen real estate (dirty rects)
Preparing Assets in Flash • Reduce, Reduce, Reduce • Smaller animations (avoid bitmaps) • Lower rate (fewer tween frames) • Reduce bounding rect • Simplify (fewer curves) • Avoid transparencies (alpha channels) • Compensating later when all Hell breaks loose
Preparing Assets in Flash • Anticipate Use in Director • No sounds (trigger from Director) • Minimal ActionScript • Don’t use Flash scenes (flattened on export) • Synchronization
Compositing Assets in Director • What will it overlap with in space? • Bounding rect containing Director sprites • Overlapping other Flash assets • What will it overlap in time? • Screen refresh • Segue from one animation to the next • What does it need to trigger, respond to, or synchronize with?
Playing Flash Sprites in Director • Manual Control - Static vs. Animated • Set static and pausedAtStart to TRUE • Control frame position with goToFrame() • Control rendering quality dynamically (manually) • Manual synchronization • Trigger sound and Lingo manually
Playing Flash Sprites in Director • Benefits of Manual Control of Flash Sprites • Better performance • More reliable (trigger sounds) • Better synchronization • Play backwards • Play subportions and combine in unique sequences • Vary rendering quality based on needs and performance characteristics
Sample Application - Bartending Sim • Heavy Flash character animation (10+) • Extremely large Flash animations (1400 x 500) • Each SWF Containing Multiple Sequences) • Composting Characters’ Body and Face • Segue between animation sequences • Combining animation sequences for variation
Technical Approach - Sounds • Multiple Characters, each with VO and SFX • Triggering Sounds in Director using getURL() • Asynchronous vs. synchronous • Synchronizing SFX with Animation Engine • Pseudo Lip-Synch of VO • Don’t Try This at Home (no Flash sounds!)
Custom Animation Engine • Manual Control over Flash Frame Position • Independent of Director frame rate • Synchronous and asynchronous animation • Detect (and adapt to!) machine performance • Maintain timed animation’s speed on slow machines and throttle it on fast ones • Adjust rendering quality on the fly
Custom Animation Engine • Complete Control and Flexibility • Play animations backwards • Database-Driven animation sequences • Abort animations • Smoother segues
Custom Animation Engine • Rendering Performance • Up to 300% improvement • Up to 10 simultaneous Flash sprites • Dozens of Director sprites • Up to 8 sound channels • How Did We Do It? • Use coordinate transformations to render subportions of a Flash sprite
Custom Animation Engine - Techniques • Send Events from SWF to Lingo • Trigger sounds • Trigger changes in drawing rect • Use getURL("event:") (not "lingo:") • Use Lingo to Manage Flash Sprites • Frame to be displayed using gotoFrame() • Rendering quality using quality property • Handle events using on someEvent
Sprite and Member Properties property flashSpr on beginSprite me flashSpr = sprite (me.spriteNum) flashMem = flashSprite.member -- Set sprite properties flashSpr.static = TRUE flashSpr.pausedAtStart = TRUE flashSpr.directToStage = TRUE flashSpr.quality = #autoLow -- Set member properties flashSpr.eventPassMode = #passAlways end beginSprite on advanceIt me flashSpr.frame = flashSpr.frame + 1 goToFrame (flashSpr, flashSpr.frame+1) end advanceIt
getURL( ) ActionScript in Flash: getURL ("event: newRect rect(16, 32,290, 245) "); Lingo in Director (attached to Flash Sprite): on newRect me, theRect -- Forget me not! theRect = value (theRect) sprite(x).rect = theRect end
getURL( ) ActionScript in Flash: getURL ("event: flashSound \" soundName\""); // pass string with escaped quotes getURL ("event: flashSound ' soundName "); // pass string with single quotes getURL ("event: getStuff [2.5, 17, 25]"); // pass array Lingo in Director (attached to Flash Sprite): on flashSound me, soundName puppetSound soundName end on getStuff me, someArray, someFloat -- whatever end
Coordinate Transformations See http://www.zeusprod.com/devcon2002 originMode: #topLeft originPoint: point(0, 0) originH: 0.00 originV: 0.00 viewScale: 100.00 viewPoint: point(783, 228) viewH: 783.00 viewV: 228.00 scaleMode: #noScale defaultRect: rect(0, 0, 1420, 480) defaultRectMode: #flash flashRect: rect(0, 0, 1420, 480)
Custom Animation Engine - Demo • Demo Bartending Sim Animation Engine • Source Code at: http://www.zeusprod.com/devcon2002
Optimizing Flash Playback - Review • Don't overlap with too many Director sprites • Don't include too many on the screen at once • Reduce amount of non-Flash activity • Use intelligent compositing • Plan with repurposing in mind
Conclusion • Manual Control is the Way to Go! • See http://www.zeusprod.com/devcon2002 • Email bruce@zeusprod.com