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

The Archive Base Latest Questions

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

I got a question about event dispatching and dispatching in flex. My goal is

  • 0

I got a question about event dispatching and dispatching in flex.

My goal is to pass an email address captured in one component (Comp1) and be passed to another (Comp2). These two components are navigator content of a viewstack. The custom event dispatched the email correctly from Comp1 but somehow could not reach Comp2. The application (Main) looks like :

<fx:Script>
    <![CDATA[
        import events.LoginEventComplete;

        protected function loginHandler(event:LoginEventComplete):void
        {
            myViewStack.selectedChild = idViewMain;
        }
    ]]>
</fx:Script>

<s:Panel width="100%" height="100%">
    <mx:ViewStack id="myViewStack" selectedIndex="0" width="100%" height="100%">
        <views:Comp1 id="idViewLogin" login="loginHandler(event)"/>
        <views:Comp2 id="idViewMain"/>
    </mx:ViewStack>
</s:Panel>

The Comp1 looks like

<fx:Metadata>
    [Event(name="login", type="events.LoginEventComplete")]
</fx:Metadata>
<fx:Script>
    <![CDATA[
        import events.LoginEventComplete;

        protected function bnLogIn_clickHandler(event:MouseEvent):void{
            var e:LoginEventComplete = new LoginEventComplete("login");
            e.workemail = tiWorkEmail.text;
            dispatchEvent(e);
        }
    ]]>
</fx:Script>

<fx:Declarations>
    <!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>

<s:layout>
    <s:VerticalLayout verticalAlign="middle" horizontalAlign="center"/>
</s:layout>

<s:Panel width="400" height="500">
    <s:Label text="Email" x="130" y="150"/>
    <s:TextInput id="tiWorkEmail" top="140" left="180" right="60"/>
    <s:Button 
        id="bnLogIn"
        label="Log In"
        top="220" left="180"
        click="bnLogIn_clickHandler(event)"/>
</s:Panel> 

The Comp2 looks like

<fx:Script>
    <![CDATA[
        import events.LoginEventComplete;

        import valueObjects.Employee;

        protected function init():void
        {
            this.addEventListener(LoginEventComplete.LOGIN, mainHandler);
        }

        private function mainHandler(event:LoginEventComplete):void{
            tiWorkEmail.text = event.workemail;
        }

    ]]>
</fx:Script>

<fx:Declarations>

</fx:Declarations>

<s:layout>
    <s:VerticalLayout verticalAlign="middle" horizontalAlign="center"/>
</s:layout>

<s:Label id="idWorkEmail" text="Email"/>
<s:TextInput id="tiWorkEmail"/>

The custom event LoginEventComplete look like

package events
{
import flash.events.Event;
public class LoginEventComplete extends Event
{
public var workemail:String;

public static const LOGIN:String = "login";

public function LoginEventComplete(type:String)
{
  super(type, true, false);
  this.workemail = workemail; 
}

override public function clone():Event
{
  var newEvent:LoginEventComplete = new LoginEventComplete(type);
  newEvent.workemail = workemail;
  return newEvent;
}

}
}

Can someone help please? Many thanks!

Best David W

  • 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-22T18:29:59+00:00Added an answer on May 22, 2026 at 6:29 pm

    You’re realizing one of the problems that any hierarchical view structure has to pass information. This problem can be solved in severals ways, but I feel that I should tell you that you might need to look into an application framework if your application is going to get large. One like Parsley or RobotLegs.

    Now, onto a solution. You won’t be able to use bubbling to go from one sibling component to another, since bubbling goes up the display list (child to parent and so on). You can either listen for the event on the common parent and then push the information into the other sibling, but that’s adding a lot of logic on the parent container.

    An easy fix would be to create a model (a class that just has public properties to store information) that is bindable on the parent and binded into both siblings. Then if one changes the information, the other can receive that same information (or use bindings).

    For example:

    <fx:Script>
        <![CDATA[
            import events.LoginEventComplete;
    
            [Bindable] private var someData:SomeModel = new SomeModel();
    
            protected function loginHandler(event:LoginEventComplete):void
            {
                myViewStack.selectedChild = idViewMain;
            }
        ]]>
    </fx:Script>
    
    <s:Panel width="100%" height="100%">
        <mx:ViewStack id="myViewStack" selectedIndex="0" width="100%" height="100%">
            <views:Comp1 id="idViewLogin" login="loginHandler(event)" data="{someData}/>
            <views:Comp2 id="idViewMain" data="{someData}/>
        </mx:ViewStack>
    </s:Panel>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have got a question about event and bound command. What happens if I
I've got question about wpf xaml style definitions. When I try to set style
Just got a question about generics, why doesn't this compile when using a generic
i got a question about unsigned char array. How can i store an integer
I've got a question about references between projects in a solution. Most of my
I've got a question about testing methods working on strings. Everytime, I write a
i've got a question about how is it possible (if possible :) to use
I've got a question about SimpleDateFormat class and the java.util.Date's compareto method: I'm constructing
Hay I've got a question about relationships. I want to Users to have Friendships.
I've got a question about CSS based popup windows, like those generated by jQuery

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.