optimizing macromedia flash assets in director (session #mc002w) bruce epstein principal, zeus...

25
Optimizing Macromedia Flash Assets in Director (session #MC002W) Bruce Epstein Principal, Zeus Productions October 28, 2002

Upload: shana-pierce

Post on 29-Dec-2015

220 views

Category:

Documents


2 download

TRANSCRIPT

Optimizing Macromedia Flash Assets in Director (session #MC002W)

Bruce EpsteinPrincipal, Zeus ProductionsOctober 28, 2002

2

Optimizing Flash Assets in Director

›Bruce Epstein - Zeus Productions

[email protected]

›http://www.zeusprod.com/devcon2002

›Books

›Director in a Nutshell

›Lingo in a Nutshell

›ActionScript for Flash MX: The Definitive Guide by Colin Moock

3

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

4

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)

5

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

6

Your Flash “Budget”

›Number of Simultaneous Flash Sprites

›Simultaneous Non-Flash Content

›Complexity of Each Flash Asset

›Curves

›Frame Rate (and Duration!!!!!)

›Transparencies

›ActionScript

7

Your Flash “Budget”

›Flash Footprint

›Memory usage (Xtra instance plus content)

›Processor usage

›Screen real estate (dirty rects)

8

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

9

Preparing Assets in Flash

›Anticipate Use in Director

›No sounds (trigger from Director)

›Minimal ActionScript

›Don’t use Flash scenes (flattened on export)

›Synchronization

10

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?

11

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

12

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

13

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

14

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!)

15

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

16

Custom Animation Engine

›Complete Control and Flexibility

›Play animations backwards

›Database-Driven animation sequences

›Abort animations

›Smoother segues

17

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

18

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

19

Sprite and Member Properties

property flashSpron 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 = #passAlwaysend beginSprite

on advanceIt me flashSpr.frame = flashSpr.frame + 1 goToFrame (flashSpr, flashSpr.frame+1)end advanceIt

20

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 = theRectend

21

getURL( )

ActionScript in Flash:

getURL ("event: flashSound \" soundName\""); // pass string with escaped quotesgetURL ("event: flashSound ' soundName "); // pass string with single quotesgetURL ("event: getStuff [2.5, 17, 25]"); // pass array

Lingo in Director (attached to Flash Sprite):

on flashSound me, soundName puppetSound soundNameend

on getStuff me, someArray, someFloat -- whateverend

22

Coordinate Transformations

See http://www.zeusprod.com/devcon2002originMode: #topLeftoriginPoint: point(0, 0)originH: 0.00originV: 0.00viewScale: 100.00viewPoint: point(783, 228)viewH: 783.00viewV: 228.00scaleMode: #noScaledefaultRect: rect(0, 0, 1420, 480)defaultRectMode: #flashflashRect: rect(0, 0, 1420, 480)

23

Custom Animation Engine - Demo

›Demo Bartending Sim Animation Engine

›Source Code at: http://www.zeusprod.com/devcon2002

24

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

25

Conclusion

›Manual Control is the Way to Go!

›See http://www.zeusprod.com/devcon2002

›Email [email protected]