Copy link to clipboard
Copied
I am stumped. I have been tryign to load my XML into my application and it keeps giving me a 1010 error
var xmlLoader:URLLoader = new URLLoader();
xmlLoader.addEventListener(Event.COMPLETE, parseXMLforSearchPanel);
xmlLoader.load(new URLRequest( "xml/Full_TV_Episodes.xml"));
function parseXMLforSearchPanel(event:Event):void{
var xml:XML = XML(event.target.data);for(var j:uint = 1; j < main.length; j++){
if(main.xmlLoader == event.target){main .xml = XML(event.target.data); main .xmlLoaded = true; break;}
}
var source:Array = new Array({});
for(i = 0; i < main.xml[0].item.length(); i++){
source.push({
MC:new ItemHolder(),
title:main.xml[0].item.@title,
channel:main.xml[0].item.@channel,
letter:main.xml[0].item.@letter,
genre:main.xml[0].item.@genre.split("#"),
mostPopular:main.xml[0].item.@mostPopular,
image:absPath + main.xml[0].item.image,
url:main.xml[0].item.url ,
urlTarget:main.xml[0].item.url.@target,
imgLoader:new Loader()
});
for(var l:uint = 0; l < source[i+1].genre.length; l++){
var genreAdded:Boolean = false;
for(var k:uint = 0; k < genre.length; k++){
if(genre== source[i+1].genre ){genreAdded = true; break;}
}
if(!genreAdded){genre.push(source[i+1].genre);}
}
source[i+1].imgLoader.load(new URLRequest(source[i+1].image));
source[i+1].MC.container.addChild(source[i+1].imgLoader);
source[i+1].MC.title = source[i+1].title;
source[i+1].MC.url = source[i+1].url;
source[i+1].MC.urlTarget = source[i+1].urlTarget;
source[i+1].MC.mouseChildren = false;
source[i+1].MC.addEventListener(MouseEvent.ROLL_OVER, newChoiceItem);
source[i+1].MC.addEventListener(MouseEvent.CLICK, openItemUrl);
}
//MOST POPULAR PART
if(main.xml[0].mostPopular[0] != undefined){
if(main.xml[0].mostPopular[0].show[0] != undefined){
for(var m:uint = 0; m < main.xml[0].mostPopular[0].show.length(); m++){
for(i = 1; i < source.length; i++){
if(main.xml[0].mostPopular[0].show .@title == source.title){
mostPopular.push({MC:source.MC});
}
}
}
}
}
main.source = source;
genre.sort(); refreshGenreMenuDropDown();if(firstRun && j == menuBTNselected){
filterByMostPopular();
firstRun = false;
}//XMLforSearchPanelParsed = true;
}
ANy help will be greatly apprciated
I don't see where you declared the variable i, so do like you did for the other loops and declare it in that line and see if that solves it. If it was already declared somewhere else that I don't see, then try tracing that middle variable ( main
Copy link to clipboard
Copied
What is the complete error message?
Copy link to clipboard
Copied
TypeError: Error #1010: A term is undefined and has no properties.
at tvshows_fla::MainTimeline/parseXMLforSearchPanel()[tvshows_fla.MainTimeline::frame1:40]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/onComplete()
Copy link to clipboard
Copied
Which line is line 40 in frame 1?
Copy link to clipboard
Copied
for(i = 0; i < main
Copy link to clipboard
Copied
i also have no issue sending the fla file if needed
Copy link to clipboard
Copied
I don't see where you declared the variable i, so do like you did for the other loops and declare it in that line and see if that solves it. If it was already declared somewhere else that I don't see, then try tracing that middle variable ( main
Copy link to clipboard
Copied
ouch!
It seems like it is declared in this other function:
function parseMainXML(event:Event):void{
event.target.removeEventListener(Event.COMPLETE, parseMainXML);
var xml:XML = XML(event.target.data);
spaceBetweenButtons = xml[0].preferences[0].@spaceBetweenButtons;
buttonAlign = xml[0].preferences[0].@align;
for(i = 0; i < xml[0].menuButton.length(); i++){
main.push({
MC:new MenuButton(),
title:xml[0].menuButton.@title,
panelType:xml[0].menuButton.@panelType,
turnedOn:xml[0].menuButton.@turnedOn,
xml:XML,
xmlPath:absPath + xml[0].menuButton.xml[0],
xmlLoader:new URLLoader(),
xmlLoaded:false,
//------------next Level--------------
source:new Array({})
});
main[i+1].MC.nr = i+1;
main[i+1].MC.txtMCoff.txt.text = main[i+1].MC.captionTXT = main[i+1].title;
main[i+1].MC.mouseChildren = false;
main[i+1].MC.addEventListener(MouseEvent.CLICK, changeButton);
main[i+1].MC.y = menuButtonsScope.y;
main[i+1].MC.x = menuButtonsScope.x;
if(main[i+1].panelType == "ListPanel"){
main[i+1].xmlLoader.addEventListener(Event.COMPLETE, parseXMLforListPanel);
}else if(main[i+1].panelType == "SearchPanel"){
main[i+1].xmlLoader.addEventListener(Event.COMPLETE, parseXMLforSearchPanel);
}
if(i > 0){
main[i+1].MC.x = main.MC.x + main[i+1].MC.width + spaceBetweenButtons;
}
if(main[i+1].turnedOn == "true"){
main[i+1].MC.gotoAndStop("on");
menuBTNselected = i+1;
}
main[i+1].xmlLoader.load(new URLRequest(main[i+1].xmlPath));
}
var newButtonScope:Number = (main.length-1)*(main[1].MC.width + spaceBetweenButtons) - spaceBetweenButtons;
for(i = 1; i < main.length; i++){
if(buttonAlign == "center"){
main.MC.x += (menuButtonsScope.width - newButtonScope)/2;
}else if(buttonAlign == "right"){
main.MC.x += (menuButtonsScope.width - newButtonScope);
}
if(main.turnedOn == "true"){
main.MC.gotoAndStop("on");
showPanelElements(main.panelType);
}
addChild(main.MC);
}
}
Whose only purpose is to add buttons to the top of the flash application, since i parsed out all the infomration it broke the loop.
Copy link to clipboard
Copied
I cannot read that code to see what you mean, but if you say you declared it in another function, it only has scope within the function in which it is declared. If you didn't declare it outside of any function then you need to declare it in any function that makes use of it.
JUst declare it as you did the otheras and see if that fixes it (for that error).
Copy link to clipboard
Copied
i took out main
Copy link to clipboard
Copied
sorry did giver other error
When i removed the main[]
i get this error
TypeError: Error #1010: A term is undefined and has no properties.
at tvshows_fla::MainTimeline/filterByLetter()[tvshows_fla.MainTimeline::frame1:400]
at tvshows_fla::MainTimeline/showLetter()[tvshows_fla.MainTimeline::frame1:321]
function showLetter(event:MouseEvent):void{
for(var i:uint = 1; i < letter.length; i++){
if(event.target == letter){
letter.gotoAndStop("on");
filterByLetter(letter.captionTXT);
}else{
letter.gotoAndStop("off");
}
}
}
function filterByLetter(ch:String):void{
mostPopularBTN.gotoAndStop("off");
searchInput.txt.text = "Search TV Show...";
while(searchPanelContainer.container.numChildren > 0){searchPanelContainer.container.removeChildAt(0);}
var i:uint;
var filtered:Array = new Array();
if(ch == "123"){
for(i = 1; i < main[menuBTNselected].source.length; i++){
if(String(Number(main[menuBTNselected].source.letter)) != "NaN"){filtered.push(main[menuBTNselected].source);}
}
}else if(ch == "ALL"){
for(i = 1; i < main[menuBTNselected].source.length; i++){
filtered.push(main[menuBTNselected].source);
}
}else{
for(i = 1; i < main[menuBTNselected].source.length; i++){
if(main[menuBTNselected].source.letter == ch){filtered.push(main[menuBTNselected].source);}
}
}
refreshSearchPanelContainer(filtered);
scrollBarVertical.connectMC(searchPanelContainer.container);
infoMC.txt.text = "TV Shows on letter '" + ch + "'";
if(ch == "ALL"){infoMC.txt.text = "All TV Shows";}
moveLettersShine();
}
i removed the main and even the menutNselected and the program goes nuts
main is set as a global array
var menuBTNselected:uint
321 line = filterByLetter(letter.captionTXT);
400 lin = for(i = 1; i < main[menuBTNselected].source.length; i++){
Sorry i am really new to action script, and tryign to piece this together as former devleoper left
Copy link to clipboard
Copied
No need to apologize. Here is something that might help you thru dealing with the errors. I am assuming your Publish Settings have the "Permit Debugging" option turned on, which is a good thing. That is helping by adding line numbers to the error messages. The first line number shown in an error message will be the closest to the problem.
So for the new error it is indicating line 400 of frame 1 has something in it that is undefined. So now you can try to track it down by using the trace function. Just before line 400 insert the following traces...
trace("i : ",i);
trace("length: ", main[menuBTNselected].source.length);
When you try run the file again you should see something amiss with one of those traces. If it happens to be the second one, you can break that down further to see what part of it is the most likely culprit by tracing the parts...
trace(main)
trace(main[menuBTNselected])
trace(main[menuBTNselected].source)
Find more inspiration, events, and resources on the new Adobe Community
Explore Now