Determining your Flex SDK version number

by Peter deHaan on October 29, 2008

in ActionScript

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>

{ 3 comments… read them below or add one }

1 Mark October 30, 2008 at 9:53 am

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?

Reply

2 peterd October 30, 2008 at 9:58 am

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

Reply

3 Brian January 11, 2009 at 9:15 am

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

Reply

Leave a Comment

Sorry, this blog is terrible at eating HTML comments.
If you're pasting any HTML/XML/MXML code, you need to convert your < characters to &lt; and your > characters to &gt; .

You can 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

Previous post:

Next post: