jwallace.us

tech, tunes, and other stuff

Adobe to Apache Flex

Some time ago Adobe open sourced their Flex programming language over to Apache. I have some old Adobe Flex based programs that I wanted to move over to using the new Apache Flex. After downloading the new SDK, I tried to compile the Flex source code, and I was presented the following error message:

Error: unable to open '{playerglobalHome}/11.1/playerglobal.swc

The fix for this error is to go into the Apache Flex SDK installation directory and do the following.

First you will need the playerglobal.swc file. Currently the only version supported by Apache is 11.1. Download it here: http://fpdownload.macromedia.com/get/flashplayer/updaters/11/playerglobal11_1.swc

Next you’ll want to put it in the location the Apache Flex SDK will be expecting it. On my system, I would do this:

mkdir -p /home/john/apache-flex-sdk-4.15.0-bin/frameworks/libs/player/11.1

With that command, the player/11.1 directories would be created. Now copy the file into the location. Note we are renaming the file in the process:

cp playerglobal11_1.swc /home/john/apache-flex-sdk-4.15.0-bin/frameworks/libs/player/11.1/playerglobal.swc

Now you want to copy the env-template.properties file to env.properties:

cp /home/john/apache-flex-sdk-4.15.0-bin/env-template.properties /home/john/apache-flex-sdk-4.15.0-bin/env.properties

Finally, edit the env.properties file and find the env.PLAYERGLOBAL_HOME setting. Change it to the path that contains the :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#
# PLAYERGLOBAL_HOME is a directory which contains one or more subdirectories.
# The name of each subdirectory corresponds to a supported target player version and
# in each of the subdirectories is the playerglobal.swc that corresponds to that target
# player.  The default
#
# For this sample directory structure, set PLAYERGLOBAL_HOME to the full path of the
# player directory.
#
#       - player (dir)
#           - 11.1 (dir)
#               playerglobal.swc (file)
#
#env.PLAYERGLOBAL_HOME=
env.PLAYERGLOBAL_HOME=/home/john/apache-flex-sdk-4.15.0-bin/frameworks/libs/player/

You’re done. To test this you can compile the sample program below.

Use the following command to compile: mxmlc -compiler.optimize -compiler.as3 FlashVersion.mxml

FlashVersion.mxml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?xml version="1.0"?>
<!-- FlashVersion.mxml -->
<s:Application
    xmlns:fx="http://ns.adobe.com/mxml/2009"
    xmlns:s="library://ns.adobe.com/flex/spark"
    xmlns:mx="library://ns.adobe.com/flex/mx">

    <s:layout>
        <s:VerticalLayout/>
    </s:layout>

    <fx:Script>
        <![CDATA[
        import flash.system.Capabilities;

        private function reportVersion():String {
            if (Capabilities.isDebugger) {
                return "Flash Debug";
            } else {
                return "Flash Player";
            }
        }
        private function reportType():String {
            return Capabilities.playerType + " (" + Capabilities.version + ")";
        }
        ]]>
    </fx:Script>

    <s:Label text="{reportVersion()}"/>
    <s:Label text="{reportType()}"/>

</s:Application>