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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T23:22:27+00:00 2026-06-11T23:22:27+00:00

I am using ActionScript3, I am writing a class that extends Bitmap, I want

  • 0

I am using ActionScript3, I am writing a class that extends Bitmap, I want to have all of Bitmap’s behaviors and I also want to treat to replace its bitmapData with a subclass of bitmapData that offers more flexibility.

So basically what I have is(metaphor):

Class Gunman
{
    //Has-A
    public var pistol : Gun;
    public function Gunman(gun : Gun)
    {
        this.pistol = gun;
    }
    //methods
    public function shoot():void ..
    {
        pistol.fire();
    }  
}

Class Gun
{
    //constructor omitted cause it is unnecessary for this example
    public function fire():void ..
}

Now I extend these two classes.

Class Automatic extends Pistol
{
    override public function fire():void
    {
        super.fire(); super.fire(); super.fire();
    }
}

Class NavySeal extends Gunman
{
    public function Enforcer(auto : Automatic)
    {
        super(auto);
    }
}

The problem is that people can still easily do this:

var eliteSoldier : NaveSeal = new Enforce(new Automatic());
eliteSoldier.pistol = new Gun();

And this will be bad. Is there any way I prevent this?

I cannot change ‘Gunman’ cause it is part of the API.

  • 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-11T23:22:29+00:00Added an answer on June 11, 2026 at 11:22 pm

    If you are trying to prevent from changing public property public var pistol:Gun; than you can’t if you haven’t got the control over the class that has defined it. It is a bad design, it should be the getter/setter instead. Then you would be able to get and test what users are passing etc.

    best regards

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

Sidebar

Related Questions

I am currently using FlashDevelop for my Actionscript3 development. I have also tried my
I'm writing an extension to the Flex DataGridColumn class. I want to override the
Writing text to .txt files using actionscript. how? i couldn't find anything about that
In our Flex application we have an ActionScript3 class containing a property like this:
i want to build a project base on actionscript3.and it needs to re-size its
I am writing application on ActionScript for Android using Adobe AIR with native extentions.
I am engaged in a game project which using ActionScript3 as language and Flash
Is it possible to create multiple layer masks over a single layer using Actionscript3?
I have the following code using actionscript and the indesign sdk: At the beginning
Hi when I add a new component using Actionscript I want it to fade

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.