Hello,
I’m quite fond of the “Copy Motion as Actionscript 3.0” feature. I think it’s pretty neat. However, the XML-based animation only works when the XML variable is in the code. I’m trying to make it so where I can place the XML-based animation tags in an external XML file, and then load it into the application. I prefer to have it this way as opposed to having the XML tags hardcoded into the app.
Here is the XML file:
<?xml version="1.0" ?>
<Motion duration="30" xmlns="fl.motion.*" xmlns:geom="flash.geom.*" xmlns:filters="flash.filters.*">
<source>
<Source frameRate="30" x="127.5" y="127.5" scaleX="1" scaleY="1" rotation="0" elementType="movie clip">
<dimensions>
<geom:Rectangle left="0" top="0" width="55" height="55"/>
</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>
</Keyframe>
<Keyframe index="29" x="578.95"/>
</Motion>
The movie clip is named ‘ball’ as obviously told from the following AS3 code:
import flash.net.URLLoader ;
import flash.net.URLRequest ;
import flash.net.URLLoaderDataFormat ;
import fl.motion.Animator ;
var loader:URLLoader = new URLLoader( ) ;
loader.dataFormat = URLLoaderDataFormat.TEXT ;
loader.load( new URLRequest( "XML/Test.xml" ) ) ;
loader.addEventListener( Event.COMPLETE, startAnimation ) ;
function startAnimation( e:Event ):void
{
var ball_xml:XML = new XML( e.target.data ) ;
var ball_animator:Animator = new Animator( ball_xml, ball ) ;
ball_animator.play();
}
So what exactly am I doing wrong?