Hi, I figured out that if I hardcode the values things work, but if I use values from variables, nothing works.
When I trace the variable values, they trace properly, then why cant I use them dynamically??? Thanks for any help. Sajid On 6/12/06, Sajid Saiyed <[EMAIL PROTECTED]> wrote:
Ok, I had forgotten ingoreWhite, but still the code is not drawing anything :( Sajid On 6/12/06, Sajid Saiyed <[EMAIL PROTECTED]> wrote: > Hi Abdul, > Thanks for your reply. > > I am still stuck because after trying your suggestion, if I do: > > layout_xml.firstChild.childNodes.length > > I get 5 instead of 2. > > Here is my revised code: > /////////////////////////////////// > > RootNodes = []; > SubRootNodes = []; > tempArray = []; > LoadXML("layout.xml"); > var layout_xml:XML = new XML(); > layout_xml.onLoad = mx.utils.Delegate.create (this, onXMLLoad); > layout_xml.load("layout.xml"); > function onXMLLoad (success:Boolean) { > trace(layout_xml.firstChild.childNodes[0]); > > 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(); > > > } > > function tracer() { > > num = 0; > for (var i = 0; i<tempArray.length; i++) { > trace("SAJID: "+tempArray[i]); > Name = tempArray[i][0]; > Width = tempArray[i][1]; > Height = tempArray[i][2]; > XPos = tempArray[i][3]; > YPos = tempArray[i][4]; > num++; > _root.createEmptyMovieClip("box"+num, _root.getNextHighestDepth()); > if (num == 1) { > trace("SAJSA: "+_root["box"+num]); > _root["box"+num].lineStyle(5, 0xFF00FF, 100); > _root["box"+num].moveTo(XPos, YPos); > _root["box"+num].lineTo(Width, YPos); > _root["box"+num].lineTo(Width, Height); > _root["box"+num].lineTo(XPos, Height); > _root["box"+num].lineTo(XPos, YPos); > } > } > > } > > //////////////////////////////////////////////// > > Thanks > Sajid > > On 6/12/06, Abdul Qabiz <[EMAIL PROTECTED]> wrote: > > It's scope issue? I guess, tracer () is not found or executed in wrong > > scope. > > > > Use Delegate to fix this:- > > > > > > layout_xml.onLoad = mx.utils.Delegate.create (this, onXMLLoad); > > > > function onXMLLoad (success:Boolean) { > > > > ........... > > > > } > > > > > > Check, if that fixes the problem. > > > > -abdul > > > > > > > > On 6/12/06, Sajid Saiyed <[EMAIL PROTECTED]> wrote: > > > > > > 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 > > > _______________________________________________ > > > Flashcoders@chattyfig.figleaf.com > > > 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 > > > > > _______________________________________________ > > Flashcoders@chattyfig.figleaf.com > > 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 > > >
_______________________________________________ Flashcoders@chattyfig.figleaf.com 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