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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:24:38+00:00 2026-05-27T05:24:38+00:00

I have not completly understood how custom components work… Let’s assume I have my

  • 0

I have not completly understood how custom components work…

Let’s assume I have my Main.mxml application

<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009" 
       xmlns:s="library://ns.adobe.com/flex/spark" 
       xmlns:mx="library://ns.adobe.com/flex/mx"
       xmlns:local="*">
    <fx:Script>
        <![CDATA[
            private var privateStr:String = "Stringa Private";
            public  var publicStr:String = "Stringa Public";
        ]]>
    </fx:Script>
    <local:AddUser height="100" width="500"/>   
    <s:Label id="lblText" x="120" y="120" width="418" height="115" text="!!!"/>                                    
</s:WindowedApplication>

And the component AddUser.mxml

<?xml version="1.0" encoding="utf-8"?>
<mx:VBox 
    xmlns:fx="http://ns.adobe.com/mxml/2009" 
    xmlns:s="library://ns.adobe.com/flex/spark" 
    xmlns:mx="library://ns.adobe.com/flex/mx"
    creationComplete="initialize_component()">  
    <fx:Script>
        <![CDATA[                                               
            public var btnName:String = "Login";
        private function initialize_component():void
        {
             login.label = btnName;              
            }
            private function doLogin():void
            {
             //some stuff here
            }

        ]]>
    </fx:Script>
    <s:TextInput id="txtuser" x="96" y="36"/>
    <s:TextInput id="txtpass" x="96" y="66"/>
    <s:Button id="login" x="96" y="96" width="128" click="doLogin()" />
</mx:VBox>

I would like that on the Button (login) click I get the publicStr/privateStr that are in the main.mxml…
Am I getting everything wrong? how can I use more components like they are all part of the same application and use the same variables/methods?

  • 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-27T05:24:39+00:00Added an answer on May 27, 2026 at 5:24 am

    It seems like you’re having issues with the idea of encapsulation. Child components shouldn’t know about parent components, and View components shouldn’t do real work, only request work from Controller components. In very simple projects, your top level component can contain the controller logic, but many people prefer to keep it separate even in small projects. How to do this is beyond the scope of this answer.

    So, how should the parent and child properly communicate? Child components should expose properties that the parent (or Framework, if you’re feeling ready to use a dependency injection framework) can populate with only the data the child components need.

    Child components request work from the controller by generating events.

    So, doLogin() would containe something like

    dispatchEvent(new Event('doLogin'));
    

    and the parent component would be listening for this Event. In its handler, you would perform the login. More than likely, your login would be asynchronous, so you’ll need another handler to listen for the login data to come back. When the login data comes back, you will then set the properties on the login View based on the return.

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

Sidebar

Related Questions

I have one main windows form and within that form I have custom controls
I have just started C++ and have come across references and have not understood
I have a an image not covering the background completely of a div. Can
how do i get a list of user that have completed or not completed
I have a mysql problem, my query looks as follows but not complete SELECT
I'm not sure if this is possible (complete non-flash developer speaking), but we have
have not tested on windows. but in ubuntu when u disconnect from the network,
I have not used generics much and so cannot figure out if it is
I have not seen much support for Grails to develop facebook apps.I was just
I have not had to mess with mailto links much. However I now need

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.