Hei!
Im trying to implement an interface for custom classes that extend Sprite (DisplayObject), but i can’t use DO methods on those instances afterwards, when called via the interface… illustration:
**interface**:
public interface IListingItem extends IEventDispatcher
{
function setData( someData ):void;
}
// **usage**..
var instance:IListingItem = new MyDisplayObject( ); // **MyDisplayObject extends Sprite, implements IListingItem**
instance.addEventListener( Event.COMPLETE, onItemLoaded ); // okay, since interface extends IEventDispatcher
instance.setData( "bla" ); // still okay, since interface defines this method
instance.x = 10; // [COLOR=red]1119: Access of possibly undefined property x through a reference with static type classes.interfaces:IListingItem.[/COLOR]
this.addChild( instance ); // i guess this would also throw error
So maybe i do something wrong? Should be interface only used for calling some simple methods that don’t work with display list?
Initially i also got an error calling that addEventListener on the content instance, that disappeared after i told the interface to extend IEventDispatcher. Is there similiar interface that defines DO properties like ISprite or something? Or should this technique not be used at all? Any ideas welcome!
Thanks design-patterns-flash-gurus!