Internet Commerce

Partners & Affiliates

Developer Channel


Featured Flash FLA
Gallery Downloads 11401 Flash Movies | 5 New Flash Movies Added
What's New | Top 100

Featured FLA

»  Author: Nick Kouvaris
»  Title: Znax
»  Description: Znax is a board game. Click 4 tiles of the same color and form squares as big as you can. You will erase all the tiles inside the square and collect points. Get maximum score if you make a square with game edges.
»  More by: Nick Kouvaris


Random FLAs | Add Flash Movie
Featured Flash Site
Gallery Downloads 4941 Flash Sites | 1 New Flash Links
What's New | Top 100 Flash Site

Featured Site

»  Author Agence WOP Digital Agency
»  Title: Electricdrum
»  Description: French WOP Agency, 3D websites, Flash (Papervision, Away 3D), event or institutional projects. The agency operates on all digital projects: consulting, design, graphic design, development, online communication. The WOP agency follows you on the implementation of original, creative and optimized digital projects.


Random Links | Add your own Flash Related Links
Flash Tutorials 1481 Tutorials 7 New Tutorials Added!
What's New | Top100

» How To Make A Simple Animation Using Christmas Clips
» Simple Step by step flash game tutorial Spot the diffrence
» How To Make A Moving Text Slide
» Create Flash Banner With Text Float Effect
» How To Make Zoo Photos Slideshow
» How To Make A Dolphin Photos Slideshow
» How To Make A Fathers Day Slideshow
» How To Make A Transparent Background of Your Flash File
» Create Flash Banner With Text Disco Light Effect Today we will introduce you a Text Disco Light eff
» Unknown Tag: Title10
Random Tutorial | Add Site


Tutorials Home What's New Top Rated Submit myTutes Random!

Search Tutorials


Categories Creating 'Track-Points' in Adobe After Effects and using them in a Flash Animation
Author: Martin Overmars | Website: http://www.56k.nl/ |

 
Page 4
«prev 1 2 3 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 like  instead 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");
-Create a movieclip called 'theMovingObject' with your object in it. Like the icecube or the helmet with the propellor on it in the examples I brought up earlier.
-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

«prev 1 2 3 4

» Level Intermediate

Added: : 2007-05-02
Rating: 10.00 Votes: 2
Hits: 996
» Author
Digital Media Design Student
» Download
Download the files used in this tutorial.
Download (2215 kb)
Get conversion and unzipping tools for PC and Mac here!

» Forums
More help? Search our boards for quick answers!

Please rate this tutorial, 10 is the top rating, you can also click the comments link to read/write a review.
10 9 8 7 6 5 4 3 2 1
Read or Post Comments