Search tutorials

Creating 'Track-Points' in Adobe After Effects and using them in a Flash Animation - Page 4
Step 3: Using the XML with ActionScript
Basic stuff: placing your FLV on stage
-File -> New... (CTRL+N) -> Flash Document (so, just what you would do normally) -> Ok.
-Click on frame1 on layer1 to select it.
-Window -> Components (CTRL+F7) -> FLV Playback - Player 8 -> FlvPlayback -> doubleclick -> you can exit the components window if you please.
-Leftclick on the component.
-Activate the parameters tab.
-Change the 'contentPath' to the location of your flv. Make sure the 'Match source file dimensions' box is checked.
-Change the 'skin' to 'none' or what you prefer.

-Activate the Properties Tab.
-Modify -> Document... (CTRL+J) -> change the default demensions: W(idth) and H(eight) to the values inside the properties window. -> Change the Frame Rate to the same of your movie, ex. 25 fps -> Ok
-Change both the X and the Y in the properties tab to 0.
Scripting
-Select frame1 on layer1.-Window -> Actions (F9) -> paste alle script
//create an empty var, ready for XML content. var xmlContent:XML = new XML(); //ignore empty elements likeinstead of //formatting them to etc. xmlContent.ignoreWhite = true; //the first frame is the first frame where the movie starts playing.. //so start with index 0 i = 0; //every frame in the flash file is a frame of the flv movie because we synched those //so we can change the cooords of the animation in refference //to the coords in the xml file each time the flash file enters a new frame onEnterFrame = function () { //The flv might be playing before the xml is loaded but shit happens if (xmlIsLoaded == true) { //if the animation is out of synch with the flv.. offset = -Math.round(25/2); //assign the framenumber to a variable newNumber = xmlContent.firstChild.childNodes[3].firstChild.childNodes[i+offset].childNodes[0].firstChild.firstChild.nodeValue; //assign the new x cooord to a variable newX = xmlContent.firstChild.childNodes[3].firstChild.childNodes[i+offset].childNodes[1].firstChild.firstChild.nodeValue; //assign the new y cooord to a variable newY = xmlContent.firstChild.childNodes[3].firstChild.childNodes[i+offset].childNodes[2].firstChild.firstChild.nodeValue; //if there are still framenumbers in the xml file then actualy give the movieClip it's new position if (newNumber != undefined) { theMovingObject._x = newX; theMovingObject._y = newY; //Track(newNumber+","+newX+","+newY); } } //Increment the number with one for each time a frame is entered. i++; }; //If the xml file is loaded into flash then... xmlContent.onLoad = function(loooaded:Boolean) { if (xmlContent.hasChildNodes()) { //Only start doing things with the xml when it's loaded already, //else we're only going to get a big pile of nonesence and maybe bugs. xmlIsLoaded = true; //As you might have seen or not, there is a pile of useless thingies //in the xml file, so when the xml is loaded //get rid of the useless elements in it. xmlContent.firstChild.childNodes[3].firstChild.firstChild.removeNode(); xmlContent.firstChild.childNodes[3].firstChild.firstChild.removeNode(); xmlContent.firstChild.childNodes[3].firstChild.firstChild.removeNode(); xmlContent.firstChild.childNodes[3].firstChild.firstChild.removeNode(); xmlContent.firstChild.childNodes[3].firstChild.firstChild.removeNode(); xmlContent.firstChild.childNodes[3].firstChild.firstChild.removeNode(); xmlContent.firstChild.childNodes[3].firstChild.firstChild.removeNode(); xmlContent.firstChild.childNodes[3].firstChild.firstChild.removeNode(); xmlContent.firstChild.childNodes[3].firstChild.lastChild.removeNode(); xmlContent.firstChild.childNodes[3].firstChild.lastChild.removeNode(); xmlContent.firstChild.childNodes[3].firstChild.lastChild.removeNode(); xmlContent.firstChild.childNodes[3].firstChild.lastChild.removeNode(); } else { //If the file is unreadable, then let me know //there is a big chance that you missed my note earlier in my tutorial //about that new-versions-of-excel xml thingy. Track("XML loading-errorblah"); } }; //Start loading the xml file wherein we'd put all //coordinates and stuff from After Effects xmlContent.load("07positions.xml");
-Insert -> New symbol(CTRL+F8) -> make it available for actionscript.

-Make sure it also has the instance name 'theMovingObject'.

And that's it! Sort of... =) hope it was of 'some' use.
Martin
» Level Intermediate |
Added: 2007-05-02 Rating: 5.4 Votes: 5 |
» Author |
Digital Media Design Student |
» Download |
Download the files used in this tutorial. |
Download (2215 kb) |
» Forums |
More help? Search our boards for quick answers! |