Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6344023
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T20:33:31+00:00 2026-05-24T20:33:31+00:00

From what I read, interfaces are basically classes for methods, right? If two classes

  • 0

From what I read, interfaces are basically classes for methods, right? If two classes implements the same interface, then they should both have methods described in the interface.

Now, how is this useful? Let’s say I want to call foo();.

public interface IExample {
    function foo(om:String):void;
}

class HungryClass implements IExample{
    public function foo(om:String):void{
        trace("OM NOM NOM!!! Thank you for feeding me" + om);
    }
}

class FullClass implements IExample{
    public function foo(om:String):void{
        trace("No thanks, I don't want to eat" + om);
    }
}

//somewhere..
instanceOfEitherClass.foo("cake");

How does interfacing help? Wouldn’t this work without interfacing?

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T20:33:31+00:00Added an answer on May 24, 2026 at 8:33 pm

    Lets say you have a concrete class that inherits from an abstract class. In that case you would simply do the following:

    public class ConcreteClass extends AbstractClass
    

    Now how about if you need the concrete class to also inherit from the EventDispatcher class? You can’t do the following:

    public class ConcreteClass extends AbstractClass, EventDispatcher
    

    However you can implement the EventDispatcher class’s IEventDispatcher interface and then use an EventDispatcher object like the following:

    internal class ConcreteClass extends AbstractClass implements IEventDispatcher
    {
        private var _eventDispatcher:EventDispatcher;
    
        public function ConcreteClass()
        {
            _eventDispatcher = new EventDispatcher(this);
    
        }// end function
    
        public function addEventListener(type:String, 
                                         listener:Function, 
                                         useCapture:Boolean = false, 
                                         priority:int = 0, 
                                         useWeakReference:Boolean = false):void
        {
            _eventDispatcher.addEventListener(type, listener, useCapture, priority, useWeakReference);
    
        }// end function
    
        public function dispatchEvent(event:Event):Boolean
        {
            return _eventDispatcher.dispatchEvent(event);
    
        }// end function
    
        public function hasEventListener(type:String):Boolean
        {
            return _eventDispatcher.hasEventListener(type);
    
        }// end function
    
        public function removeEventListener(type:String, 
                                            listener:Function, 
                                            useCapture:Boolean = false):void
        {
            _eventDispatcher.removeEventListener(type, listener, useCapture);
    
        }// end function
    
        public function willTrigger(type:String):Boolean
        {
            return _eventDispatcher.willTrigger(type);
    
        }// end function
    
    }// end class
    

    Using this combination of composition and interfaces you can use the concrete class as both an AbstractClass and EventDispatcher object.

    Interfaces are great for allowing “unrelated objects to communicate with one another”. You can find more information on interfaces here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I read about Interface Builder Plug-Ins but from what I understood they're not
I am trying to read from file: The file is multiline and basically i
Basically i want to discover if a jar implements any number of interfaces wihtout
I read from some books that Phusion Passenger is the answer to easy Ruby
From what I've read from Herb Sutter and others you would think that volatile
History: I read from one of Knuth's algorithm book that first computers used the
I have read from some article that say's Apple doesn't approve the application which
I need to read from a variety of different text files (I've some delimited
How would I read from an Excel sheet and load the marked selection (Area)
I want to read from stdin five numbers entered as follows: 3, 4, 5,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.