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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T00:54:05+00:00 2026-05-19T00:54:05+00:00

From this tutorial http://www.brighthub.com/internet/web-development/articles/11010.aspx I found the code below. Is there a way to

  • 0

From this tutorial http://www.brighthub.com/internet/web-development/articles/11010.aspx
I found the code below. Is there a way to break this out so the mxml file just has the mxml, and the code between the script tags is put in an actionscript file?

Thanks.

-Nick

<mx:Application
    xmlns:mx="http://www.adobe.com/2006/mxml"
    layout="absolute"
    width="600"
    height="400"
    frameRate="100"
    creationComplete="CreationComplete()"
    enterFrame="EnterFrame(event)">
    <mx:Script><![CDATA[
        public function CreationComplete():void
        {

        }

        public function EnterFrame(event:Event):void
        {

        }
    ]]></mx:Script>
</mx:Application>
  • 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-19T00:54:06+00:00Added an answer on May 19, 2026 at 12:54 am

    There are several ways of achieving this in Flex:

    • Put the AS code in a .as file and use the “source=yourfile.as” attribute in the Script tag:

    <mx:Script source="yourfile.as" />

    You can also use the includes="yourfile.as" declaration w/in the Script tag:

    <mx:Script
        <![CDATA[
            include "yourfile.as";
    
            //Other functions
        ]]>
    </mx:Script>
    

    • Use a Code-Behind pattern where you define the code in an AS file which extends the visual component you want your MXML file to extend. Then your MXML file simple extends the AS file and you have (via inheritance) access to all the code. It would look something like this (I’m not sure if this would work for the main MXML file which extends Application):

    AS File:

    package {
        public class MainAppClass {
            //Your imports here
            public function CreationComplete():void {
            }
            public function EnterFrame(event:Event):void {
            }
        }
    }
    

    MXML File:

    <component:MainAppClass xmlns:component="your namespace here"
                            xmlns:mx="http://www.adobe.com/2006/mxml"
                            layout="absolute"
                            width="600"
                            height="400"
                            frameRate="100"
                            creationComplete="CreationComplete()"
                            enterFrame="EnterFrame(event)">
    </component:MainAppClass>
    

    • Use a framework to inject the functionality you are looking for as a type of “model” which contains the data-functionality you will use. It would look something like this in Parsley:

          <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
                  layout="absolute"
                  width="600"
                  height="400"
                  frameRate="100"
                  creationComplete="model.CreationComplete()"
                  enterFrame="model.EnterFrame(event)">
      
                  <mx:Script>
                      <![CDATA[
                          [Inject]
                          [Bindable]
                          public var model:YourModelClass;
                      ]]>
                 </mx:Script>
         </mx:Application>
      

    Two frameworks which come to mind which can help w/injection are Mate or Parsley.


    I’m not sure if the code-behind pattern works with the main MXML file (which extends Application), so if you’re having problems, you might try breaking out the content in your Main MXML file into a separate component which is included in Main. It might look something like this:

    Main.mxml:

    <mx:Application blah,blah,blah>
        <component:YourComponent />
    </mx:Application>
    

    YourComponent.mxml:

    <component:YourComponentCodeBehind creationComplete="model.creationComplete()"...>
      //Whatever MXML content you would have put in the Main file, put in here
    </component:YourComponentCodeBehind>
    

    YourComponentCodeBehind.as

    package {
        class YourComponentCodeBehind {
            //Whatever AS content you would have put in the Main .as file, put in here
        }
    }
    

    From what I’ve been able to gather from Flex architecture, this is a very common way of setting up your application: your main MXML includes a single “view” which is the entry-point to the rest of your application. This view the contains all other views which comprise the app.

    Hope that makes sense 🙂

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

Sidebar

Related Questions

Googled out- could use some help here. I followed this excellent tutorial here (http://www.malteahrens.com/#/blog/howto-onenote-dev/)
i am using a php script (followed this tutorial http://www.bitconsultants.net/2010/geocoding-with-google-maps-and-the-zend-framework/ ) to get the
This code is from Prototype.js . I've looked at probably 20 different tutorials, and
I am doing [this tutorial][1] over at www.asp.net. It is written for ASP.NET MVC
From this post . One obvious problem is scalability/performance. What are the other problems
From this question , a neat answer about using COALESCE to simplify complex logic
So from this string: name[id] I need this: id I used str.split ('[]'), but
Coming from this question , I have a wxComboCtrl with a custom popup made
This came up from this answer to a previous question of mine . Is
This question follows on from this vim search question I have a setting in

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.