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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T08:25:03+00:00 2026-05-14T08:25:03+00:00

I’ve created a custom component in Flex, and I’ve created it from the main

  • 0

I’ve created a custom component in Flex, and I’ve created it from the main application with actionscript. Successively I invoke its “setName” method to pass a String.

I get the following run-time error (occurring only if I use the setName method):

TypeError: Error #1009: Cannot access a property or method of a null object reference.

I guess I get it because I’m calling to newUser.setName method from main application before the component is completely created.

How can I ask actionscript to “wait” until when the component is created to call the method ? Should I create an event listener in the main application waiting for it ? I would prefer to avoid it if possible.

Here is the code:

Main app

...
newUser = new userComp();
//newUser.setName("name");

Component:

<?xml version="1.0" encoding="utf-8"?>
<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" width="100" height="200" >

<mx:Script>
    <![CDATA[


        public function setName(name:String):void {
            username.text = name;
        }

       public function setTags(Tags:String):void {

        }

    ]]>
    </mx:Script>

    <mx:HBox id="tagsPopup" visible="false">
        <mx:LinkButton label="Tag1" />
        <mx:LinkButton label="Tag2" />
        <mx:LinkButton label="Tag3" />      
    </mx:HBox>

    <mx:Image source="@Embed(source='../icons/userIcon.png')"/>
    <mx:Label id="username" text="Nickname" visible="false"/>

</mx:VBox>

thanks

  • 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-14T08:25:03+00:00Added an answer on May 14, 2026 at 8:25 am

    You get the error message because the Label component with id “username” has not been initialized when you call setName function.

    you can create a property in UserComp, and set Label’s text property binded to it. And in your setName function, you assign the value to the property just created. When the Label component is created, it will use the value from the property to show on the screen.

    <?xml version="1.0" encoding="utf-8"?>
    <mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" width="100" height="200" >
    
    <mx:Script>
        <![CDATA[
            [Bindable]
            private var _name;
            public function setName(name:String):void {
                _name=name;
            }
    
           public function setTags(Tags:String):void {
    
            }
    
        ]]>
        </mx:Script>
    
        <mx:HBox id="tagsPopup" visible="false">
            <mx:LinkButton label="Tag1" />
            <mx:LinkButton label="Tag2" />
            <mx:LinkButton label="Tag3" />      
        </mx:HBox>
    
        <mx:Image source="@Embed(source='../icons/userIcon.png')"/>
        <mx:Label id="username" text="{_name}" visible="false"/>
    
    </mx:VBox>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 444k
  • Answers 444k
  • 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 Typically it's best to push the responsibility of infrastructure configuration… May 15, 2026 at 6:32 pm
  • Editorial Team
    Editorial Team added an answer Your code will work fine as it is, assuming each… May 15, 2026 at 6:32 pm
  • Editorial Team
    Editorial Team added an answer Yes. You are posting an image to their stream. Attachment… May 15, 2026 at 6:32 pm

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.