Tips and Tricks for Mobile Flash Development

55
@paultran i Paul Trani [email protected] www.paultrani.com @paultrani MOBILE FLASH DEVELOPMENT Tips and Tricks for

TAGS:

description

Learn tips and tricks that will help you when it comes to mobile development. Flash Pro specifically. ActionScript generally.

Transcript of Tips and Tricks for Mobile Flash Development

Page 1: Tips and Tricks for Mobile Flash Development

@paultrani

Paul Trani [email protected] www.paultrani.com @paultrani

MOBILE FLASH DEVELOPMENTTips and Tricks for

Page 2: Tips and Tricks for Mobile Flash Development

@paultrani

Live

Work

Love

Ride

Play

Paul Trani, Adobe Evangelist

Page 3: Tips and Tricks for Mobile Flash Development

@paultrani

Tips and Tricks

Overview of mobile Take advantage of mobile specific capabilities Learn effective ways to optimize Flash content

Page 4: Tips and Tricks for Mobile Flash Development

@paultrani

UNDERSTANDING MOBILEMobile Flash Development

Page 5: Tips and Tricks for Mobile Flash Development

@paultrani

Understanding Mobile

Page 6: Tips and Tricks for Mobile Flash Development

@paultrani

Processing Power

Page 7: Tips and Tricks for Mobile Flash Development

@paultrani

Bandwidth

Page 8: Tips and Tricks for Mobile Flash Development

@paultrani

Internet Users

Page 9: Tips and Tricks for Mobile Flash Development

@paultrani

Screen Size

Page 10: Tips and Tricks for Mobile Flash Development

@paultrani

Think first.

Page 11: Tips and Tricks for Mobile Flash Development

@paultrani

Don’t think mobile last

Page 12: Tips and Tricks for Mobile Flash Development

@paultrani

LET’S START THINKING…Mobile Flash Development

Page 13: Tips and Tricks for Mobile Flash Development

@paultrani

Device Sizes

1024x768

120ppi

1024x600

240ppi

854x480

240ppi

800x480

240ppi

480x320

160ppi

960x640

326ppi

Capabilities

Page 14: Tips and Tricks for Mobile Flash Development

@paultrani

Design for Real Hand Sizes

45x45px15x15px

Start Button

Page 15: Tips and Tricks for Mobile Flash Development

@paultrani

Navigation != Buttons

Page 16: Tips and Tricks for Mobile Flash Development

@paultrani

Gestures

Pinch to zoom Click for more info Swipe for additional items GPS for nearby stores?

Page 17: Tips and Tricks for Mobile Flash Development

@paultrani

Mouse/Touch Events

Touch Events have more overhead than Mouse Events

Can disable with

mouseEnabled

mouseChildren

Don’t use MouseEvent.MOUSE_MOVE

Check Mouse position at interval

Page 18: Tips and Tricks for Mobile Flash Development

@paultrani

Mulitouch Accelerometer Orientation Microphone Keyboard GPS Camera

Device CapabilitiesSwipe/Accelerometer

Page 19: Tips and Tricks for Mobile Flash Development

@paultrani

WORKFLOWMobile Flash Development

Page 20: Tips and Tricks for Mobile Flash Development

@paultrani

Flash/AIR Across Devices

Page 21: Tips and Tricks for Mobile Flash Development

@paultrani

Flash/AIR Across Devices

Page 22: Tips and Tricks for Mobile Flash Development

@paultrani

DIFFERENT MOBILE PLATFORMSMobile Flash Development

Page 23: Tips and Tricks for Mobile Flash Development

@paultrani

Don’t Resize. Recreate.

Page 24: Tips and Tricks for Mobile Flash Development

@paultrani

iOS User Experience

Back

Home

New/Edit

Page 25: Tips and Tricks for Mobile Flash Development

@paultrani

Options Menu

Android User Experience

Back Home

Page 26: Tips and Tricks for Mobile Flash Development

@paultrani

BlackBerry Playbook User Experience

Application Switching

Application Switching

Minimize Application

Bring up Keyboard

Orientation Change

Context Menu

Flash Silk

Page 27: Tips and Tricks for Mobile Flash Development

@paultrani

One Project. Multiple Platforms.

Page 28: Tips and Tricks for Mobile Flash Development

@paultrani

OPTIMIZATIONMobile Flash Development

Page 29: Tips and Tricks for Mobile Flash Development

@paultrani

The Elastic Racetrack

Page 30: Tips and Tricks for Mobile Flash Development

@paultrani

GRAPHICS & RENDERINGMobile Flash Development

Page 31: Tips and Tricks for Mobile Flash Development

@paultrani

Reuse Objects

Consider bitmaps over vectors Keep bitmaps as small as possible

Page 32: Tips and Tricks for Mobile Flash Development

@paultrani

Things to Avoid

FiltersBlend modes:Layer, Alpha, Erase, Overlay, Hard Light, Lighten, Darken

Page 33: Tips and Tricks for Mobile Flash Development

@paultrani

Text

Page 34: Tips and Tricks for Mobile Flash Development

@paultrani

Display Objects

Objects that aren’t interactive?trace(getSize(new Shape()));// output: 216

Interactive but no timeline? trace(getSize(new Sprite()));// output: 396

Need animation? trace(getSize(new MovieClip()));// output: 416

Page 35: Tips and Tricks for Mobile Flash Development

@paultrani

Off Screen Display Objects

Visible = false

Page 36: Tips and Tricks for Mobile Flash Development

@paultrani

Clean Up

alpha = 0 rendering still occurs Set visible = false Events and other costs are still incurred when visible=false.

removeChild instead.

runningBoy.addEventListener(Event.REMOVED_FROM_STAGE,deactivate);function deactivate(e:Event):void{ e.currentTarget.removeEventListener(Event.ENTER_FRAME,handleMovement); e.currentTarget.stop();}

Page 37: Tips and Tricks for Mobile Flash Development

@paultrani

Software Rendering

Page 38: Tips and Tricks for Mobile Flash Development

@paultrani

Prevent Excessive Redraws

Page 39: Tips and Tricks for Mobile Flash Development

@paultrani

Hardware Rendering

Page 40: Tips and Tricks for Mobile Flash Development

@paultrani

Cache as Bitmap

Object is rendered into an offscreen bitmap Use when an object changes position only

Page 41: Tips and Tricks for Mobile Flash Development

@paultrani

Cache as Bitmap Matrix

Scale, skew, rotate, and translate the object without triggering bitmap regeneration.

Page 42: Tips and Tricks for Mobile Flash Development

@paultrani

CPU vs. GPUOtherworld

Page 43: Tips and Tricks for Mobile Flash Development

@paultrani

Blitting

Draw vector content to a bitmap before it ever gets rendered to the stage.

Like painting on the stage.

Blitting

Page 44: Tips and Tricks for Mobile Flash Development

@paultrani

Test, Test, Test

Elliot Mebane http://www.roguish.com

Aliens!

Page 45: Tips and Tricks for Mobile Flash Development

@paultrani

ACTIONSCRIPT PERFORMANCEMobile Flash Development

Page 46: Tips and Tricks for Mobile Flash Development

@paultrani

Performance Tests

https://github.com/mrdoob/Hi-ReS-Stats

Page 47: Tips and Tricks for Mobile Flash Development

@paultrani

Flex Profiler

Page 48: Tips and Tricks for Mobile Flash Development

@paultrani

Time Management

In General, ENTER_FRAME performs better than Timer Use single listener, and then dispatch

Page 49: Tips and Tricks for Mobile Flash Development

@paultrani

Loading and Unloading SWFs

unloadAndStop() Handles the freezing natively and forces the GC process to run:

var loader:Loader = new Loader(); loader.load ( new URLRequest ( "content.swf" ) ); addChild ( loader );

stage.addEventListener ( MouseEvent.CLICK, unloadSWF );function unloadSWF ( e:MouseEvent ):void {

// Unload the SWF file with automatic object deactivation loader.unloadAndStop();

}

Page 50: Tips and Tricks for Mobile Flash Development

@paultrani

Instance Allocation

Page 51: Tips and Tricks for Mobile Flash Development

@paultrani

Instance Allocation

Page 52: Tips and Tricks for Mobile Flash Development

@paultrani

Event Propagation

Can be very expensive, especially deeply nested display list instances.

Event.stopPropagation(); Event.stopImmediatePropagation();

Page 53: Tips and Tricks for Mobile Flash Development

@paultrani

Event Propagation

Page 54: Tips and Tricks for Mobile Flash Development

@paultrani

Thank You

Optimizing Mobile Content for the Adobe Flash PlatformThibault Imbertwww.bytearray.org/?p=1363

Flash Pro New Features@flashplatform – Tom Barclay & Richard Galvan

Paul Trani [email protected] www.paultrani.com

Page 55: Tips and Tricks for Mobile Flash Development

@paultrani

Thank You

Optimizing Mobile Content for the Adobe Flash PlatformThibault Imbertwww.bytearray.org/?p=1363

Flash Pro New Features@flashplatform – Tom Barclay & Richard Galvan

Lynda.com free 30-day pass at this URL:www.lynda.com/freepass/ptrani

Paul Trani [email protected] www.paultrani.com