Kinesis SoftwareKineticFusion

[Show Table of Contents]

8 Working With RVML Documents

[Hide Table of Contents]



8.1.6 Working With SWC Components

KineticFusion supports the integration of external SWC components in RVML during both RVML compilation and decompilation without having to specify the entire component as RVML.

8.1.6.1 Main Component Support Features

  • Components can be declared in RVML documents and are automatically compiled into a resulting SWF movie
  • All classes stored inside a component are automatically added to the compilation class path
  • Common resources from multiple components are merged on output
  • Components can be manipulated on a timeline the same as a MovieClip symbol
  • KineticFusion will locate SWC components on multiple user-specified paths
  • All component resources located when translating SWF to RVML can be identified, removed, and replaced with a Component reference
  • Example external tag library for handling components allows component-based UIs to be specified declaratively and can be used as the basis for building sophisticated component-oriented extensions.

8.1.6.2 Summary of SWC Component Configuration Options

New configuration options are available to help support the new SWC component capabilities.

8.1.6.2.1 kinesis.components.path

KineticFusion is able to reference SWC components during both compilation and decompilation. This configuration property can be used to specify one or more folders in which to look for referenced SWC components. The path can be a compound path with each path component separated by a semicolon.

Once the paths are defined KineticFusion will automatically search the specified folders and all sub-folders for SWC files.

This property is a global property for all RVML documents and SWF movies. As a result, this property cannot be relative to a single RVML document but should always be specified in terms of absolute paths. Changes to this property will be immediately picked up the KineticFusion GUI and applied to all future documents.

8.1.6.2.2 kinesis.components.resolve

SWC components, when represented in RVML, can needlessly complicate RVML output, adding all the symbol definitions and resources to the output RVML. When this property is enabled, the input SWF is automatically scanned for all defined components on the component path. Each discovered component is removed from the RVML output and replaced instead with a short Component element that specifies that the component should be included in the SWF on compilation.

8.1.6.2.3 kinesis.components.logMissingAssets

KineticFusion will only resolve embedded components in an SWF if it can ensure that all the contents of the component exist within the SWF. This ensures that SWFs containing symbols with the same name as components are not accidentally identified as components and removed. However, should the assets associated with an external component be augmented since the component was added to the SWF, KineticFusion will not be able to fully identify the component. When this option is enabled, KineticFusion will log all the required symbols in the component that do not exist in the SWF.

8.1.6.2.4 kinesis.components.ignoreAssets

If a component has been upgraded since the SWF was originally created then the assets in the component may not match the assets stored in the SWF. In this case, it is still desirable that the component be identified and resolved so that the RVML will reference the most up-to-date component on compilation. This property defines a list of assets that are not required within an SWF in order to resolve embedded components.

8.1.6.3 Adding SWC Components

Two new RVML elements have been created to support the definition of SWC components within an RVML movie.

8.1.6.3.1 <Components> element

The Components element is used to group all defined components in an RVML document. When the end tag of this element is encountered, all defined components are analyzed, optimized, and both the symbols and ActionScript classes of the component are immediately available for use within the rest of the document.

8.1.6.3.2 <Component> element

The Component element defines a single SWC component that will be included in the output SWF movie.

8.1.6.4 Referencing Component classes

SWC components are generally a mixture of graphical assets and ActionScript classes (though there is no requirement for either). When a component is defined within an RVML document all the ActionScript classes contained within the SWC component are automatically available for use in all other scripts. KineticFusion will automatically add all the intrinsic classes inside the SWC to the document ActionScript class path and the classes are automatically included in the output SWF.

8.1.6.5 SWC Component Examples

SWC component can be defined inside any RVML document using the new <Component> element available in KineticFusion 3.0. Once a component has been defined it can be automatically referenced using normal timeline operations or using ActionScript.

Declaring and Referencing a Component using the Timeline

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<Movie version='7' width='150' height='150' rate='23' backgroundColor='white'
     compressed='Yes' xmlns='http://www.kineticfusion.org/RVML/3.0'>
    <Components>
        <Component id='Button' type='SWC' />
    </Components>
     <Timeline>
        <Frame>
          <Place name='Button' depth='2' instanceName='myButton' x='10' y='20'>
              <MovieClipActions><![CDATA[
on(construct)
{
    label = "Hello";
}
onClipEvent(load)
{
    this.addEventListener("click", function ( event)
        {
            if( this.label == "Hello" )
                this.label = "Bye";
            else
                this.label = "Hello";
        });
}                ]]></MovieClipActions>
            </Place>
        </Frame>
    </Timeline>
</Movie>

So what does the resulting SWF look like? Have a look (it's about 27K) ....

It's also a simple matter to create a component programmatically. In this example, we will again create a button but use ActionScript to create a default instance of the button. Events handlers have been omitted for simplicity:

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<Movie version='7' width='150' height='150' rate='23' backgroundColor='white' 
    compressed='Yes' xmlns='http://www.kineticfusion.org/RVML/3.0'>
    <Components>
        <Component id='Button' type='SWC' />
    </Components>
    <Definitions />
    <ExportSymbols />
    <Timeline frameCount='1'>
        <Frame frameNo='1'>
            <FrameActions>
import mx.controls.Button;
createClassObject(Button, "button", 5, {label:"I Do Nothing"});                 
            </FrameActions>
        </Frame>
    </Timeline>
</Movie>

You can see the resulting SWF here (it's about 27K) ....

Finally, when component resolution is enabled, we can decompile this SWF back to RVML with all the component resources removed. This is the output on translation to RVML:

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!-- <!DOCTYPE Movie SYSTEM 'dtd/RVML.dtd'> -->
<Movie version='7' width='150' height='150' rate='23' backgroundColor='white' 
compressed='Yes' xmlns='http://www.kineticfusion.org/RVML/3.0'>
        <ActionScriptSettings>
               <ASProperty name='analyzeScriptsAsAS2' value='Yes' />
        </ActionScriptSettings>
        <Components>
               <Component id='Button' type='SWC' />
        </Components>
        <Definitions />
        <ExportSymbols />
        <Timeline frameCount='1'>
               <Frame frameNo='1'>
                       <FrameActions><![CDATA[
createClassObject(mx.controls.Button, "button", 5, {label:"I Do Nothing"});
                       ]]></FrameActions>
               </Frame>
        </Timeline>
</Movie>