I would like to see Flash Player support an expanded rendering API. Today Flash has a very limited rendering API and constantly renders any object added to the DisplayList (exceptions for cacheAsBitmap & MouseEvent.updateAfterEvent). Due to the nature of constant rendering, the player is required to constantly switch from rendering graphics to executing logic (AVM bytecode) as highlighted by the Elastic Racetrack.
Having the player constantly render is expensive and if developers could control the rendering cycle, we would see a new class of higher performance graphical applications and games using Flash Player and AIR.
QUESTION: What if developers could have programmatic control of rendering?
flash.display.Stage.frameRate = 0;
//turn off rendering
//render a single sprite and its children
Today we do have access to a rendering API within flash.events.MouseEvent.updateAfterEvent() and cacheAsBitmap but these are of limited use for those wanting fine grained control of the renderer. The assumption remains that player is constantly rendering but you can skip rendering some objects or on mouse events force rendering to update graphics quickly. The assumption is that the entire displayList is rendered (except where cacheAsBitmap is true) vs designating certain objects in the displayList tree for rendering.
PROPOSAL #1: Rendering is turned off when stage.frameRate is set to 0.
– Turn off constant rendering
– Developer must designate items to render via the method below.
– Render a sprite and any child objects ondemand
– Pre-render DisplayObjects not attached to the DisplayList
– Render only part of the displayList tree. MySprite.render vs stage.render()
The other way to go is to have modes for the renderer like so:
flash.system.System.renderMode = flash.display.RenderMode.CONSTANT;
//todays default behavior
flash.system.System.renderMode = flash.display.RenderMode.ONDEMAND;
//no rendering but you get enterframe events
I know this would be a powerful API in the hands of game and application developers and would allow a developer to turn off rendering once an animation completed. Obviously it isn’t perfect but then again what is? I would love to hear your thoughts on adding a rendering API into Flash Player.
The proposal has been submitted as a feature enhancement using the public process. Once filed feature enhancement are routed to the Flash Player Product Managers for review. If you have features you want to see, feel free to submit them here.