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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T21:04:29+00:00 2026-05-22T21:04:29+00:00

I have a headerbar.mxml that is displayed when user swipes_down in my app. The

  • 0

I have a headerbar.mxml that is displayed when user swipes_down in my app. The headerbar.mxml contains a button component I want to run an erase() in the main application window. The main application is a drawing app that contains an erase(). I just don’t know how to call a function from another mxml view file. I thought it would be something like click=”{mainwindow.drawPanel.erase()}”;

EDIT:

protected function onColorChange(event:List):void{
                appHome.drawArea.erase();
            }
  • 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-05-22T21:04:29+00:00Added an answer on May 22, 2026 at 9:04 pm

    To run a function in another view (AKA Component) It depends largely on the architecture. It sounds like you want to run a function in your parent. In which case the ‘encapsulation proper’ method is to dispatch an event from component1; listen for the event in component1s parent; and execute the function from the event listener.

    So, somewhere in headerbar’s parent, add the event listener:

    headerbarInstance.addEventListener('parentDoSomething', onHeaderBarToldMeTo);
    

    I’d probably add this in the constructor if an ActionSCript 3 component, or in a preinitialize event handler if an MXML Component. The ‘parent’ component will also need the listener function:

    protected function onHeaderBarToldMeTo(event:Event):void{
      erase();
    }
    

    When the clicks the button component in headerbar.mxml and this fires off a click event handler inside of headerbar, which needs to dispatch the event, like this:

    protected function onButtonInheaderbarClick(Event:Event):void{
     dispatchEvent(new Event('parentDoSomething'));
    }
    

    And everything should magically work. You may have to bubble the event if the function is not inside a direct child of the parent.

    If you don’t care about encapsulation, you can also just access the parent directly. So your header bar component would do this:

    parent.erase();
    

    It’s simple and straight forward, and should work, but is considered horribly bad practice from a maintenance stand point.

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

Sidebar

Related Questions

I have a couple of view controllers that I want all to share a
So I have this application that someone coded a few years ago and it
I have a problem where the link locations are being printed when the user
I have an issue regarding style my blog. I want to make the header
TL;DR Version : This question has arisen due to the fact that I have
Have some dates in my local Oracle 11g database that are in this format:
I have the following code: <?php if (!$this->Auth->user()) { echo $this->element('header'); } else {
I would like to have more than one button on the right side of
I have a checkbox that triggers a function that opens a small window with
I have a fixed position header bar that is about 40px heigh. It is

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.