<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!-- <!DOCTYPE Movie SYSTEM "dtd/RVML.dtd"> -->
<Movie version='6' width='600' height='400' rate='30' backgroundColor='white' compressed='No' enableDebug="Yes"
    xmlns="http://www.kineticfusion.org/RVML/2.0">
    <Title>
        Example Of MovieClip classes and scripted animations
    </Title>
    <Desc>
        Illustrated how to associate a MovieClip symbol with an ActionScript class that
        can be scripted. Two MovieClips are placed on the timeline but with different initializers
        so that the first clip is rendered horizontally and the second vertically. The position of
        each movie clip is altered using a MovieClip ActionScript event handler.
    </Desc>
    <Definitions>
        <FontDefinition id='Arial' fontName='Arial' fontStyle='(bold)' fontRange='defined' />
        <!--Grey Box -->
        <Shape id='greyBoxShape' bounds="auto">
            <LineStyles>
                <LineStyle index="1" width="0.05" color="red"/>
            </LineStyles>
            <FillStyles>
                <ColorFill index="1" color="lightGrey"/>
            </FillStyles>
            <Edges>
                <SetStyle line="1" mainFill="1"/>
                <Rect x="0" y="0" width="100" height="100" />
            </Edges>
        </Shape>
        <!-- Movie clip with box on first frame -->
        <MovieClip id="GreyBoxClip">
            <Timeline>
                <Frame>
                    <Place name="greyBoxShape" depth="1"/>
                </Frame>
            </Timeline>
        </MovieClip>
    </Definitions>
    <!-- Export our movie clip as we need to associate it with a 
         name and class in actionscript -->
    <ExportSymbols>
        <ExportSymbol name='GreyBoxClip' exportName='GreyBoxClip' />
    </ExportSymbols>
    <InitClipActions>
        <InitClip name="GreyBoxClip"><![CDATA[
function GreyBoxClass()
{
    this.init();
}
GreyBoxClass.prototype = new MovieClip();

GreyBoxClass.prototype.isHorizontal = function()
{
    if ( this.horizontal == undefined )
        this.horizontal = true;
    return this.horizontal;
};

GreyBoxClass.prototype.getWidth = function()
{
    if ( this.isHorizontal() )
        return 100;
    else
        return 5;
        };
        
GreyBoxClass.prototype.getHeight = function()
{
    if ( this.isHorizontal() )
        return 5;
    else
        return 100;
};

GreyBoxClass.prototype.init = function()
{
    // Rather contrived example 

    this._width = this.getWidth();
    this._height = this.getHeight();
};
Object.registerClass("GreyBoxClip", GreyBoxClass);
]]>
        </InitClip>
    </InitClipActions>
    <Timeline>
        <Frame>
            <Place name="GreyBoxClip" depth="1" x="100" y="30">
                <MovieClipActions><![CDATA[
// Called before the class initialisers are called so properties available to initialisers
onClipEvent( setParameters )
{
    horizontal = true;
    // Initialise direction here
    direction = 1;
}
onClipEvent( enterFrame )
{
    this._x = this._x +direction;
    if ( this._x >600 - this._width || this._x < 0)
        direction = -direction;
}                
    ]]></MovieClipActions>
            </Place>
            <Place name="GreyBoxClip" depth="2" x="100" y="130">
                <MovieClipActions><![CDATA[
onClipEvent( setParameters )
{
    horizontal = false;

}
// The horizontal property set here will not be seen by the class initializers as load 
//handlers executed afterwards. As a result the box will be drawn vertically.
onClipEvent( load )
{
    horizontal = true;
    // Initialise direction here
    direction = 1;
}
onClipEvent( enterFrame )
{
    this._x = this._x +direction;
    if ( this._x >600 - this._width|| this._x < 0 )
        direction = -direction;
}                ]]></MovieClipActions>
            </Place>
        </Frame>
    </Timeline>
</Movie>