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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T06:19:11+00:00 2026-05-11T06:19:11+00:00

If I include a an external actionscript file in a flex mxml file, I

  • 0

If I include a an external actionscript file in a flex mxml file, I get different behaviours at compile time depending on the method used. Using an mx script tag with a source attribute or an include statement, then compiling the file gives errors like:

Error: Packages cannot be nested.

If use import these errors go away and the file compiles but then I have problems when trying to instantiate the class.

    import lib.journal;     public var testing:journal = new journal();     testing.init(); 

which gives:

Error: Access of undefined property testing.

Can anyone explain what is going on here? What effect does including the file as opposed to importing it have on packages and scope?

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. 2026-05-11T06:19:11+00:00Added an answer on May 11, 2026 at 6:19 am

    To answer the more general question: importing is the preferred way of including external files. In my opinion the include statement should be only used when nothing else will do as it makes things a bit more difficult to debug if something goes wrong and makes code usually more difficult to read and comprehend. Assaf’s description of what import and include do is correct.

    And then for the more specific problem you seem to have: you’re probably trying to do the testing.init(); right there in the <script> block — try putting it in a method. You should only have things like import statements and member declarations (variables, functions) directly in the script block and statements like this within functions.

    You’re seeing that error message because when you’re calling the init() method of this object, it hasn’t been created yet — that statement will be executed when the definition of the class that your MXML file represents is loaded; what you want is to have it executed when a particular instance of this class has been created, and you can do that by calling it in the constructor of the class (this is, as far as I know, not possible when you’re writing a class using MXML, so read on:) or for example in a handler function for the FlexEvent.CREATION_COMPLETE (or creationComplete in terms of MXML tag attributes) event (see the example below.)

    Try something like this:

    <?xml version='1.0' encoding='utf-8'?> <mx:Application      xmlns:mx='http://www.adobe.com/2006/mxml'     width='800' height='600'     creationComplete='creationCompleteHandler();' >     <mx:Script>         <![CDATA[          import lib.Journal;          public var testing:Journal = new Journal();          private function creationCompleteHandler():void         {             testing.init();         }          ]]>     </mx:Script>  </mx:Application> 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 107k
  • Answers 107k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer There's nothing built-in to do this. Would you want the… May 11, 2026 at 9:02 pm
  • Editorial Team
    Editorial Team added an answer So, good news and bad news. Here's the good news.… May 11, 2026 at 9:02 pm
  • Editorial Team
    Editorial Team added an answer found this code here private void btnGetPrinters_Click(object sender, EventArgs e)… May 11, 2026 at 9:02 pm

Related Questions

We have an external .js file that we want to include in a number
Can anyone explain how compilation works? I can't seem to figure out how compilation
I am looking to distribute an open source iPhone app and I have a
I wrote a simple program that reads the characters from external device (bar code

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.