Avatar of MackieRSA
MackieRSA
Flag for South Africa asked on

Searching XML file to retrive set of values

Hi There, I am desperately looking for a class/function AS code to search an XML file for a value, find the value and return the child nodes.

So in other words, in be XML sample extract, I need to find an event name and return the Event date, objectives and noted (for example).

I have looked at various samples, but none actually does the trick.

Any help?
<calendar>
 <category>
  <catName>PREPARING THE ORGANISATION FOR BLOCKBUSTER LAUNCH</catName>
  <catColour>0x860038</catColour>
  <Events>
  		<EV name="TEST1">
  			<eventMonts>
  			<Jan>
				<entry>FDA 789</entry>
				<objective>My Objective</objective>
				<desc>My Description</desc>
				<details>My Details</details>
				<attendance>Philip,Gayle</attendance>
				<date>28 Jan 2009</date>
				<venue>My venue</venue>
				<notes>My Notes</notes>
				<hqcontact>Joe Soap IDIOT Mother</hqcontact>
			</Jan>
			<Feb>
				<entry>Feb FDA</entry>
				<objective>Feb Not Now</objective>
				<desc>Feb My Description</desc>
				<details>Feb My Details</details>
				<attendance>Feb Philip,Gayle</attendance>
				<date>Feb 28 Jan 2009</date>
				<venue>Feb My venue</venue>
				<notes>Feb My Notes</notes>
				<hqcontact>Feb Joe Soap HQ Contact Dude</hqcontact>
			</Feb>
			<Mar>
				<entry>Mar FDA</entry>
				<objective>Mar objective</objective>
				<desc>Mar My Description</desc>
				<details>Mar My Details</details>
				<attendance>Mar Philip,Gayle</attendance>
				<date>Mar 28 Jan 2009</date>
				<venue>Mar My venue</venue>
				<notes>Mar My Notes</notes>
				<hqcontact>Mar Joe Soap HQ Contact Dude</hqcontact>
			</Mar>

Open in new window

Adobe Flash

Avatar of undefined
Last Comment
kolotsey

8/22/2022 - Mon
kolotsey

OK, this is quite a difficult question and solution depends on what you want to do with your data when you receive it. But I have a snippet for you. It's just a function that can help.

Usage:

//You should have xml already loaded
var xml_string:String="load your xml yourself or just type it here";
var xml:XML=new XML(xml_string);

//o is the object, that contains attributes, you are interested in.
//For example, here is the name of the event, you are going to select.
var o:Object={name:"TEST1"};
var node:XML;
node=first_xml_node(xml, "EV", o);
trace(node);


//When you select xml node that you need, you should loop through it and read data you need.
temp=node;
if(temp=first_xml_node(temp, "eventMonts")){
    if(temp=first_xml_node(temp, "Jan")){
        if(temp=first_xml_node(temp, "date")){
            trace(temp.nodeValue);
        }
    }
}
function first_xml_node(xml:XML, node_name:String, node_atts:Object):XML{
	var i=0, j;
	var correct:Boolean;
	var temp_node:XML;
	while (i<xml.childNodes.length) {
		if (xml.childNodes[i] == null) {
			//correct xml node not found
			return undefined;
			
		}else if (xml.childNodes[i].nodeName == node_name) {
			if(node_atts){
				//test for correct attributes
				correct=true;
				for(j in node_atts){
					if(xml.childNodes[i].attributes[j] !=node_atts[j]){
						correct=false;
						break;
					}
				}
				if(correct){
					return xml.childNodes[i];
				}else{
					if(temp_node=first_xml_node(xml.childNodes[i], node_name, node_atts)){
						return temp_node;
					}
				}
			}else{
				//attributes are not provided, so we don't need to check them
				return xml.childNodes[i];
			}
		}else{
			if(temp_node=first_xml_node(xml.childNodes[i], node_name, node_atts)){
				return temp_node;
			}
		}
		i++;
	}
	return undefined;
}

Open in new window

MackieRSA

ASKER
Hi kolotsey:

I just want to thank you for your solution. It really cut my existing code by half. I changed the last part of your code slightly by using an array as shon in my code snippet.

Do you perhaps have any reference to how I can store "hidden" values in a movieclip, then when i click on a button inside the movie clip it retrieves the values that i want to pass to the function you gave me?

Let me be more specific. I have dynamically created a calendar by using duplicate movieclip. for each movieclip square that I duplicate I loop through the xml and build the event names etc. What I want to do now, is click on that event (square) and call THAT specific "data" as per your function?

I have read that you could use an event listener to achieve this, and also create an object and give it properties,then store unique values in these properties for retrieval, and in my case reference later. I am not sure if this is teh best way though.

Thanks in advance....

Mackie

		var caldata:Array = temp.childNodes;
		
		//trace("XML DATA+++> : "+caldata);
    	for (icd=0; icd<caldata.length; icd++) {//iterate through each <categorysection> node
			//trace("subcat->: "+subcategories[isc].attributes.name);
			trace("-----------------------------------------------------------------------------");
			trace("Event name: "+caldata[icd].firstChild.childNodes[0].childNodes[0].nodeValue);
			trace("objective name: "+caldata[icd].firstChild.childNodes[1].childNodes[0].nodeValue);
			trace("desc name: "+caldata[icd].firstChild.childNodes[2].childNodes[0].nodeValue);
			trace("details name: "+caldata[icd].firstChild.childNodes[3].childNodes[0].nodeValue);
			trace("attendance name: "+caldata[icd].firstChild.childNodes[4].childNodes[0].nodeValue);
			trace("date name: "+caldata[icd].firstChild.childNodes[5].childNodes[0].nodeValue);
			trace("venue name: "+caldata[icd].firstChild.childNodes[6].childNodes[0].nodeValue);
			trace("notes name: "+caldata[icd].firstChild.childNodes[7].childNodes[0].nodeValue);
			trace("hqcontact name: "+caldata[icd].firstChild.childNodes[8].childNodes[0].nodeValue);
			trace("-----------------------------------------------------------------------------");
		}

Open in new window

kolotsey

I'm sorry, but I don't completely understand you. Do you duplicate movieclips for each event (for each xml node "EV" or other xml node) while you loop through the xml? Or you already have duplicated all needed movieclips and you loop through them?
In both cases you can save data (or even functions) in duplicated movieclips like in objects, and reference that data when you want. But it is very important to use correct relative paths when you reference that data.

//here just generic movieclip created
mc=_root.createEmptyMovieClip("mc-"+_root.getNextHighestDepth(), _root.getNextHighestDepth());
mc.beginFill( 0x000000);
mc.moveTo(0, 0);
mc.lineTo(100, 0);
mc.lineTo(100, 100);
mc.lineTo(0, 100);
mc.lineTo(0, 0);
mc.endFill();
 
//this stuff you should do in your loop
//onRelease will be called when user press movieclip mc
mc.my_data="xml data or other object";
mc.onRelease=function(){
	trace(this);
	trace(this.my_data);
}

Open in new window

All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
MackieRSA

ASKER
I loop through XML and create squares using the duplicate movieclip function.-> dynamically.

Just on the correct reference paths, I am little new to actionscript, and I must tell you I find it very daunting to keep track of the layers, levels and references. :)

I have a dynamic textbox that has a variable that I pass values to (txtheading, variable varheading), and this I can reference easy >>>."...eventToSearch=this._parent.varheading; .."

My problem is that I do not know(Yet), how to create a variable/object on that Square movie clip that can store the values for me..so that when i click on the movieclip (square) it retrieves that unique value stored. In my case I want to stores values;
1) Event Category
2) Event Name
3) Event Month

in a single square . so that when i click on that square i can use those values to lookup data in the XML file (As per your previous function you submitted).



 
I have attached the code that creates the calendar based on my XML.

Regards

Mackie
var currentmonth=0;
var currentcat=0;
var currentrow=0;
var counter=0;
 
var xml:XML = new XML();
xml.ignoreWhite = true;
xml.onLoad = function() {
 
setProperty(square, _x, 0);
setProperty(square, _y, 0);
 
var curY=0;
var curX=0;
var curXWidth=0;
var setWidth=0;
var setHeight=0;
var setSpacer=0;
setSpacerX=0;
 
setCatHeight =20;
setSubCatHeight =20;
setMonthsHeight =60;
 
 
setProperty(square, _height,setCatHeight);
 
var catTextFormat = new TextFormat();
	
	//trace(">>>START BUILDING CALENDAR>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
	
		//===============Loop through the Main Categories=================================	
		var categories:Array = this.firstChild.childNodes;//get the main <category> nodes in a array
		
		setWidth =115;
		
    	for (i=0; i<categories.length; i++) {//iterate through each <categorysection> node
						
			var catname = categories[i].childNodes[0].firstChild.nodeValue;//<categories>
			var catcolours = categories[i].childNodes[1].firstChild.nodeValue;//<entry>
			var cattextcolours = categories[i].childNodes[2].firstChild.nodeValue;//<entry>
			
			//trace("Main Category Name:"+catname+"=====================================");
			//SUPRESS ROW IF CATEGORY IS BLANK
			if(catname=="none"){
				}
			else
				{
				catTextFormat.size = 30;
				catTextFormat.color = cattextcolours;
				catTextFormat.bold = true;
				//catTextFormat.font = "arial";
						
				currentmonth=0;
				
				duplicateMovieClip(square, "csquare"+counter, counter);				 
								
				setProperty("csquare"+counter, _x, 0);
				setProperty("csquare"+counter, _y, (Number(getProperty("csquare"+(counter-1), _y))+Number(getProperty("csquare"+(counter-1), _height))));
			 	setProperty("csquare"+counter, _width,990);
				setProperty("csquare"+counter, _height,setCatHeight);
				
				
				//trace("Cat Y: = (Previous Y("+ Number(getProperty("csquare"+(counter-1), _y))+") + Cur Height ("+Number(getProperty("csquare"+counter, _height))+")) * Row ("+currentrow+")");
				//trace("Category : "+ catname +"  [Counter:"+counter+" |Row: "+currentrow+"]");
					
				
				_level0.ScrollPane1.spContentHolder["csquare"+counter].varheading = catname;
				_level0.ScrollPane1.spContentHolder["csquare"+counter].catName = "PHILIP DATA";
				_level0.ScrollPane1.spContentHolder["csquare"+counter].txtheading.setTextFormat(catTextFormat);
				_level0.ScrollPane1.spContentHolder["csquare"+counter].txtheading._x=0;
				
				//_level0.ScrollPane1.spContentHolder["csquare"+counter].ojSquareData.newProperty = "HELLO THIS IS MY VALUES";
				
				var obj:Object = new Object();
				obj.category = catname;
				obj.subcategory = "none";
				obj.eventname="eventname1";
				obj.monthvalue="Jan";
				
				
							
				colCat = new Color(_level0.ScrollPane1.spContentHolder["csquare"+counter].sqbkg_mc);
				colCat.setRGB(catcolours);
				
				colSquare = new Color(_level0.ScrollPane1.spContentHolder["csquare"+counter].catcolor_mc);
				colSquare.setRGB(catcolours);
				
				
						
				counter = counter+1;
				currentrow = currentrow+1;		
			}
			//===============Loop through SUB CATEGORIES ==========================================
			
		
		var subcategories:Array =  categories[i].childNodes[3].childNodes;//get the main <category> nodes in a array
		
			
    	for (isc=0; isc<subcategories.length; isc++) {//iterate through each <categorysection> node
			//trace("subcat->: "+subcategories[isc].attributes.name);
			setWidth =115;
			
			var subcatname = subcategories[isc].attributes.name;
			
			if(subcatname=="None"){
			}
			else
			{
						
			catTextFormat.size = 30;
			catTextFormat.color = catcolours;
			catTextFormat.bold = true;
			
			duplicateMovieClip(square, "csquare"+counter, counter);				 
				
				setProperty("csquare"+counter, _x, 0);
				setProperty("csquare"+counter, _y, (Number(getProperty("csquare"+(counter-1), _y))+Number(getProperty("csquare"+(counter-1), _height))));
				setProperty("csquare"+counter, _height,setSubCatHeight);
			 	setProperty("csquare"+counter, _width,990);
				
				
				//trace("Cat Y: = (Previous Y("+ Number(getProperty("csquare"+(counter-1), _y))+") + Cur Height ("+Number(getProperty("csquare"+counter, _height))+")) * Row ("+currentrow+")");
				//trace(" >>>Sub Category : "+subcatname+" Counter:"+counter+" Row: "+currentrow);
					
				
				_level0.ScrollPane1.spContentHolder["csquare"+counter].varheading = subcatname;
				_level0.ScrollPane1.spContentHolder["csquare"+counter].txtheading.setTextFormat(catTextFormat);
				_level0.ScrollPane1.spContentHolder["csquare"+counter].txtheading._x=0;
				
				//colCat = new Color(_level0.ScrollPane1.spContentHolder["csquare"+counter].sqbkg_mc);
				//colCat.setRGB(0xFFFFFF);
				
				//colSquare = new Color(_level0.ScrollPane1.spContentHolder["csquare"+counter].catcolor_mc);
				//colSquare.setRGB(0xFFFFFF);
						
				counter = counter+1;
				currentrow = currentrow+1;		
			}
				
				
			//===============Loop through the Events for Categories=================================
					
			var events:Array = subcategories[isc].childNodes[0].childNodes;//get the main <months> nodes in a array
			//trace("XML >> "+events);
			
			//EVENTS VALUES - categories[i].childNodes[2].firstChild.attributes.name
			for (ie=0; ie<events.length; ie++){
				
				setWidth =115;
				
				var eventName =  events[ie].attributes.name;
								
				//trace("events name :"+eventName);
				
				catTextFormat.size = 10;
				catTextFormat.color = 0x000000;
				catTextFormat.bold = false;
			
				duplicateMovieClip(square, "csquare"+counter, counter);				 
				
				setProperty("csquare"+counter, _x, 0);
				setProperty("csquare"+counter, _y, (Number(getProperty("csquare"+(counter-1), _y))+Number(getProperty("csquare"+(counter-1), _height))));
				setProperty("csquare"+counter, _height,setMonthsHeight);
			 	setProperty("csquare"+counter, _width,setWidth);
				
				//if(eventName=="none"){
				//_level0.ScrollPane1.spContentHolder["csquare"+counter].varheading = " ";
				//}
				//else
				//{
					_level0.ScrollPane1.spContentHolder["csquare"+counter].varheading = eventName;
				//}
				_level0.ScrollPane1.spContentHolder["csquare"+counter].txtheading.setTextFormat(catTextFormat);
				_level0.ScrollPane1.spContentHolder["csquare"+counter].txtheading._x=0;
				
				//colCat = new Color(_level0.ScrollPane1.spContentHolder["csquare"+counter].sqbkg_mc);
				//colCat.setRGB(0xFFFFFF);
				
				//colSquare = new Color(_level0.ScrollPane1.spContentHolder["csquare"+counter].catcolor_mc);
				//colSquare.setRGB(0xFFFFFF);
						
				counter = counter+1;
				//currentrow = currentrow+1;		
							
						
			//===============Loop through the MONTHS for the EVENTS for the Categories=================================
				var months:Array = events[ie].childNodes[0].childNodes;//get the main <months> nodes in a array
				
				var startX=0;
				currentmonth = 1;
				
				startX=115;
				
				var month =  events[ie].childNodes[0];
				
				catTextFormat.size = 10;
				catTextFormat.color = 0x000000;
				catTextFormat.bold = false;
											
				for (im=0; im<months.length; im++) {//iterate through each <month> node
				
				setWidth =72;
				
				var evententry = months[im].childNodes[0].firstChild.nodeValue;
				
				//trace("Entry:"+evententry);
					
				duplicateMovieClip(square, "csquare"+counter, counter);				
				
				setProperty("csquare"+counter, _height,setMonthsHeight);
				setProperty("csquare"+counter, _x, (startX));
				setProperty("csquare"+counter, _y, Number(getProperty("csquare"+(counter-1), _y)));
				setProperty("csquare"+counter, _width,setWidth);
				
				if(evententry=="none"){
					catTextFormat.color = 0xFFFFFF;
					}
				else 
				{
					catTextFormat.color = 0x000000;
				}
				
				 _level0.ScrollPane1.spContentHolder["csquare"+counter].varheading = evententry;
				_level0.ScrollPane1.spContentHolder["csquare"+counter].txtheading.setTextFormat(catTextFormat);
				_level0.ScrollPane1.spContentHolder["csquare"+counter].txtheading._x=0;
				
				startX = startX + Number(getProperty("csquare"+counter, _width)+setSpacerX);
				counter = counter+1;
				currentmonth = currentmonth+1;
					
				}
				//currentrow = currentrow+1;
				}
				
								
				}
				
				
			}
			//currentrow = currentrow+1;
	
		};
xml.load("XML/BuildCalendar.xml");
 
//trace(_global.selCat);
stop();

Open in new window

MackieRSA

ASKER
Flash XML calendar
MackieRSA

ASKER
FLASH XML Calendar
xmlcalendar-flash.jpg
âš¡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
SOLUTION
kolotsey

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
MackieRSA

ASKER
Thanks for the quick reply..

Please forgive me for being so backwards.. in your code sample...

var obj:Object = new Object();
obj.category = catname;
obj.subcategory = "none";
obj.eventname="eventname1";
obj.monthvalue="Jan";
 
//copy created object to duplicated movieclip
             dupmc=this["csquare"+counter];
             dupmc.my_data=new Object();
             var ii;
             
              for(ii in obj){
             dupmc.my_data[ii]=obj[ii];
       }

I am not sure what dupmc represents? Is dupmc a new movieclip that I need to reference?

I think I understand what you are doing, just that in my square movieclip.....

when i run for(i in this.my_data){
    trace(i+"="+this.my_data[i]);
  }
}
 gives me an undefined...

 I get undefined.. I can however access teh "variables on the movicelip" as this_parent.variable names...


if I do a trace(this._parent) >>>

I get  _level0.ScrollPane1.spContentHolder.csquare47 (wgich is the level that I need to acces my "data".

i can not access dupmc. ?

Can you clarify.

Thanks again in advance..





kolotsey

In my code dupmc=this["csquare"+counter] is the movieclip that you've just duplicated with duplicateMovieClip().
When you call 'property setter' like
setProperty("csquare"+counter, _x, 0);
in your code, you can use
dupmc["csquare"+counter]._x=0;
instead.

You get undefined because you call this.my_data property from movieclip, that included into square movieclip (your dupmc). This is that I said earlier about proper relative paths.  Try this:
for(i in this._parent.my_data){
    trace(i+"="+this._parent.my_data[i]);
  }
}
MackieRSA

ASKER
I see...

So from what I understand is that every time you duplicate a movie clip you load it into higher levels, or is it lower levels?

I think I am going mad. I am not sure what I am doing wrong. I tried what you suggested but still giving me a "undefined".

Ok so very quickly to tell you about my levels.

If I look at the Action script window where my code is in for the square click event. I see teh "levels in the main stage heading as....>> Scene 1, square mc,month anim.

Below is my code for retrieving the obj data. As you can see I am having problems even passing values to the dynamic text fields...

_level0.detail_mc.varheading = caldata[icd].firstChild.childNodes[0].childNodes[0].nodeValue;

So.. It seems that my problem could be proper relative paths.

Thanks for helping me I appreciate it.


I have setup a link to the flash fla, if you are interested in looking at looking into my problem.

www.ipx-soft.com/Files/XMLCalendarMain.zip




on (release) {
		//var eventToSearch=this._parent.varheading;
		trace(this._parent);
		trace(this);
					
		var i;
		
		for(i in this._parent.my_data){
    			trace(i+"="+this._parent.my_data[i]);
  			}
		//}
		
	
	
var xml:XML=new XML(xml_string);
xml.ignoreWhite=true;
xml.load("XML/BuildCalendar.xml")
xml.onLoad = xml_handler;
 
// executes when xml file has loaded (used as MAIN function)
function xml_handler(success)
{
  if (success==true){
	  
			
		//o is the object, that contains attributes, you are interested in.
		//For example, here is the name of the event, you are going to select.
		//var o:Object={name:"TEST7"};eventToSearch
		var o:Object={name:eventToSearch};
		var node:XML;
		node=first_xml_node(xml, "EV", o);
		//trace("Node-->"+node);
 
  		
 
 
		//When you select xml node that you need, you should loop through it and read data you need.
		temp=node;
		
		var caldata:Array = temp.childNodes;
		
		//trace("XML DATA+++> : "+caldata);
    	for (icd=0; icd<caldata.length; icd++) {//iterate through each <categorysection> node
			//trace("subcat->: "+subcategories[isc].attributes.name);
			trace("-----------------------------------------------------------------------------");
			
			myColorObject = new Color(_root.mcdetail.detail_mc.infocolor);
			myColorObject.setRGB(0x000000);
 
			trace("Event name: "+caldata[icd].firstChild.childNodes[0].childNodes[0].nodeValue);
			_level0.detail_mc.varheading = caldata[icd].firstChild.childNodes[0].childNodes[0].nodeValue;
			
			//_level0.detail_mc.infocolor;
			
			trace("objective name: "+caldata[icd].firstChild.childNodes[1].childNodes[0].nodeValue);
			_level0.detail_mc.varobj = caldata[icd].firstChild.childNodes[1].childNodes[0].nodeValue;
 
			trace("desc name: "+caldata[icd].firstChild.childNodes[2].childNodes[0].nodeValue);
			_level0.detail_mc.vardesc =caldata[icd].firstChild.childNodes[2].childNodes[0].nodeValue;
			
			trace("details name: "+caldata[icd].firstChild.childNodes[3].childNodes[0].nodeValue);
			_level0.detail_mc.vardetail =caldata[icd].firstChild.childNodes[3].childNodes[0].nodeValue;
			
			
			trace("attendance name: "+caldata[icd].firstChild.childNodes[4].childNodes[0].nodeValue);
			_level0.detail_mc.varattend =caldata[icd].firstChild.childNodes[4].childNodes[0].nodeValue;
			
			trace("date name: "+caldata[icd].firstChild.childNodes[5].childNodes[0].nodeValue);
			_level0.detail_mc.vardate =caldata[icd].firstChild.childNodes[5].childNodes[0].nodeValue;
			
			trace("venue name: "+caldata[icd].firstChild.childNodes[6].childNodes[0].nodeValue);
			_level0.detail_mc.varvenue =caldata[icd].firstChild.childNodes[6].childNodes[0].nodeValue;
			
			trace("notes name: "+caldata[icd].firstChild.childNodes[7].childNodes[0].nodeValue);
			_level0.detail_mc.varnotes =caldata[icd].firstChild.childNodes[7].childNodes[0].nodeValue;
			
			trace("hqcontact name: "+caldata[icd].firstChild.childNodes[8].childNodes[0].nodeValue);
			_level0.detail_mc.varcontact =caldata[icd].firstChild.childNodes[8].childNodes[0].nodeValue;
			
			trace("-----------------------------------------------------------------------------");
			_root.gotoAndPlay(3);
		}
		
  }
  else{
	trace("...error loading xml file");
	break;
  }
}
 
			
 
function first_xml_node(xml:XML, node_name:String, node_atts:Object):XML{
		
        var i=0, j;
        var correct:Boolean;
        var temp_node:XML;
        while (i<xml.childNodes.length) {
			
                if (xml.childNodes[i] == null) {
						trace("correct xml node not found");
                        //correct xml node not found
                        return undefined;
                        
                }else if (xml.childNodes[i].nodeName == node_name) {
                        if(node_atts){
                                //test for correct attributes
								//trace("test for correct attributes");
                                correct=true;
                                for(j in node_atts){
                                        if(xml.childNodes[i].attributes[j] !=node_atts[j]){
                                                correct=false;
                                                break;
                                        }
                                }
                                if(correct){
                                        return xml.childNodes[i];
                                }else{
                                        if(temp_node=first_xml_node(xml.childNodes[i], node_name, node_atts)){
                                                return temp_node;
                                        }
                                }
                        }else{
                                //attributes are not provided, so we don't need to check them
								trace("attributes are not provided, so we don't need to check them");
                                return xml.childNodes[i];
                        }
                }else{
                        if(temp_node=first_xml_node(xml.childNodes[i], node_name, node_atts)){
                                return temp_node;
                        }
                }
                i++;
        }
        return undefined;
	}
}

Open in new window

Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
MackieRSA

ASKER
_level0.ScrollPane1.spContentHolder.csquare53
_level0.ScrollPane1.spContentHolder.csquare53.square_mc
0=undefined
-----------------------------------------------------------------------------
Event name: FDA 789
objective name: My Objective
desc name: My Description
details name: My Details
attendance name: Philip,Gayle
date name: 28 Jan 2009
venue name: My venue
notes name: My Notes
hqcontact name: Joe Soap HQ Contact Dude
-----------------------------------------------------------------------------
_level0.detail_mc

forgot to add this OUTPUT I get when I run my code...
SOLUTION
kolotsey

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
âš¡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
MackieRSA

ASKER
Hi,

I copied the trace code after the create object code and commented out the Trace this as it hangs up my flash due to the fact that it loads the XML file.

If I put the trace(this); above the XML Load function it returns >>> _level0.ScrollPane1.spContentHolder.

                  
                        var obj:Object = new Object();
                        obj.category = catname;
                        obj.subcategory =subcatname;
                        obj.eventname=eventName;
                        obj.monthvalue=currentmonth;
 
                        //copy created object to duplicated movieclip
                        dupmc=this["csquare"+counter];
                        dupmc.my_data=new Object();
                        
                        var ii;
                        for(ii in obj){
                                dupmc.my_data[ii]=obj[ii];
                              trace("Data :" +obj[ii]);
                              
                              }
                              //After copying object data, add little more debugging:
                              //trace("instance: "+this+", duplicated obj: "+dupmc);
                              //trace("instance: "+this+", duplicated obj: ");
                              //Check the object you've just copied really exists:
                              trace("copied object:"+dupmc);
                              for(ir in dupmc.my_data){
                                trace(ir+"="+dupmc[ir]);
                              }
                              trace("--------------------------------");            
                        

>>>>>>>>>>>>>>
I get an undefined for :       trace("copied object:"+dupmc);
                              for(ir in dupmc.my_data){
                                trace(ir+"="+dupmc[ir]);
                              }


Data :0
Data :Congress
Data :None
Data :PREPARING THE ORGANISATION FOR BLOCKBUSTER LAUNCH
copied object:undefined
--------------------------------

It seems that it does nto exists.

MackieRSA

ASKER
Just my 2 cents worth here...

could it not be that the code snippet ...

                       dupmc=this["csquare"+counter];

>>this<< refers to the XML data as this snippet and section executes IN the Load XML section/function?

âš¡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
MackieRSA

ASKER
When I use>>

dupmc=["csquare"+counter];
                        dupmc.my_data=new Object();
                        
                        var ii;
                        for(ii in obj){
                                dupmc.my_data[ii]=obj[ii];
                              trace("Data :" +obj[ii]);
                              
                              }
                              //After copying object data, add little more debugging:
                              //trace("instance: "+this+", duplicated obj: "+dupmc);
                              //trace("instance: "+this+", duplicated obj: ");
                              //Check the object you've just copied really exists:
                              trace("copied object:"+dupmc);
                              
                              var ir=0;
                              for(ir in dupmc.my_data){
                                trace(ir+"="+dupmc[ir]);
                              }

I get Copied object >>csquare13..

_level0.ScrollPane1.spContentHolder
Data :PREPARING THE ORGANISATION FOR BLOCKBUSTER LAUNCH
copied object:csquare13
category=undefined
--------------------------------
SOLUTION
kolotsey

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
âš¡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
MackieRSA

ASKER
ok just tried it now...

returns... :(

Data :PREPARING THE ORGANISATION FOR BLOCKBUSTER LAUNCH
copied object: _level0.ScrollPane1.spContentHolder.csquare13
category=undefined
--------------------------------

Still undefined...
//copy created object to duplicated movieclip
				//dupmc=["csquare"+counter];
				dupmc=_level0.ScrollPane1.spContentHolder["csquare"+counter];
				dupmc.my_data=new Object();
				
				var ii;
				for(ii in obj){
  					dupmc.my_data[ii]=obj[ii];
					trace("Data :" +obj[ii]);
					
					}
					//After copying object data, add little more debugging:
					//trace("instance: "+this+", duplicated obj: "+dupmc);
					//trace("instance: "+this+", duplicated obj: ");
					//Check the object you've just copied really exists:
					trace("copied object: "+dupmc);
					
					var ii=0;
					for(ii in dupmc.my_data){
  					trace(ii+"="+dupmc[ii]);
					}

Open in new window

MackieRSA

ASKER
I exported my CS3 version to Flash 8.. if you keen to check it out.

www.ipx-soft.com/Files/XMLCalendarMain_ver8.zip

Thanks as always!!
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
SOLUTION
kolotsey

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
âš¡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
MackieRSA

ASKER
kolotsey: = THE MAN!!!!

Output>>>>

_level0.ScrollPane1.spContentHolder
Data :PREPARING THE ORGANISATION FOR BLOCKBUSTER LAUNCH
copied object:csquare13
category=PREPARING THE ORGANISATION FOR BLOCKBUSTER LAUNCH

So, I should be able to use above in click event and reference as per above?
SOLUTION
kolotsey

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
âš¡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
MackieRSA

ASKER
And to confirm?

I should be able to execute the below cose after squares have been built from >>_level0.ScrollPane1.spContentHolder.csquare19.square_mc<<

on (release) {
      
            //trace(this._parent);
            //trace(this);
                              
            var ii=0;
            for(ii in this._parent.my_data){
                  trace(ii+"="+this._parent.my_data[ii]);
            }

Soem feedback...

When i click on a square,, I get no data.. I presume its again the way I am referencing dupmc?

Sorry for questions but I am almost there!

Mackie
SOLUTION
kolotsey

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
âš¡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
ASKER CERTIFIED SOLUTION
MackieRSA

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
âš¡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
MackieRSA

ASKER
It works!!!  

Thank you VERY much for support.

Mackie
âš¡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
kolotsey

You are welcome.
MackieRSA

ASKER
Hi kolotsey:,

I hope you dont mind my asking... but just going back tgo our discussion on your code...


"................var o:Object={name:eventName};
      var node:XML;
      node=first_xml_node(xml, "EV", o);...."

IS it at all possible to START at the part level node of "EV"?

I am trying to use the removeNode() property to remove an event,

Thanks in advance!!

Mackie
MackieRSA

ASKER
ooppss I meant to say PARENT NODE (one up)..and not "....part level node.."
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
kolotsey

It is possible to start from any level.
MackieRSA

ASKER
I need (in my flash) app to delete an event.

I am trying to use the removeNode syntax to remove an EVENT in my XML.

var o:Object={name:eventName};
      var node:XML;
      node=first_xml_node(xml, "EV", o);
      //trace(node.parent);
      pnode = node.parentNode;

    pnode.firstChild.removeNode();

But this does not work. Only if I use the firstChild.removeNode(); at the current EVENT level does it delete a Child node of event and not the whole event itself.
as always appreciate your help.

Mackie
kolotsey

I tried your example and got xml without removed child node. This works.
var o:Object={name:eventName};
var node:XML;
node=first_xml_node(xml, "EV", o);
pnode = node.parentNode;
pnode.firstChild.removeNode(); //check that here you get exact child node: trace(pnode.firstChild);
trace(xml); //  <--- xml without EV node
âš¡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.