Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 10-20-2008, 09:45 PM   #1
cmbarsotti
Senior Member
 
cmbarsotti's Avatar
 
Join Date: Dec 2003
Location: Kansas City, MO
Posts: 298
Default How do I interpret this output message?

Hello,
I'm doing a lynda.com tutorial on AS3 and have run into an issue I can't resolve. I get an error message in the output window upon testing movie.
Code:
ArgumentError: Error #1063: Argument count mismatch on XML/http://adobe.com/AS3/2006/builtin::attributes(). Expected 0, got 1.
	at testTrash_fla::MainTimeline/xmlLoaded()
	at flash.events::EventDispatcher/dispatchEventFunction()
	at flash.events::EventDispatcher/dispatchEvent()
	at flash.net::URLLoader/onComplete()
Is this telling me that I have an error in my xmlLoaded function? This looks like it's trying to tell me that xmlLoaded() is expecting 0 and getting 1 argument. I thought the event listener would return the event.

I had this as an external class but removed all irrelevant code and have pasted it below, I've also included the XML below.

Any help is greatly appreciated.

Code:
import flash.events.*;
import flash.net.*;

var xml:XML;
var xmlList:XMLList;
var xmlLoader:URLLoader = new URLLoader();
var container:MovieClip = new MovieClip();
var xmlPath:String;
var thumbAtt:String;
var fullAtt:String;

function ImageGallery(path:String,thumb:String,full:String) {
	xmlPath = path;
	thumbAtt = thumb;
	fullAtt = full;
	xmlLoader.addEventListener(Event.COMPLETE,xmlLoaded);
	xmlLoader.load(new URLRequest(xmlPath));
}

function xmlLoaded(event:Event):void {
	xml = XML(event.target.data);
	xmlList = xml.children();
	for (var i:int = 0; i < xmlList.length(); i++) {
		trace(xmlList[i].attributes(thumbAtt));
	}
}
ImageGallery("images.xml","full","thumb");
Code:
<images>
	<image full="1.jpg" thumb="1th.jpg">Description of image 1</image>
	<image full="2.jpg" thumb="2th.jpg">Description of image 2</image>
	<image full="3.jpg" thumb="3th.jpg">Description of image 3</image>
	<image full="4.jpg" thumb="4th.jpg">Description of image 4</image>
</images>
__________________
Michael [the idiot] Barsotti
cmbarsotti is offline   Reply With Quote
Old 10-20-2008, 10:23 PM   #2
matbury
What's up pussycat?
 
matbury's Avatar
 
Join Date: Dec 2006
Location: Toronto, Canada
Posts: 1,990
Default

Hi cmbarsotti,

This bit of syntax doesn't look right to me:

ActionScript Code:
trace(xmlList[i].attributes(thumbAtt));

Try this instead:

ActionScript Code:
trace(xmlList..images[i].@thumb);

Also this line:

ActionScript Code:
for (var i:int = 0; i < xmlList.length(); i++) {

will run the XMLList.length() function every time the loop goes round. It's not a problem for small XML files but it can slow down larger ones, like RSS feeds. It's better to do something like this:

ActionScript Code:
var len:uint = xmlList.length(); for (var i:int = 0; i < len; i++) {

Then it only calculates the length once.

Hope this helps!

Matt
__________________
http://matbury.com/

Last edited by matbury; 10-20-2008 at 10:26 PM.
matbury is offline   Reply With Quote
Old 10-20-2008, 10:25 PM   #3
wvxvw
Holosuit User
 
wvxvw's Avatar
 
Join Date: Oct 2006
Location: Tel Aviv
Posts: 4,301
Send a message via ICQ to wvxvw
Default

.attributes() method doesn't take arguments because it returns all the attributes of the XML object it is called on. you should either use attribute("attributeName") to target specific attribute node or attributes() to target all the nodes.
You may also want to look into E4X syntax for this operation:
.@* == .attributes()
.@attributeName == .attribute("attributeName")
__________________
The .NET open source editor for Flash and web developers
*This would be my contribution to the project*
couchsurfing if you need it
wvxvw is offline   Reply With Quote
Old 10-20-2008, 10:28 PM   #4
ASWC
Super Moderator
 
ASWC's Avatar
 
Join Date: Dec 2007
Location: Greenville, SC
Posts: 6,528
Default

ActionScript Code:
trace(xmlList[i].attribute(thumbAtt));
As wvxvw noticed, remove the "s" and your good to go.
__________________
aswebcreations
Super Duper!
ASWC is offline   Reply With Quote
Old 10-20-2008, 10:44 PM   #5
cmbarsotti
Senior Member
 
cmbarsotti's Avatar
 
Join Date: Dec 2003
Location: Kansas City, MO
Posts: 298
Default

Thanks for the responses but when I run this I never get that far in the code. It will not call the xmlLoaded function because it says xmlLoaded is expecting 0 arguments and getting 1. Since this is an event listener I believe it should be expecting 1 argument (event)

matbury: Good man for pointing out the xmlList.length() issue. I assume lynda.com did this because it's a tutorial and they wanted to keep it easy to read. I had the exact same thought as I was watching the video.

wvxvw and ASWC: Thanks, I have changed that to 'attribute' but like I say above, my script never gets to that line of code.
__________________
Michael [the idiot] Barsotti
cmbarsotti is offline   Reply With Quote
Old 10-20-2008, 10:50 PM   #6
matbury
What's up pussycat?
 
matbury's Avatar
 
Join Date: Dec 2006
Location: Toronto, Canada
Posts: 1,990
Default

It could be this then:

ActionScript Code:
xml = XML(event.target.data);

Try:

ActionScript Code:
xml = new XML(event.target.data);
__________________
http://matbury.com/
matbury is offline   Reply With Quote
Old 10-20-2008, 10:55 PM   #7
cmbarsotti
Senior Member
 
cmbarsotti's Avatar
 
Join Date: Dec 2003
Location: Kansas City, MO
Posts: 298
Default

Since that line of code is inside the xmlLoaded function I don't believe that is the issue either (and testing it proved no change). The xmlLoaded function is not being called at all.
__________________
Michael [the idiot] Barsotti
cmbarsotti is offline   Reply With Quote
Old 10-20-2008, 11:16 PM   #8
wvxvw
Holosuit User
 
wvxvw's Avatar
 
Join Date: Oct 2006
Location: Tel Aviv
Posts: 4,301
Send a message via ICQ to wvxvw
Default

Code:
ArgumentError: Error #1063: Argument count mismatch on XML/http://adobe.com/AS3/2006/builtin::attributes(). Expected 0, got 1.
	at testTrash_fla::MainTimeline/xmlLoaded()
	at flash.events::EventDispatcher/dispatchEventFunction()
	at flash.events::EventDispatcher/dispatchEvent()
	at flash.net::URLLoader/onComplete()
The error says xmlLoaded() is called, but you have an error there in the method call of the XML type object, and the method's name is "attributes", it says than it wanted to see no arguments when you call it but you gave it an argument and it doesn't know what to do with it.
__________________
The .NET open source editor for Flash and web developers
*This would be my contribution to the project*
couchsurfing if you need it
wvxvw is offline   Reply With Quote
Old 10-21-2008, 02:55 AM   #9
cmbarsotti
Senior Member
 
cmbarsotti's Avatar
 
Join Date: Dec 2003
Location: Kansas City, MO
Posts: 298
Default

ok, so that first line is pointing out the exact portion throwing the error, and since I had attributes and not attribute, it thought attributes was a function and I was passing 'thumbAtt'. That makes sense.

and the 2nd - 5th lines were telling me all of the functions that failed starting with my xmlLoaded function which tells me where to start looking.

I think I get it.

Also: CORRECTION In an earlier post I said that I changed attributes to attribute and it still failed. Turned out that I'm an idiot. I was testing from the .as file by selecting ctrl + ENTER but the target fla file was incorrect. I have to learn to watch that.

Thanks everyone for your help.
__________________
Michael [the idiot] Barsotti
cmbarsotti is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
output error message (flash & XML) vyas ActionScript 2.0 4 08-01-2008 06:53 PM
Loading External SWF - Blank output message omega3d12 ActionScript 3.0 1 03-26-2008 08:50 PM
What does this output message mean? Nibblingcheese ActionScript 2.0 0 06-27-2007 05:26 PM
Output message. (1000: Unable to....) smc01 ActionScript 2.0 1 05-03-2007 08:29 PM
why i always get this message at output [type Function] raskolnikov Other Flash General Questions 1 05-19-2006 09:46 AM


All times are GMT. The time now is 04:00 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.