Select to view content in your preferred language

incorrect number of arguments?

3671
6
01-24-2011 01:05 PM
GeorgiannaStrode
Deactivated User
In my mxml file I keep getting error 1136: "Incorrect number of arguments.Expected 1." from the codes below. I have declared search() function in the ActionScript part already so there should be no problem.

  <s:Button x="130" y="270" click="search()" label="{search}"/> 
Tags (2)
0 Kudos
6 Replies
DasaPaddock
Esri Regular Contributor
It sounds like the search function is expecting an argument to be passed to it. How is it declared in the code?
0 Kudos
GeorgiannaStrode
Deactivated User
It sounds like the search function is expecting an argument to be passed to it. How is it declared in the code?


private function search(event:Event):void
   { 
    var query:Query = new Query();
    query.where = queryAttribute1 + "='" + txtSearch1.text + "'"+queryAttribute2 + "='" + txtSearch1.text + "'";
    queryTask.url = featureURL;
    queryTask.execute(query, new AsyncResponder(onResult, onFault));
    
    function onResult(featureSet:FeatureSet, token:Object = null):void
    {
     if (featureSet.features.length == 0){
      Alert.show("Not found.");
     }else if(featureSet.features.length == 1){
      if(featureSet.features[0].geometry is MapPoint)
      {
       map.scale = 24000;
       map.centerAt(featureSet.features[0].geometry as MapPoint);
      }else{
       map.extent = GraphicUtil.getGraphicsExtent(featureSet.features);
      }
     }else{
      map.extent = GraphicUtil.getGraphicsExtent(featureSet.features);
     }
    }
    function onFault(info:Object, token:Object = null):void
    {
     Alert.show(info.toString());
    }
   }
0 Kudos
JasonLevine
Deactivated User
Try removing "event:Event" so it looks like:
private function search():void
0 Kudos
GeorgiannaStrode
Deactivated User
Try removing "event:Event" so it looks like:
private function search():void


I removed it and now its getting no errors and the box came out right. But after I input the lat/long and click search, it give me another error saying:
[RPC Fault faultString="Unable to complete  operation." faultCode="400" faultDetail="Unable to complete Query operation."]
Is there anything important I am missing here?
0 Kudos
JasonLevine
Deactivated User
I think there might be something wrong with your query.where statement:
query.where = queryAttribute1 + "='" + txtSearch1.text + "'"+queryAttribute2 + "='" + txtSearch1.text + "'";


An example of how it should be formatted is:
query.where = "STATE_NAME = 'Alaska' AND TYPE = 'city'";


So in your case, it could go something like this:
query.where = queryAttribute1+"='"+txtSearch1.text+"' AND "+queryAttribute2+"='"+txtSearch1.text+"'";
0 Kudos
GeorgiannaStrode
Deactivated User
Hi Jason, your codes work better. Thanks
Whatever i type in it still says "Not found". Im trying to make a lat/long zoom. and now i'm using this query statement:
query.where = queryAttribute1+"='"+txtSearch1.text+"','"+txtSearch2.text+"'
    AND "+queryAttribute2+"='"+txtSearch3.text+"','"+txtSearch4.text+"'";


for queryAttribute1 Im using latitude attribute of a lyer, for Attribute2 I'm using longitude attribute.
textSearch1 and 2 are for latitude input, textSearch3 and 4 are for longitude input(found it from bookmark.xml).  They tell me my codes have problem again.

I wonder if anyone knows how to handle this lat/long thing.
0 Kudos