PDA

View Full Version : 1137: Incorrect number of arguments. Expected no more than 1.


hackin
03-14-2008, 06:51 PM
I create the following function

---------------------------------

package com.cerebrum.utils {

import mx.rpc.events.ResultEvent
import mx.controls.Alert;

public class Result {

[Embed("/assets/images/dialog-information.png")]
public var IconDialogInformation:Class;

public function Result(event:ResultEvent,MyObject:Object):void {
Alert.show("teste", "teste", 4, null, null, IconDialogInformation);
}

}

}

---------------------------------


I as follows

import Result;

Result(event, meuobjeto);

---------------------------------

Is presented in the following error flex builder


1137: Incorrect number of arguments. Expected no more than 1.

---------------------------------

How should I inform the function that actually has 2 parameters?

hackin
03-14-2008, 06:53 PM
I create the following function

---------------------------------

package com.cerebrum.utils {

import mx.rpc.events.ResultEvent
import mx.controls.Alert;

public class Result {

[Embed("/assets/images/dialog-information.png")]
public var IconDialogInformation:Class;

public function Result(event:ResultEvent,MyObject:Object):void {
Alert.show("teste", "teste", 4, null, null, IconDialogInformation);
}

}

}

---------------------------------


I as follows

import Result;

Result(event, meuobjeto);

---------------------------------

Is presented in the following error flex builder


1137: Incorrect number of arguments. Expected no more than 1.

---------------------------------

How should I inform the function that actually has 2 parameters?

sgartner
03-14-2008, 07:14 PM
I create the following function

---------------------------------

package com.cerebrum.utils {

import mx.rpc.events.ResultEvent
import mx.controls.Alert;

public class Result {

[Embed("/assets/images/dialog-information.png")]
public var IconDialogInformation:Class;

public function Result(event:ResultEvent,MyObject:Object):void {
Alert.show("teste", "teste", 4, null, null, IconDialogInformation);
}

}

}

---------------------------------


I as follows

import Result;

Result(event, meuobjeto);

---------------------------------

Is presented in the following error flex builder


1137: Incorrect number of arguments. Expected no more than 1.

---------------------------------

How should I inform the function that actually has 2 parameters?

The problem is that you think you are calling the constructor for your class, but what you are really doing there is using the class casting operator for the Result class. To call the constructor you need to use "new".


var x:Result = new Result(x, y);


versus


var x:Result = Result(z); // Attempt to coerce variable z into type Result

dr_zeus
03-14-2008, 08:00 PM
Please do not post the same topic in more than one forum. I've merged the two.

/moderator