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 8877915
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T19:35:07+00:00 2026-06-14T19:35:07+00:00

OK I’ve got some question about what I guess is basic OOP. For example,

  • 0

OK I’ve got some question about what I guess is basic OOP. For example, let’s say I have many diffrent objects which has diffrent classes. Let’s say, one object called, car (Car.as), then I have a truck (truck.as) and a moped (moped.as). Now instead of writing a simple function within all of these, can’t I have a class and then attach this function onto everyone of these objects?

For example I want them to be able to fade out. Then I have a class called “AlphaThings” and within this class I write a simple fadeout function.

Can’t I somehow then attach this function to another object? Like

AlphaThings.fadeout(car);
AlphaThings.fadeout(truck);
AlphaThings.fadein(moped);

Thanks, and sorry if there some misspelled words.

  • 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-06-14T19:35:09+00:00Added an answer on June 14, 2026 at 7:35 pm

    You’re trying to accomplish inheritance, which is where a class inherits properties and methods from another.

    Inheritance is accomplished by using the extends keyword when defining the class.

    Your three objects Car, Truck and Moped could inherit from (extend) AlphaThings like this:

    class Car extends AlphaThings
    {
        //
    }
    

    Your Car will now contain all of the properties and methods defined within AlphaThings, such as .fadein() and .fadeout() that you mentioned.

    Bonus info:

    When you extend another class, you can alter how methods existing within the base class will work in the class inheriting from it. This is done using the override keyword.

    For example, you may want your Car to do something slightly different or additional when you use .fadein() on it, so you would override that method like this:

    override public function fadein():void
    {
        // Some additional logic.
        // ...
    
        super.fadein();
    }
    

    The line super.fadein() is there to call the original .fadein() function. If you omit this, you can completely rewrite the function and have the previously defined actions ignored.

    Regarding this specific scenario:

    This answer of course gets straight to the point and answers the question directly by explaining how to achieve inheritance. With that said, what you’re trying to achieve can be done more cleanly using one of a handful of other routes.

    For example, consider this Tweening Library by Greensock. The library can deal with the transitioning of any values (including alpha) on any objects in different ways. Here are some examples of why this is great vs using inheritance:

    1. The library is completely separate from your actual objects.
    2. The library can be made as powerful as you like without making all of your other game objects heavier than they need to be. You’ll notice for example that there are many types of transition styles you can use (e.g. ease out, ease in, etc) – imagine if all of that was part of your base object.
    3. You can target anything with the library, meaning that you do not need to extend AlphaThings from your example to use it.
    4. It is relatively easy to detach or swap out with another library if you decide down the track that it it no longer necessary or you’ve found something better.
    5. You can re-use the library easily across your projects, versus having to extract bits and pieces of code from AlphaThings in a new project.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I don't have much knowledge about the IPv6 protocol, so sorry if the question
Let's say I'm outputting a post title and in our database, it's Hello Y’all
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
This could be a duplicate question, but I have no idea what search terms
i got an object with contents of html markup in it, for example: string
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I want to count how many characters a certain string has in PHP, but
link Im having trouble converting the html entites into html characters, (&# 8217;) i

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.