Ask a Question related to Macromedia Flash Data Integration, Design and Development.
-
crisbosch #1
XML node variable
HI
I'm trying to access RootNode in the code from anywhere in the timeline. I
assigned a value in the loadFile function but when I try to access it from
outside this function I get "undefined". How can I have this easily accessible
from anywhere in the code? I know _global.RootNode will not work for XMLnode
types.
Thanks!
// Initialize variables
var selectedUnitSize:String = "studio";
var selectedFloor:Number;
var matchingFloors:Array;// for Select a floor component
var matchingUnits:Array;// for keyplan component
var RootNode:XMLNode;
// Creates XML Object
var floorplansXML:XML = new XML();
floorplansXML.ignoreWhite = true;
floorplansXML.onLoad = loadFile;
floorplansXML.load("xml/floorplans.xml");
function init(){
loadAllFloorplans();
}
// Accesses XML data from the XML object
function loadFile(success:Boolean):Void {
if (success) {
RootNode = this.firstChild;
trace(RootNode);
} else {
trace("Error in loading XML file");
}
};
// Loads selected floorplan data from XML file
function loadAllFloorplans(selectedUnitSize) {
//trace(RootNode);
for (var i:Number = 0; i<RootNode.childNodes.length; i++) {
nodeUnitSize = RootNode.childNodes[i].attributes.unitsize;
if (nodeUnitSize == selectedUnitSize) {
matchingUnits.push(RootNode.childNodes[i]);
break;
}
}
};
init();
crisbosch Guest
-
+Data (node)
Can anyone tell me what It takes to get the +Data node and a few other components in the component window. On startup I see the nodes there but in a... -
XML node inserting
Hi is it possible use the function insertChildAfter() (or another useful function) to insert a node under the root node? For example, suppose... -
tree node
Hi, I have a tree with say parent1 and child1 . To access the label of either child or parent I am using... -
ANNOUNCE: XUL-Node 0.02
NAME XUL-Node - server-side XUL for Perl SYNOPSIS package XUL::Node::Application::HelloWorld; # XUL-Node Hello World use XUL::Node; use... -
XML append node without DOM
Note: I'm not using the xmldom functions because I need to maintain compatibility with current typical installs. Say I have an XML file like this... -
Noelbaland #2
Re: XML node variable
Hello there,
Don't use the init function as you lose the scope to your RootNode variable.
You should instead call the loadAllFloorplans function from inside the loadFile
function.
if(success){
RootNode = this.firstChild;
// Pass in the selectedUnitSize variable as a parameter here
loadAllFloorplans(selectedUnitSize);
}
and then in the loadAllFloorPlans function set a different name for the
parameter and strict type it to Number.
function loadAllFloorPlans(unitSize:Number) {
// Use unitSize throughout the rest of your script
for (var i:Number = 0; i<RootNode.childNodes.length; i++) {
nodeUnitSize = RootNode.childNodes[i].attributes.unitsize;
if (nodeUnitSize == unitSize) {
matchingUnits.push(RootNode.childNodes[i]);
break;
}
}
};
Noelbaland Guest



Reply With Quote

