Problem with "copy motion as ActionScript 3"

so i tried using the “copy motion as ActionScript 3” feature in Flash CS3… so far so good… but i cant seem to figure out why the code wont work once i put it inside a function…

in layer 1, i have a circle on stage with an instance name of “circle”
in layer 2, i have pasted the “motion ActionScript” code:

import fl.motion.Animator;
var circle_xml:XML = <Motion duration="30" xmlns="fl.motion.*" xmlns:geom="flash.geom.*" xmlns:filters="flash.filters.*">
    <source>
        <Source frameRate="12" x="64" y="214.4" scaleX="1" scaleY="1" rotation="0" elementType="movie clip" symbolName="circletest">
            <dimensions>
                <geom:Rectangle left="0" top="0" width="123" height="123"/>
            </dimensions>
            <transformationPoint>
                <geom:Point x="0.5" y="0.5"/>
            </transformationPoint>
        </Source>
    </source>

    <Keyframe index="0" tweenSnap="true" tweenSync="true">
        <tweens>
            <SimpleEase ease="0"/>
        </tweens>
        <filters>
            <filters:BlurFilter blurX="0" blurY="0" quality="1"/>
        </filters>
    </Keyframe>

    <Keyframe index="14" tweenSnap="true" tweenSync="true" x="214.39999999999998">
        <tweens>
            <SimpleEase ease="0"/>
        </tweens>
        <filters>
            <filters:BlurFilter blurX="38" blurY="0" quality="1"/>
        </filters>
    </Keyframe>

    <Keyframe index="29" tweenSnap="true" tweenSync="true" x="422.4">
        <tweens>
            <SimpleEase ease="0"/>
        </tweens>
        <filters>
            <filters:BlurFilter blurX="0" blurY="0" quality="1"/>
        </filters>
    </Keyframe>
</Motion>;

var circle_animator:Animator = new Animator(circle_xml, circle);
circle_animator.play();

i published the movie and it worked fine, the circle animated…

next i tried to put the “motion ActionScript” code inside a function and run it:

runTheAnimation();
function runTheAnimation():void
{
import fl.motion.Animator;
var circle_xml:XML = <Motion duration="30" xmlns="fl.motion.*" xmlns:geom="flash.geom.*" xmlns:filters="flash.filters.*">
    <source>
        <Source frameRate="12" x="64" y="214.4" scaleX="1" scaleY="1" rotation="0" elementType="movie clip" symbolName="circletest">
            <dimensions>
                <geom:Rectangle left="0" top="0" width="123" height="123"/>
            </dimensions>
            <transformationPoint>
                <geom:Point x="0.5" y="0.5"/>
            </transformationPoint>
        </Source>
    </source>

    <Keyframe index="0" tweenSnap="true" tweenSync="true">
        <tweens>
            <SimpleEase ease="0"/>
        </tweens>
        <filters>
            <filters:BlurFilter blurX="0" blurY="0" quality="1"/>
        </filters>
    </Keyframe>

    <Keyframe index="14" tweenSnap="true" tweenSync="true" x="214.39999999999998">
        <tweens>
            <SimpleEase ease="0"/>
        </tweens>
        <filters>
            <filters:BlurFilter blurX="38" blurY="0" quality="1"/>
        </filters>
    </Keyframe>

    <Keyframe index="29" tweenSnap="true" tweenSync="true" x="422.4">
        <tweens>
            <SimpleEase ease="0"/>
        </tweens>
        <filters>
            <filters:BlurFilter blurX="0" blurY="0" quality="1"/>
        </filters>
    </Keyframe>
</Motion>;

var circle_animator:Animator = new Animator(circle_xml, circle);
circle_animator.play();
}

i published the movie and now it wont work… how come??
i need to be able to put the “motion ActionScript 3” inside a function because i will create a button which is supposed to run the animation when clicked…