Christopher Casey
asked on
Flash AS3 ArgumentError: Error #1063
i get this error in the output of this flash
ArgumentError: Error #1063: Argument count mismatch on Untitled_fla::MainTimeline /onNextCli ck(). Expected 1, got 0.
at QuestionForm/completeHandl er()
at flash.events::EventDispatc her/dispat chEventFun ction()
at flash.events::EventDispatc her/dispat chEvent()
at flash.net::URLLoader/onCom plete()
I am trying to make the MovieClip QuestionForm go to the next question ones you pick a answer.
ArgumentError: Error #1063: Argument count mismatch on Untitled_fla::MainTimeline
at QuestionForm/completeHandl
at flash.events::EventDispatc
at flash.events::EventDispatc
at flash.net::URLLoader/onCom
I am trying to make the MovieClip QuestionForm go to the next question ones you pick a answer.
var variables:URLVariables = new URLVariables();
buttonA.addEventListener(MouseEvent.CLICK, onAnswer);
buttonB.addEventListener(MouseEvent.CLICK, onAnswer);
buttonC.addEventListener(MouseEvent.CLICK, onAnswer);
buttonD.addEventListener(MouseEvent.CLICK, onAnswer);
function onAnswer(e:MouseEvent):void {
switch (e.target) {
case buttonA :
variables.Answer="A";//or whatever you want
variables.sendRequest="parse";
// etc etc
break;
case buttonB :
break;
case buttonC :
break;
case buttonD :
break;
}
var urlRequest:URLRequest=new URLRequest("Write-to-DB.php");
urlRequest.method=URLRequestMethod.POST;
urlRequest.data=variables;
var urlLoader:URLLoader=new URLLoader ;
urlLoader.dataFormat=URLLoaderDataFormat.VARIABLES;
urlLoader.addEventListener(Event.COMPLETE, completeHandler);
//send to server
urlLoader.load(urlRequest);
}
function completeHandler(event:Event):void {
MovieClip(root).onNextClick();
//go to next question here
//handle the response from the server...
}
Untitled-3.fla
I can't check your source file now, but what the error message is saying is that the onNextClick() function requires one argument but you are not providing it in this line...
MovieClip(root).onNextClic k();
Maybe the onNextClick() function takes an Event as an argument??? If that is the case, change it to something like this to get away with it... (It's not a good way of doing it, but that should get you going...
function onNextClick(e:Event = null):void
If that does not work, post the code for the onNextClick function...
CyanBlue
MovieClip(root).onNextClic
Maybe the onNextClick() function takes an Event as an argument??? If that is the case, change it to something like this to get away with it... (It's not a good way of doing it, but that should get you going...
function onNextClick(e:Event = null):void
If that does not work, post the code for the onNextClick function...
CyanBlue
ASKER
O i am sorry i forgot to all the xml file and blue-genie your right i did upload the wrong flash file
Questions.xml
Untitled-3.fla
Questions.xml
Untitled-3.fla
ASKER
Here is the code other bit of the code.
This works it hides the questions i will have to thank other experts-exchange Genius for all the code.
what i want to do is when the user press a,b,c,d it jumps to the next questions.
This works it hides the questions i will have to thank other experts-exchange Genius for all the code.
what i want to do is when the user press a,b,c,d it jumps to the next questions.
//load the questions
var urlLoader:URLLoader = new URLLoader();
urlLoader.addEventListener(Event.COMPLETE, onLoad);
urlLoader.load(new URLRequest("Questions.xml"));
var arrQuestions:Array = []; //will contain all the questionForms for easy access
var objAnswers:Object = {}; //track all answers given
var currentQuestion:Number = -1; //The current displayed question
function onLoad(e:Event):void {
var xml = new XML(e.target.data);
var questions:XMLList = xml..Question;
var questionCount:Number = questions.length();
for(var i=0; i<questionCount; i++){
//create instances of QuestionForm for each question.
var questionForm:QuestionForm = new QuestionForm();
//populate with text
questionForm.question.text = questions[i].text();
questionForm.optionA.text = questions[i].Answer[0].text();
questionForm.optionB.text = questions[i].Answer[1].text();
questionForm.optionC.text = questions[i].Answer[2].text();
questionForm.optionD.text = questions[i].Answer[3].text();
//position
questionForm.x = (stage.stageWidth /2) - (questionForm.width /2);
questionForm.y = (stage.stageHeight /2) - (questionForm.height /2);
questionForm.ID = questions[i].@id; //pulled from the id attribute in the xml file
arrQuestions.push(questionForm);
addChild(questionForm);
}
hideAllQuestions();
}
function hideAllQuestions(){
for(var i in arrQuestions) arrQuestions[i].visible = false;
}
//Next Button functionality
function onNextClick(e:MouseEvent):void{
currentQuestion ++;
hideAllQuestions();
if(currentQuestion == arrQuestions.length) currentQuestion = 0; //restart - or change to show 'end screen'
arrQuestions[currentQuestion].visible = true;
traceAnswers()
}
btnNext.addEventListener(MouseEvent.CLICK, onNextClick);
//Demonsrates how to access all answers
function traceAnswers():void{
for(var i in arrQuestions){
if(arrQuestions[i].answer) trace("Question:" + arrQuestions[i].ID + " Answer:" + arrQuestions[i].answer);
}
trace("-----------");
}
Did you try what I have asked???
CyanBlue
CyanBlue
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Yes changing function onNextClick(e:Event = null):void worked.
why ?
why ?
ASKER
I put function onNextClick(e:MouseEvent = null):void{
and it still worked again why
and it still worked again why
ASKER
Thank you
It should really be MouseEvent rather than Event... It works because of the parent-child relationship between two... But you really need to use MouseEvent for it...
CyanBlue
CyanBlue
the error upon clicking the Next button
TypeError: Error #1010: A term is undefined and has no properties.
at Untitled_fla::MainTimeline
seems to be a problem in here
arrQuestions[currentQuesti
can't check what's going on with where you're pushing and adding the questionForm to the stage without the xml format but it concerns me a bit that you're adding it in a for loop.