Changing the position of a Flash object with external data.
March 9, 2006 10:18 AM   Subscribe

How can I change the position of an object in a Flash file with data from an external (XML) file?

I need to change the position of an object in my Flash movie based on changes in external data. I have an XML file with the data, and I know how to get the XML into Flash. How do I tell Flash to change the object's position?
posted by kirkaracha to Computers & Internet (5 answers total)
 
What sort of data is it? Are you trying to pass variables into Flash that will determing X/Y coords?

I can probably help (professional Flasher), but I need more details...
posted by kaseijin at 10:23 AM on March 9, 2006


Best answer: Say your XML node for the object is this:
<cities>
<city x="33" y="320" name="New York" clip="nyc_mc" />
<city x="98" y="71" name="San Francisco" clip="sf_mc" />
<city x="420" y="64" name="Dallas" clip="dal_mc" />
</cities>

Once you've loaded the XML into flash and you've parsed it you'll need something like this to move the movieClips you want to where you want:

// parsing the above XML down to all the city nodes
// being called cityNode in actionscript 1.0
// (for compatibility's sake) inside a for loop:
for (i = 0; i < citynodes; i ++) {br> var obj_mc = eval(cityNode[i].attributes.clip);
obj_mc._x = cityNode[i].attributes.x;
obj_mc._y = cityNode[i].attributes.y;
}

Hope that helps.
posted by DragonBoy at 10:35 AM on March 9, 2006


Woops, that's supposed to read:

for (i = 0; i < citynodes.length; i ++) {
var obj_mc = eval(cityNode[i].attributes.clip);
obj_mc._x = cityNode[i].attributes.x;
obj_mc._y = cityNode[i].attributes.y;
}
posted by DragonBoy at 10:36 AM on March 9, 2006


Response by poster: Thanks!
posted by kirkaracha at 1:50 PM on March 9, 2006


I don't know if flash is a requirement, but I've seen people do similar stuff with XML and Scalable Vector Graphics.
posted by kookywon at 3:00 PM on March 9, 2006


« Older What to do in Lyon?   |   Newsreaders Newer »
This thread is closed to new comments.