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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T08:17:54+00:00 2026-06-16T08:17:54+00:00

In ActionScript3, I am trying to access the properties of the caller object from

  • 0

In ActionScript3, I am trying to access the properties of the caller object from a composite.

public class Robot {
 ...
 private var controlPanel:ControlPanel;
 ...
 public function Robot() {
 ...
 cPanel = new ControlPanel();
 ...
  }
 }

My ControlPanel needs to access properties from Robot instance, but I don’t think I can pass this when calling the ControlPanel…

public class ControlPanel{
...
 public function ControlPanel() {
  //How can I refer back to robot properties ?
  //
 }

}

I believe I am in the case of composition as a Robot has a ControlPanel. I am thinking of using events, but there are many properties I need to access.

What would be the best way to solve this?

  • 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-16T08:17:55+00:00Added an answer on June 16, 2026 at 8:17 am

    You can always just let ControlPanel store a reference to its own Robot object, like so:

    // ControlPanel
    private var robot:Robot;
    
    public function ControlPanel(robot:Robot) {
        this.robot = robot;
    }
    

    And then, when creating the control panel:

    // Robot
    public function Robot() {
        controlPanel = new ControlPanel(this);
    }
    

    Alternatively, you could create an even system of sorts, and then let the control panel dispatch them. You could create your own ControlPanelEvent class, and then let the Robot itself handle the results. For example, let’s say you change a property called foo in the control panel. You could dispatch it like this:

    var event:ControlPanelEvent = new ControlPanelEvent(ControlPanelEvent.PROPERTY_CHANGE, "foo", value);
    

    Then you’d receive it like this:

    public function Robot() {
        controlPanel = new ControlPanel();
        controlPanel.addEventListener(ControlPanelEvent.PROPERTY_CHANGE, updateProperty);
    }
    
    public function updateProperty(event:ControlPanelEvent):void {
        if (event.key == "foo") {
            this.foo = event.value;
        }
    }
    

    However, that’s wordy and unnecessary. You could also use ActionScript’s array access notation in the event handler, which would be a simple one-liner:

    this[event.key] = event.value;
    

    Still, that’s not entirely secure, since you might not want the control panel to be able to update all of a robot’s properties. Instead, you could maintain a simple map of configurable properties that the robot can have, and update that instead:

    private var configuration:Dictionary = new Dictionary();
    
    public function Robot() {
        // ...
        configuration.foo = "bar";
        configuration.baz = "qux";
        //...
    }
    
    public function updateProperty(event:ControlPanelEvent):void {
        if (configuration.hasOwnProperty(event.key))
            configuration[event.key] = event.value;
    }
    

    There you go. Of course, you could always just store the configuration map in the ControlPanel itself, and let the Robot pull from that, but if you absolutely need it as a property of the robot, here are a few solutions.

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

Sidebar

Related Questions

I have extended an mxml component with an actionscript class. I'm trying to access
I am trying to create and array of objects so that I can access
Here's something I'm trying to figure out concerning display objects in ActionScript3 / Flex.
I'm trying to a make a simple class in an actionscript file that handles
I am very new to actionscript3/flashbuilder and I'm trying to do something simple like
I am trying to make a simple Flash ActionScript3 program that saves some text
I'm trying to compile an SWC file from a list of given ActionScript classes.
I'm new to Flash/ActionScript 3, I'm trying to dynamically update the Object in a
I'm trying to load profile images (friend images) from Facebook with AS3 but I
I am trying to create an ActionScript 3 class that implements two interfaces. The

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.