Custom component for distribution – live preview detection

It’s been a while since I worked on a custom component for distribution, to auto-install in the Adobe Extension Manager.

Many online tuts and official documentation assume that you want to extend the standard Flash UI Component framework. Building components without using this framework is a bit of a black art. Kudos to David Barlia’s blog post at Studio Barliesque for answering a lot of my questions regarding this approach.

When you set up a custom component and drag it to the stage from the library, it is still just a static symbol. However a component that comes from the ‘Components Panel’, (i.e. you’ve moved the FLA or SWC to the folder  Adobe Flash CS6/Common/Configuration/Components ) actually runs the component when you drag it to the stage. It’s great that you can see something happen on the stage, but sometimes you don’t want it to do the same thing in authoring or compiled modes.

The common solution to handle this is to set up a separate movie which will display when you drag on the component, called the live preview. (for example this is described in this page in tutsplus)

However I was interested in the component detecting whether it was being displayed in authoring mode or compiled. Unfortunately it’s not as easy as you’d think. Capabilities.playerType thinks its running ‘External’ either way. So, I was at a road block until a few years ago David Barlia at Studio Barliesque managed to find the answer for me.

The following method can detect whether the component is running as a live preview in authoring mode, or in a compiled SWF.

protected function isLivePreview():Boolean {
return (parent != null && getQualifiedClassName(parent) == "fl.livepreview::LivePreviewParent");

With this method you can use the same class for the component and have it work differently depending on whether it is a live preview or not.

iOS development with Swift - book: video course:

Tagged with: , ,
Posted in Flash

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: