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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:16:31+00:00 2026-05-26T17:16:31+00:00

I’m very new to Flex 4.5 and I created a class (Project.as) with the

  • 0

I’m very new to Flex 4.5 and I created a class (Project.as) with the following code in it:

package classes
{
    public class Project
    {
        public var projectName:String;
        public var description:String;
        public var fileLoc:String;

        public function Project()
        {
            // This is the constructor  
        }

        public function SayHello() {
            import mx.controls.Alert;
            Alert.show('howdy!','Greeting');
        }
    }
}

In my main.mxml file, I have the following code:

<fx:Script>
    <![CDATA[
        import classes.Project;             
        import mx.controls.Alert;

        public var aProject:Project = new Project;
        aProject.SayHello();
    ]]>
</fx:Script>

And Flex Builder is saying this:

1120: Access of undefined property aProject.

Why is it telling me this, and how can I fix it? I don’t see why it’s not working.

  • 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-26T17:16:31+00:00Added an answer on May 26, 2026 at 5:16 pm

    Lots of issues here.

    First, I have never seen anyone put import statements inside a method. Usually they are put between the package and class definition:

    package classes
    {
       import mx.controls.Alert;
    
        public class Project
        {
            public var projectName:String;
            public var description:String;
            public var fileLoc:String;
    
            public function Project()
            {
                // This is the constructor  
            }
    
            public function SayHello() {
                Alert.show('howdy!','Greeting');
            }
        }
    }
    

    Second; the line of ActionSCript code that you write to call a method on your class instance should be placed inside a method; not “random”. Like this:

    <fx:Script>
        <![CDATA[
            import classes.Project;             
            import mx.controls.Alert;
    
            public var aProject:Project = new Project;
            protected function sayHello():void{
              aProject.SayHello();
            }
        ]]>
    </fx:Script>
    

    Some way you’ll want to call that method. A commenter on the original post suggested using creationComplete, which would work. However, you should be cautious about using creationComplete for “constructor-style” code in an MXML Component. preinitialize is better, and the event will fire right after the actual constructor runs. If you need to access any MXML children, have your code in an initialize event handler which runs right after createChildren() runs.

    creationComplete handlers execute right after the component finishes initializing; and people often do things in creationComplete that make the component go through it’s Lifecycle again, updating the display list.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
public static bool CheckLogin(string Username, string Password, bool AutoLogin) { bool LoginSuccessful; // Trim
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text
I've got a string that has curly quotes in it. I'd like to replace
Specifically, suppose I start with the string string =hello \'i am \' me And
I have this code to decode numeric html entities to the UTF8 equivalent character.

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.