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

  • Home
  • SEARCH
  • 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 45207
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T15:46:22+00:00 2026-05-10T15:46:22+00:00

My question is pertaining to the best practice for accessing a child object’s parent.

  • 0

My question is pertaining to the best practice for accessing a child object’s parent. So let’s say a class instantiates another class, that class instance is now referenced with an object. From that child object, what is the best way to reference back to the parent object? Currently I know of a couple ways that I use often, but I’m not sure if A) there is a better way to do it or B) which of them is the better practice

The first method is to use getDefinitionByName, which would not instantiate that class, but allow access to anything inside of it that was publicly declared.

_class:Class = getDefinitionByName('com.site.Class') as Class; 

And then reference that variable based on its parent to child hierarchy.
Example, if the child is attempting to reference a class that’s two levels up from itself:

_class(parent.parent).function(); 

This seems to work fine, but you are required to know the level at which the child is at compared to the level of the parent you are attempting to access.

I can also get the following statement to trace out [object ClassName] into Flash’s output.

trace(Class); 

I’m not 100% on the implementation of that line, I haven’t persued it as a way to reference an object outside of the current object I’m in.

Another method I’ve seen used is to simply pass a reference to this into the class object you are creating and just catch it with a constructor argument

var class:Class = new Class(this);   

and then in the Class file

public function Class(objectRef:Object) {     _parentRef = objectRef; }  

That reference also requires you to step back up using the child to parent hierarchy though.

I could also import that class, and then use the direct filepath to reference a method inside of that class, regardless of its the parent or not.

import com.site.Class; com.site.Class.method(); 

Of course there the parent to child relationship is irrelevant because I’m accessing the method or property directly through the imported class.

I just feel like I’m missing something really obvious here. I’m basically looking for confirmation if these are the correct ways to reference the parent, and if so which is the most ideal, or am I over-looking something else?

  • 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. 2026-05-10T15:46:22+00:00Added an answer on May 10, 2026 at 3:46 pm

    It’s generally good to have the class as it’s own instance and reduce tight coupling to something else (as in this case, it’s parent). If you do something like parent.doSomething() it’s not possible to use that class in container that doesn’t have the doSometing() method. I think it’s definitely better to pass in whatever the class may need and then inside the class it doesn’t have to do any parent.parent etc anymore.

    With this if you in the future want to change the structure, it’s very easy to just pass in a new reference; the implementation of the child class doesn’t have to change at all.

    The third alternative you have here is also very different, it’s accessing a class level static method (you don’t have to type the whole class path when accessing that method), not an instance method as in the first two.

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

Sidebar

Ask A Question

Stats

  • Questions 218k
  • Answers 218k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer From the Django book, chapter 4: If you can’t think… May 12, 2026 at 11:36 pm
  • Editorial Team
    Editorial Team added an answer Just because two objects have the same hash code does… May 12, 2026 at 11:36 pm
  • Editorial Team
    Editorial Team added an answer That expression $nv[$kk][$jj] is dimensional access. Try to run this… May 12, 2026 at 11:36 pm

Related Questions

My question is pertaining to the best practice for accessing a child object's parent.
I have an internal enterprise application I've developed for my company built on .Net
I have to make a graphical user interface application using the language of my
I have a winform data entry and retrieval program called CaseNotes. This has a
I'm beginning to plan a complete redesign of our departments intranet pages. As it

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.