views:

50

answers:

3

I am trying to put getters and setters into my inteface but I get the following error1053:

Accessor types must match.

Below is my Interface.

package com.objects{


    public interface IKiller {

        function get Systems():Array;
        function set Systems(value:TargetSystem):void;

    }
}

How are you suppose to put getters and setters into a interface. for as3

+2  A: 

I believe what the compiler is complaining about is that the getter returns an "Array", but the setter takes a "TargetSystem"

Those types must match. (Not only in an interface, but in a class as well.)

ablerman
+1  A: 

I think the problem there is the fact that

function get Systems():Array;

Defines Systems as an Array and

function set Systems(value:TargetSystem):void;

Defines Systems as a TargetSystem

The types on the get/set methods need to match. It looks like you want a get property, but not a set (as set would allow the caller to specify an all new array).

If you're trying to allow the caller to add items to the Systems Array, just have them call Array.push() after calling get.

Justin Niessner
is it possible to get properties to act like a array. will properties act like an array. (i.e. can I call the array like this object.Systems[0];
numerical25
A: 

Is it because your get returns an array but your setting takes in a "TargetSystem" type instead of an array? Typically a setter takes in the same class that a getter returns.

Austin Fitzpatrick