Hi All,
I am faced with a strange problem.
I have a XML which I am loading into the Flash movie and then iterate
through it and store values in an array.
Then I run through the array and want to drag BOXES using the drawing api.
Here is my Flash Code:
---------------------------------
//-------------- CODE START -------------- //
RootNodes = [];
SubRootNodes = [];
tempArray = [];
LoadXML("layout.xml");
function LoadXML(myXMLPath) {
var layout_xml:XML = new XML();
layout_xml.ignoreWhite = true;
layout_xml.onLoad = function(success:Boolean) {
trace("success: "+success);
trace("loaded: "+layout_xml.loaded);
trace("status: "+layout_xml.status);
if (success) {
nodeLen = layout_xml.firstChild.childNodes.length;
trace("nodeLen : "+nodeLen);
for (var i = 0; i<nodeLen; i++) {
RootNodes.push(layout_xml.firstChild.childNodes[i].nodeName);
var node_xml =
layout_xml.firstChild.childNodes[i].childNodes;
rootnodeLen = node_xml.length;
for (var j = 0; j<rootnodeLen; j++) {
tempValues = [];
for (var k = 0;
k<node_xml[j].childNodes.length; k++) {
tempValues.push(node_xml[j].childNodes[k].firstChild);
}
tempArray.push(tempValues);
trace("------------");
}
}
tracer()
}
};
layout_xml.load(myXMLPath);
}
function tracer() {
num = 0;
for (var i = 0; i<tempArray.length; i++) {
trace("Array trace: "+tempArray[i]);
var Name = tempArray[i][0];
var Width = tempArray[i][1];
var Height = tempArray[i][2];
var XPos = tempArray[i][3];
var YPos = tempArray[i][4];
num++;
trace("WIDTH: "+Width+" HEIGHT: "+Height+" XPOS: "+XPos+" YPOS:
"+YPos);
var newMC = _root.createEmptyMovieClip("box"+num,
_root.getNextHighestDepth());
trace("New MC: "+newMC);
newMC.lineStyle(5, 0xff3300, 100);
newMC.moveTo(XPos, YPos);
newMC.lineTo(Width, YPos);
newMC.lineTo(Width, Height);
newMC.lineTo(XPos, Height);
newMC.lineTo(XPos, YPos);
}
}
//-------------- CODE END -------------- //
Here is my "layout.xml" XML file:
-----------------------
//-------------- CODE START -------------- //
<root>
<LayerOne>
<asset>
<name>somename0.bmp</name>
<width>100</width>
<height>20</height>
<xPos>50</xPos>
<yPos>30</yPos>
</asset>
<asset>
<name>somename1.bmp</name>
<width>200</width>
<height>10</height>
<xPos>50</xPos>
<yPos>70</yPos>
</asset>
</LayerOne>
<LayerTwo>
<asset>
<name>somename2.bmp</name>
<width>150</width>
<height>30</height>
<xPos>50</xPos>
<yPos>100</yPos>
</asset>
</LayerTwo>
</root>
//-------------- CODE END -------------- //
The problem is, All the traces are coming fine but the movie does not
draw anything :((
Any idea why its behaving like this?
Is the XML causing the problem or the createEmptyMovieClilp() causing
this problem.
I also tried:
////////////////
trace("success: "+success);
trace("loaded: "+layout_xml.loaded);
trace("status: "+layout_xml.status);
///////////////
Everything looked OK.
Any suggestion or pointing to an error in my code is appreciated.
Thanks
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com