Copy link to clipboard
Copied
How can I specify height and width values of a movie clip using external XML file? User needs to change values of a particular movie clip [rectangular shape] using xml file.
How can I do that?
Thanks.
1 Correct answer
With what part of the using an xml file to store and retrieve data are you having difficulty? Do you know how to write the height and width values as data in an xml file? It could be something as simple as the following...
<mc_dimensions>
<mc_height>200</mc_height>
<mc_width>200</mc_width>
</mc_dimensions>
Copy link to clipboard
Copied
With what part of the using an xml file to store and retrieve data are you having difficulty? Do you know how to write the height and width values as data in an xml file? It could be something as simple as the following...
<mc_dimensions>
<mc_height>200</mc_height>
<mc_width>200</mc_width>
</mc_dimensions>
Copy link to clipboard
Copied
Thanks for the xml code. How to define it in Flash Actionscript 3 so that it can retrieve height & width values from XML.
I have a rectangular called "Box1_mc" and I would like to manipulate the height & width values of that "Box1_mc" with XML file.
I have a sample code but don't know how to modify it to get my problem resolved.
function fileLoaded(e:Event):void
{
xmlData = XML(loader_ul.data);
m_txt.text = xmlData.March;
a_txt.text = xmlData.April;}
How to modify this code to get height & width values from XML file?
Regards.
Copy link to clipboard
Copied
For the xml data file content I showed it could be as simple as:
var xmlData:XML;
function fileLoaded(e:Event):void
{
xmlData = XML(e.target.data);
m_txt.text = xmlData.mc_width;
a_txt.text = xmlData.mc_height;
}
Copy link to clipboard
Copied
Following Ned's xml data, this code would work as well:
var mc_dimensions_XML:XML;
var mc_dimensions_width:Number;
var mc_dimensions_height:Number;
var mc_dimensions_XMLLoader:URLLoader = new URLLoader();
mc_dimensions_XMLLoader.load(new URLRequest("widthHeight.xml"));
mc_dimensions_XMLLoader.addEventListener(Event.COMPLETE, mc_dimensions_processXML);
function mc_dimensions_processXML (e:Event):void
{
mc_dimensions_XML = new XML(e.target.data);
mc_dimensions_width = mc_dimensions_XML.mc_width;
mc_dimensions_height = mc_dimensions_XML.mc_height;
trace("mc_dimensions_width = "+ mc_dimensions_width);
trace("mc_dimensions_width = "+ mc_dimensions_height);
Box1_mc.width = mc_dimensions_width;
Box1_mc.height = mc_dimensions_height;
}

