Flash CS3 AS3 Error Combo Box

I have the following attached file, And It work, but I tried to Added to another file and I get the an error see code snipet
TypeError: Error #1010: A term is undefined and has no properties.
                at MethodInfo-415()
                at MethodInfo-414()
                at flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()
                at flash.events::EventDispatcher/dispatchEvent()
TypeError: Error #1010: A term is undefined and has no properties.
                at MethodInfo-415()
                at flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()
                at flash.events::EventDispatcher/dispatchEvent()
                at fl.controls::ComboBox/fl.controls:ComboBox::onListChange()
                at flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()
                at flash.events::EventDispatcher/dispatchEvent()
                at fl.controls::SelectableList/fl.controls:SelectableList::handleCellRendererClick

Open in new window

LVL 10
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ranhellAuthor Commented:
attached is the XLM file
Running the files you provided, I don't get any error.  You would need to attach the .FLA that is throwing the error for me to give you better information.
actionscript.org had some hints on what all this MethodInfo stuff is about (http://www.actionscript.org/forums/showthread.php3?t=183670).  Based on that and on the error you pasted, I can tell you that you have an "anonymous function" that has an error somewhere inside it.  An example of an anonymous function is the second argument to the addEventListener below:
addEventListener( Event.COMPLETED, function ( e:Event ) { trace( "Now within the anonymous function." ); } );
So you have an anonymous function that gets invoked when the list of the combobox changes.  The specific error is that you're setting something within that function that doesn't exist, for example:
trace( my_movie_clip.zxvzeaewrsdafzdaf );
would cause this error, unless zxvzeaewrsdafzdaf  is defined within my_movie_clip.
Putting these bits of data together, look for an addEventListener for comboBox that looks at either Event.CHANGE or ListEvent.ITEM_CLICK and uses an anonymous function.  (looking within the ComboBox code in C:\Program Files\Adobe\Adobe Flash CS4\Common\Configuration\Component Source\ActionScript 3.0\User Interface\fl\controls, those are the only two events which call onListChange, and I see that onListChange forwards the event).  That means, if you search your .fla, you'll find code that does one of the following:
...addEventListener( Event.CHANGE, function(...                   or
...addEventListener( ListEvent.ITEM.CLICK, function( ...
and the error will be somewhere within that anonymous function.  Something within that function will be attempted to read a member of an object that doesn't exist.
That's all I can tell you without seeing the .fla you added the code to.  The .fla you attached doesn't have any anonymous functions, so you'll never see this exact error from it.
Good luck!
what do you mean by "but I tried to Added to another file" - how are you doing this.

if you use the loaderClass to load your swf it works fine.
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

ranhellAuthor Commented:
OK, I think the problem is when I make the code an Action Script File and include it into the FLA
I've attached the FLA and the AS files

Ok, now we're getting somewhere!
By the way, the error message I get is much more clear than the error you posted.  Life is a lot easier if you use Debug->Debug Movie to test with.  (Any time I want to test, I use ctrl-shift-enter, which does the same thing.)
Here's the error message I get:
TypeError: Error #1010: A term is undefined and has no properties.
 at Loadxml_fla:MainTimeline/Loadcategory/Loadxml_fla:updateItems()[D:\flash_workbench\quick_ee\Loadxml.as:32]
 at Loadxml_fla:MainTimeline/Loadcategory/Loadxml_fla:completedLoad()[D:\flash_workbench\quick_ee\Loadxml.as:26]
 at flash.events::EventDispatcher/dispatchEventFunction()
 at flash.events::EventDispatcher/dispatchEvent()
 at flash.net::URLLoader/onComplete()

This is much more clear - it's saying that the error occurs when you call updateItems from within completedLoad.  The offending line is
  var str = this.categoriescb.selectedItem["label"];
Interestingly enough, the issue that is causing your problem is the word "this".  Since you included the function, and it's a global-level function without an attached object, the "this" throws it off.  Using "this" makes sense when you have an object, but since you don't, it can't find "this.categoriescb".  Simply change the line to
var str = categoriescb.selectedItem["label"];
and you're working again.  
Since you loaded it all in as a function, and you had function inside functions, they got stored as anonymous ones, even though you gave them names.  It looks like you're really close to making it object oriented.  I'm attaching files that show you some neater alternatives to what you had.  I would recommend not including the file and not having them all massed in to one function, but to each their own.
The code I'm attaching is a fully object-oriented version of what you want.  I've added some comments that might help clarify how to object orient.  Save this code in a file ComboBoxHandler.as in the same folder as your .fla, and all you need in your .fla actions is a single line:
var cbh:ComboBoxHandler = new ComboBoxHandler( categoriescb, itemscb, "test.xml" );
Do that, and you're done.
I'm also attaching a .as file, which is an edit of what you had.  The major difference is that I made it so you don't have functions embedded within functions.  If you're not looking for object oriented, this is the best way for you to set up and include your functions.  You'll notice it's very similar in style to the object-oriented solution - vars that need to be shared are declared outside of the scope of the function, and each function is distinct.  The major difference is the object-oriented solution doesn't hardcode the combo boxes or the url.

// all as3 classes should have a package layer.  If you move the file to a different folder, you'll have to make it match
	// first you have your imports
	import fl.controls.ComboBox;
	import flash.events.Event; 
	import flash.net.URLLoader;
	import flash.net.URLRequest;

	// declare a public class.  One class per file.
	public class ComboBoxHandler
		// these are the class properties, used by the class.  Since I set them private, nothing else can see them.
		private var requestPath:String;
		private var ldr:URLLoader;
		private var comboBoxCategories:ComboBox;
		private var comboBoxItems:ComboBox;
		private var config:XML;
		// this is the constructor.  It runs initialization routines
		public function ComboBoxHandler( cbCategories:ComboBox, cbItems:ComboBox, file:String )
			// here we take the reference to the combobox and store it inside the object.
			this.comboBoxCategories = cbCategories;
			this.comboBoxItems = cbItems;
			var url:URLRequest = new URLRequest( "test.xml" );
			// note that "this.ldr" is referring to the ldr declared on line 15.  The "this." is optional, but helps show that this is a class variable.
			this.ldr = new URLLoader();
			this.ldr.addEventListener( Event.COMPLETE, this.completedLoad );
			this.ldr.load( url ); 
		function completedLoad( event:Event=null ):void
			if (this.ldr.data)
				this.config = XML(this.ldr.data);
				for each (var cat:XML in this.config.category)
					var str:String = cat.@name.toString();
					var obj:Object = new Object();
					obj["label"] = str;
					obj["data"] = str;
					this.comboBoxCategories.addItem( obj );
			this.comboBoxCategories.addEventListener( Event.CHANGE, this.updateItems );
			this.comboBoxCategories.selectedIndex = 0;
		function updateItems( event:Event=null ):void
			var str = this.comboBoxCategories.selectedItem["label"];
			for each (var item:XML in this.config.category.(@name == str).item)
				var name_str:String = item.id.toString();
				var obj:Object = new Object();
				obj["label"] = name_str;
				obj["data"] = name_str;
				this.comboBoxItems.addItem( obj );

Open in new window

ranhellAuthor Commented:
Firts of all I'm glad you responded
Well ....what can I say, "YOU're RIGHT" ..!! again
You always exeeds my expectations, amazing, but also make me wonder about some other concepts I'm still learning

Now, as usual, Can I ask a couple of questions before I grant you the points.
This following question I've already tested it myself and it does work, I just wanted to make sure I'm on the right track and see if you had any comments on this
1.-Once you compile the Fla file and exported to swf, you don't need to include the as files in the hosting server right...? I mean. I don't need to copy the as files in the hosting server for the swf file to work..?
2.-Do you know how to use relative paths..? perhaps a as3 function...!!
for example if I were to use the xml folder, I'm using a variable var xmlpath:String = "xml/"

Finally but most important I'm reading xml files with spanish lenguage and they have accents and punctuations and especial caracters that currently they don't display correctly....
Do you know how to explicity say which lenguage your're using so the caracters display correct.

Thanks so much for UR help, you're becoming my favorite expert....

I'm glad it's working.
1.  You're right - once you have a swf, you don't need the fla or any of the .as files.
2.  Paths are relative to wherever the swf file is.  If your swf folder is in c:\inetpub\wwwroot\flashstuff\flashproject1, and you create a url request of "xml/myxmlfile.xml", that assumes that the full path to the file is c:\inetpub\wwwroot\flashstuff\flashproject1\xml\myxmlfile.xml .  Functions and classes such as UrlRequest work on relative paths like I just listed, and on complete urls, such as http://www.mywebsite.com/flashstuff/flashproject1/xml/myxmlfile.xml .  I'm not sure if that answered your question.
As for non-English characters, I've never dealt with that before, but...
That's the best I can easily come up with.  Good luck!

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ranhellAuthor Commented:
I figure it out, about the spanish characters, I use the CDATA code , set the text.htmlText and also embeded the Latin I fonts into it and it worked.

As of the original question, your rock....!!! thanks again for UR help and time.

see you next time I'm trouble.....
ranhellAuthor Commented:
Excellent, as usual..!!
ranhellAuthor Commented:
Hey Carnou
This is me again asking for help
Could you take a look at it, if you have a chance.....???

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Adobe Flash

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.