What is WebGL?

WebGL is an open web standard for rendering graphics on any compatible browser, without the need for additional plug-ins. WebGL is integrated completely into all the web standards of the browser allowing GPU accelerated usage of image processing and effects as part of the web page canvas. WebGL elements can be embedded with other HTML elements and composited with other parts of the page.

Although, most modern-day browsers support WebGL, visit this link to know more details about the exact versions that are supported.

Some browsers do not have WebGL enabled by default. To enable WebGL on your browser, see this article.

Note:

Ensure that you enable WebGL on your browser, because some browsers disable WebGL by default.

The WebGL document type

Flash Professional CC allows you to create and publish rich interactive content to the Web Graphics Library (WebGL) format. Since WebGL is fully integrated into browsers, it allows Flash Professional to leverage GPU accelerated usage of graphics processing and rendering, as part of the web page canvas.

In Flash Professional CC, a new document type has been added for WebGL. This allows you to create content and quickly publish to a WebGL output. You can leverage powerful tools within Flash to create rich content, but render WebGL output that runs on any compatible browser. This means that you can use the traditional Flash timeline, workspace, and drawing tools to natively author and produce WebGL content. Most commonly used browsers support WebGL, there by, allowing Flash Pro to render content on most web platforms.

Previewing WebGL content on browsers

You can use the Test Movie feature of Flash Pro to preview or test your content. To preview, do the following:

Within Flash Professional CC, press Ctrl+Enter on Windows and CMD+Enter on MAC. This launches your default browser and renders the WebGL content.

Flash Professional CC requires a web server to run WebGL content. Flash Pro CC has a built-in Web Server that is configured to run WebGL content on Port #8090. If a server is already using this port, Flash Pro automatically detects and resolves the conflict.

Provide a meaningful name for the output. Also, browse to or enter the location where you want to publish the WebGL output.

Overwrite HTML

Lets you specify whether to overwrite the HTML Wrapper or not everytime you publish your WebGL project. You may uncheck this option if you have made any external changes to the published HTML file and wish to retain them while updating any changes made to the animation or assets in Flahs Pro.

Include Hidden Layers

Includes all hidden layers in the WebGL output. Deselecting Include Hidden Layers prevents all layers (including layers nested inside movie clips) marked as hidden from being exported in the resulting WebGL. This lets you easily test different versions of WebGL document by making layers invisible.

Loop Timeline

Repeats the content when it reaches the last frame. Deselect this option to stop the content when it reaches the last frame.

Click Publish to publish WebGL content to the specified location.

Note:

The maximum FPS that could specified for WebGL content that run on browsers is 60FPS.

Understanding the WebGL output

The published WebGL output contains the following files:

HTML Wrapper file

It includes the runtime, calls for assets, and also, initializes the WebGL renderer. The file is named as <FLA_name>.html by default. You can provide a different name for the HTML file in the Publish Settings dialog (File > Publish Settings).

The HTML file is placed in the same directory as that of the FLA by default. You can provide a different location on the Publish Settings dialog.

JavaScript File (WebGL Runtime)

Renders published content on WebGL. Is published in the libs/ folder of the WebGL document. The file is named as: flwebgl-<version>.min.js

The HTML wrapper makes use of this JS file to render WebGL content.

Texture Atlas

Stores all the color value ( of shapes ) including the bitmap instances on the stage.

Adding audio to your WebGL document

You can import and embed audio to the your WebGL document, control the playback using the sync settings (event, start, and stop), and play timeline audio at runtime. WebGL currently supports only .wav and .mp3 formats.

Migrating existing content to a WebGL document

You can migrate existing content within Flash Pro to a WebGL document. To its end, Flash Pro allows you to migrate via copying or importing content manually. Also, when working with multiple documents within Flash, it is a common practice to copy content across documents as Layers or assets in the Library. Although, most features of Flash Pro are supported, some content types are modified to better accommodate the WebGL format.

Flash Professional contains several powerful features that help produce visually rich content. However, considering that some of these features are native to Flash Pro, they will not be supported in a WebGL document. Flash Pro has been designed to modify such content to a supported format, and visually indicate when a tool or feature is not supported.

Copy

content (layers or library symbols) from a traditional Flash document type (such as ActionScript 3.0, AIR for Android, AIR for Desktop, and so on) into a WebGL document. In this case, an unsupported content-type is either removed or converted to supported defaults.

For example, copying 3D animation will remove all 3D transformations applied to objects on stage.

Import

a PSD or AI file that contain unsupported content. In this case, the content is either removed or converted to supported defaults.

For example, import a PSD file that has Blur effects applied. Flash Pro removes the effect.

Work

with multiple document types (for example, ActionScript 3.0 and WebGL) simultaneously, you switch documents with an unsupported tool or option selected. In this case, Flash Pro CC visually indicates that the feature is not supported.

For example, you created a dotted line in an ActionScript 3.0 document and switch to WebGL with the Line tool still selected. Observe the pointer and the Properties Inspector, they visually indicate that dotted line is not supported within WebGL.

Scripts

You can write Javascript code in the Actions panel, which will be executed after player enters the frame. The 'this' variable in the context of frame scripts refers to the instance of the MovieClip it belongs to. In addition, frame scripts can access Javascript functions and variables declared in the container HTML file. When you copy a frame or layer from an ActionScript document and paste it in a WebGL document, scripts if any will be commented.

Changes applied to content after migrating

The following are the types of changes that are applied when you migrate legacy content to an WebGL document.

Content is removed

Content types that are not supported in HTML5 Canvas are removed. For example:

Filters

are not supported. The effect will be removed, and the shape will assume a solid fill, instead.

Blur Filter effect is removed, and is replaced by Solid fill.

Content is modified to a supported default value

Content type or feature is supported, but a property of the feature is not. For example:

Radial Gradient

is modified to assume Solid fill using the primary color.

Radial Gradient is modified to Solid fill using the primary color.

For a full list of features that are not supported and their fallback values during migration, see this article.

Improving rendering performance with bitmap caching

Runtime bitmap caching lets you optimize rendering performance by specifying that a static movie clip (for example, a background image) or button symbol be cached as a bitmap at runtime. By default, vector items are redrawn in every frame. Caching a movie clip or button symbol as a bitmap prevents the browser from having to continually redraw the item, because the image is a bitmap and its position does not change. This provides a significant improvement in performance of rendering WebGL content.

For example, when you create an animation with a complex background, create a movie clip containing all the items included in the background. Then select Cache as Bitmap for the background movie clip in the Property inspector. During playback, the background is rendered as a bitmap stored at the current screen depth. Browser draws the bitmap on the Stage quickly and only once, letting the animation play faster and more smoothly.

Bitmap caching lets you use a movie clip and freeze it in place automatically. If a region changes, vector data updates the bitmap cache. This process minimizes the number of redraws that browser must perform, and provides smoother, faster rendering performance.

To enable Cache as Bitmap property for a movieclip symbol, select the movieclip instance, and select Cache as Bitmap from the Render drop-down on Properties Inspector (Window > Properties).

Considerations when using Cache as Bitmap

When using Cache as Bitmap property on WebGL content, consider the following:

Maximum size of the movieclip symbol is limited to 2048x2048. Note that the actual bounds of the movie clip instance that can be cached are lesser than 2048x2048, WebGL reserves some pixels.

If there is more than one instance of the same movieclip, Flash Professional generates the cache with the size of the first instance encountered. However, the cache is not re-generated and Cache as Bitmap property is not ignored, even if the transform of the movie clip changes to a large extent. And hence, if the movieclip symbol is greatly scaled during the course of animation, the animation may appear pixelated.

Twitter™ and Facebook posts are not covered under the terms of Creative Commons.