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/1.0'>
    <Components>
        <Component id='Button' type='SWC' />
    </Components>
     <Timeline>
        <Frame>
            <Place name='Button' depth='2' instanceName='myButton' x='10.0' y='20.0'>
                <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/1.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/1.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>

More detailed information can be found in the installation documentation.