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?
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?
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
<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
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
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
posted by kookywon at 3:00 PM on March 9, 2006
This thread is closed to new comments.
I can probably help (professional Flasher), but I need more details...
posted by kaseijin at 10:23 AM on March 9, 2006