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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T15:18:29+00:00 2026-06-13T15:18:29+00:00

I have some common code in my MXML files that I’d like to move

  • 0

I have some common code in my MXML files that I’d like to move to the MXML equivalent of a base class, then have various MXML components subclass from that. What is the syntax for doing this in MXML?

  • 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-06-13T15:18:30+00:00Added an answer on June 13, 2026 at 3:18 pm

    MXML is viewed as an ActionScript generation language; and the current version of the Flex Compiler will translate MXML into ActionScript.

    So, for all intents and purposes, an MXML class is no different than an ActionScript class. For inheritance purposes, an MXML Class can extend an ActionScript class–you do this every time you create a new Application file. An MXML Class can also extend another MXML class; and the approach is no different than extending an ActionScript class.

    First, create your base class in whatever way you prefer. This is a sample class structure which extends a group:

    <?xml version="1.0" encoding="utf-8"?>
    <s:Group xmlns:fx="http://ns.adobe.com/mxml/2009" 
             xmlns:s="library://ns.adobe.com/flex/spark" 
             xmlns:mx="library://ns.adobe.com/flex/mx" width="400" height="300">
        <fx:Declarations>
            <!-- Place non-visual elements (e.g., services, value objects) here -->
        </fx:Declarations>
        <fx:Script>
            <![CDATA[
                // shared ActionScript Code here
            ]]>
        </fx:Script>
    <!-- shared MXML code here -->
    </s:Group>
    

    Let’s assume that you named that file BaseClass.mxml and put it in the directory com.flextras . Your new class that extends the previous class will be something like this:

    <?xml version="1.0" encoding="utf-8"?>
    <flextras:BaseClass 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:flextras="com.flextras.*" width="400" height="300">
        <fx:Declarations>
            <!-- Place non-visual elements (e.g., services, value objects) here -->
        </fx:Declarations>
    </flextras:BaseClass>
    

    In Flash Builder, this is pretty easy just by doing “new –> MXML Component” inside a Flash project.

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

Sidebar

Related Questions

Assume some domain and view objects (that have no common base class) public class
I have some common code that I would like to share between pages and
Quick question about include/requre_once . I have some code that is common to a
I have some common code that gets called while processing the response for every
I have some common code that runs at the beginning of multiple controller actions.
I have some common set up code that I've factored out to a method
I have an express project that accesses some common node code that I keep
I have three JUnit test classes that all had some common code, including identical
I have some common structure that I'd like to use, and I need to
We are using Eclipse+CDT+SVN(Linux). How can we have some common header files in a

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.