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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T03:49:05+00:00 2026-06-06T03:49:05+00:00

I have a parent component, say P, which has function, say Pfunc. I also

  • 0

I have a parent component, say P, which has function, say Pfunc. I also have two child components, say C1 and C2, and their respective function, say C1func and C2func.

How to call any function from any component?

  • 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-06T03:49:06+00:00Added an answer on June 6, 2026 at 3:49 am

    How to call any function from any component?

    From an encapsulation perspective:

    You never should be able to call any function in any component. To “Communicate up” to a parent component, you should make use of event dispatching. To communicate down; you should call a function or set a property. You should never communicate sideways.

    If you want P to execute PFunc, then just execute it:

    this.PFunc();
    

    If you want P to execute C1Func, and C1Func is public, then you can do something like this inside of P:

    C1Instance.C1Func()
    

    If you want P to execute C2Func, and C2Func is public, then you can do something like this inside of P:

    C2Instance.C2Func()
    

    If you want C1, or C2, to call PFunc, then you should dispatch an event like this:

    dispatchEvent(new Event('callPFunc'));
    

    Inside P, there should be an event listener, conceptually like this:

    C1Instance.addEventListener('callPFunc',onCallPFunc);
    
    ....
    // elsewhere in code
    
    protected function onCallPFunc(event:Event):void{
      PFunc();
    }
    

    If you want C1 to call C2Func or C2 to call C1Func, then you’re a bit out of luck. The two components at the same hierarchy level should have no direct interaction with each other. The best way to do that is to dispatch an event; listen for it in the parent, and have the parent call back down to the alternate component.

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

Sidebar

Related Questions

I have parent project parent, which has three modules like: <groupId>com.dummy.bla.bla</groupId> <artifactId>parent</artifactId> <version>1.0-SNAPSHOT</version> <packaging>pom</packaging>
Is there any way to know the parent/component which initiates context menu? I have
I have a component composed of two parts, let's say two Hbox A and
I have a component which has a corresponding persistent. This persistent is of course
I have a tabbed dialog that has 4 tabs. The parent component is an
I have parent/child relationship set up via Node Reference. A Child record can have
If you have Parent has_many :children Child Is there any reason a foreign key
I use Entity Framework 4 and I have parent - child relation with Cascade
I have a parent/child/grandchild type table relationship defined as follows: tableA: parentID description tableB:
I have a parent container with a lot of child elements. Due to animation

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.