Packagefl.livepreview
Classpublic class LivePreviewParent
InheritanceLivePreviewParent Inheritance flash.display.MovieClip

The LivePreviewParent class provides the timeline for a SWC file or for a compiled clip that is being exported when ActionScript 3.0 is selected.

When a property is set on a component instance or when a component instance is resized on the Stage, Flash makes calls to the methods of this class, which in turn call methods in your component code to set the properties and to resize the component.

In cases where your component must implement a specific action when it is in live preview mode, use the following code to test for live preview mode:

var isLivePreview:Boolean = (parent != null && getQualifiedClassName(parent) == "fl.livepreview::LivePreviewParent");

The LivePreviewParent class supports the definition of a setSize() method that uses width and height values to resize a component. If you do not define a setSize() method, this object sets the width and height properties individually.

You can also use this class to create a custom live preview SWF file without creating a SWC file; however, it is probably easier to create a component live preview file by:

To create a component live preview file in this way, follow these steps:

  1. Create a new Flash document.
  2. Set its document class to fl.livepreview.LivePreviewParent.
  3. Drag your component to the Stage and position it to x and y coordinates of 0.
  4. Check to ensure that the component parameters remain at their default settings. This should be the case if you drag the component from the Library panel or from the Components panel.
  5. Select Modify > Document from the main menu and, for the Match option, click Contents.
  6. Click OK.
  7. Publish the file to see the resulting SWF file as a custom live preview SWF file.
  8. Right-click the asset in the Library panel and select Component Definition from the context menu.
  9. The Component Definition dialog box allows you to specify a custom live preview SWF file for a component.

In some cases, you may want to have a custom live preview SWF file that is completely different from your component. See the live preview of the fl.containers.UILoader component for such an example. This live preview does not use the properties of UILoader, nor does it implement getter and setter functions for these properties. It does, however, implement a setSize() method that uses width and height parameters to draw the component at the new size.



Public Properties
 PropertyDefined by
  myInstance : DisplayObject
The component instance.
LivePreviewParent
Public Methods
 MethodDefined by
  
Initializes the scale and align modes of the Stage, sets the myInstance property, resizes myInstance to the proper size and uses the ExternalInterface class to expose functions to Flash.
LivePreviewParent
  
onResize(width:Number, height:Number):void
Resizes the component instance on the Stage to the specified dimensions, either by calling a user-defined method, or by separately setting the width and height properties.
LivePreviewParent
  
onUpdate(... updateArray):void
Updates the properties of the component instance.
LivePreviewParent
  
propertyInspectorSettingUpdate(updating:Boolean):void
LivePreviewParent
Property detail
myInstanceproperty
public var myInstance:DisplayObject

The component instance.

Constructor detail
LivePreviewParent()constructor
public function LivePreviewParent()

Initializes the scale and align modes of the Stage, sets the myInstance property, resizes myInstance to the proper size and uses the ExternalInterface class to expose functions to Flash.

Method detail
onResize()method
public function onResize(width:Number, height:Number):void

Resizes the component instance on the Stage to the specified dimensions, either by calling a user-defined method, or by separately setting the width and height properties.

This method is called by Flash Player.

Parameters
width:Number — The new width for the myInstance instance.
 
height:Number — The new height for the myInstance instance.
onUpdate()method 
public function onUpdate(... updateArray):void

Updates the properties of the component instance. This method is called by Flash Player when there is a change in the value of a property. This method updates all component properties, whether or not they were changed.

Parameters
... updateArray — An array of parameter names and values.
propertyInspectorSettingUpdate()method 
public function propertyInspectorSettingUpdate(updating:Boolean):voidParameters
updating:Boolean