The following example shows how you can determine your Flex SDK version within a Flex application by using the internal mx_internal::VERSION property.

You can also find the version number by doing one of the following:
(a) Viewing the flex-sdk-description.xml file in your Flex SDK’s root directory:

<?xml version="1.0"?>
<flex-sdk-description>
    <name>Flex 4.0</name>
    <version>4.0.0</version>
    <build>3934</build>
</flex-sdk-description>

(b) At a command prompt, navigate to your Flex SDK’s /bin/ directory and type mxmlc -version:

C:\\dev\\flexSDKs\\4.0.0.3934\\bin>mxmlc -version
Version 4.0.0 build 3934

Full code after the jump.

Since this example uses the mx_internal namespace, you can’t always depend on this behavior to work in future versions of the Flex SDK. Use at your own risk.

View MXML

<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2008/10/29/determining-your-flex-sdk-version-number/ -->
<mx:Application name="mx_internal_VERSION_test"
        xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white">

    <mx:Label text="{mx_internal::VERSION}" />

</mx:Application>

View source is enabled in the following example.

Due to popular demand, here is the “same” example in a more ActionScript friendly format:

View MXML

<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2008/10/29/determining-your-flex-sdk-version-number/ -->
<mx:Application name="mx_internal_VERSION_test"
        xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white"
        initialize="init();">

    <mx:Script>
        <![CDATA[
            import mx.controls.Label;

            private var lbl:Label;

            private function init():void {
                lbl = new Label();
                lbl.text = mx_internal::VERSION;
                addChild(lbl);
            }
        ]]>
    </mx:Script>

</mx:Application>

Or, you can use data binding (and not get a warning) by using the use namespace, as seen in the following example:

<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2008/10/29/determining-your-flex-sdk-version-number/ -->
<mx:Application name="mx_internal_VERSION_test"
        xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white">

    <mx:Script>
        <![CDATA[
            use namespace mx_internal;
        ]]>
    </mx:Script>

    <mx:Label text="{VERSION}" />

</mx:Application>
 
Tagged with:
 
About The Author

Peter deHaan

Peter deHaan currently works for Adobe on the Flex SDK QA team. While not working on Flex, Flash, and ColdFusion applications, Peter enjoys making up bios and writing in 3rd person. Peter's rarely updated blog can be found at blogs.adobe.com/pdehaan/, actionscriptexamples.com, airexamples.com, and coldfusionexamples.com.

3 Responses to Determining your Flex SDK version number

  1. Mark says:

    Just updated my About Box to show this info. However, the mx_internal::VERSION says that I’m using 3.0.0.0 whereas FlexBuilder is compiling to Flex 3.1.

    How is this possible?

  2. peterd says:

    Mark,

    We may not have updated the VERSION property in 3.1.0.x. Like I say, its an mx_internal property, and it’s one of those “use at your own risk” things. ;)

    Peter

  3. Brian says:

    You can also use FlexVersion.compatibilityVersionString. However, I don’t think they can update the version number without breaking code. Throughout the SDK I see code peppered like this:
    if (FlexVersion.compatibilityVersion

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">

Anti-Spam Protection by WP-SpamFree