Skip to main content
Known Participant
April 17, 2015
Answered

how to use motion xml in as3

  • April 17, 2015
  • 1 reply
  • 780 views

the following is the result of exporting motion preset to xml.

<Motion duration="1" xmlns="fl.motion.*" xmlns:geom="flash.geom.*" xmlns:filters="flash.filters.*">

<source>

  <Source frameRate="24" x="449.5" y="138.55" scaleX="1" scaleY="1" rotation="0" elementType="movie clip" instanceName="ball" symbolName="ball">

  <dimensions>

  <geom:Rectangle left="-51.5" top="-51.5" width="103" height="103"/>

  </dimensions>

  <transformationPoint>

  <geom:Point x="0.5" y="0.9956310679611651"/>

  </transformationPoint>

  </Source>

</source>

<Keyframe index="0"/>

</Motion>


can some one show me how the as3 script in flash should be in order to set the motion to my "ball" mc in the fla?

This topic has been closed for replies.
Correct answer kglad

excellent thank you

now i have new issue:

i have several mc on stage. i need each one of them to be animated when clicking on it. for that i need var which identify the mc.

var my_animator:Animator = new Animator(my_tween_xml, required_mc);


i tried doing it by creating a var

var required_mc:String

and on clicking on each mc :

required_mc=evt.target.name 

but it does not work.

thank you


you can't use a string.  use the movieclip, evt.target not evt.target.name.

(p.s when using the adobe forums, please mark helpful/correct responses, if there are any.)

1 reply

kglad
Community Expert
Community Expert
April 17, 2015

i don't see any motion there but you would use the animator class to apply xml motion:

var anim:Animator=new Animator(yourxml,ball);

anim.play();

udikAuthor
Known Participant
April 17, 2015

kglad please help

all i need is to apply  preset motion called multiple_bounce to movie clip "ball"  on stage using as3.

i understand that i have to export the preset motion as xml and than load it to my script.

i did the following:

var myXML:XML;

var myLoader:URLLoader = new URLLoader();

myLoader.load(new URLRequest("oman3d.xml"));

myLoader.addEventListener(Event.COMPLETE, processXML);

function processXML(e:Event):void {
myXML = new XML(e.target.data);
trace(myXML);
}

what is my mistake?

kglad
Community Expert
Community Expert
April 17, 2015

use:

var myXML:XML;

var anim:Animator;

var myLoader:URLLoader = new URLLoader();

myLoader.load(new URLRequest("oman3d.xml"));

myLoader.addEventListener(Event.COMPLETE, processXML);

function processXML(e:Event):void {
myXML = XML(e.target.data);

animr=new Animator(myXML,ball);

anim.play();


}