5 Replies Latest reply on Jul 10, 2006 12:14 PM by Flex harUI

    Trouble Getting Started With Flex

      I am trying to go through the tutorials that come with Flex Builder 2 and cannot get any custom components to work. Projects that have custom components defined in them compile OK but I get a run-time error: Error #1009 Cannot access a property or method of a null object reference...

      It works OK when I open the .swf file but fails when the .swf is embedded in an html wraper.

      If anyone has some idea of what I am doing wrong I would really apreciated hearing it.
        • 1. Re: Trouble Getting Started With Flex
          ntsiii Level 3
          Can you not get ANY custome componets to work? Have you tried a "HelloWorld" level example?

          Or is it complex data-driven components that are the issue?

          Post a sample app.

          Tracy
          1 person found this helpful
          • 2. Re: Trouble Getting Started With Flex
            No, I can't get any custom components to work. I am using an example from the Flex 2 tutorials. It is on the Hello World level. The swf works OK and if I open the file as http://localhost...main.mxml it works OK. It fails when I try to open http://localhost...Main.html. Here is the code:

            Main.mxml
            <?xml version="1.0" encoding="utf-8"?>
            <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute" xmlns="*" xmlns:ns1="myComponents.*">
            <mx:Panel x="20" y="30" width="475" height="400" layout="absolute" title="Main Application Window">
            </mx:Panel>
            <LoginBox x="503" y="30">
            </LoginBox>
            </mx:Application>

            LoginBox.mxml
            <?xml version="1.0" encoding="utf-8"?>
            <mx:Panel xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute" width="275" height="150" title="Member Login">

            <mx:Script>
            <![CDATA[
            private function handleLoginEvent():void {
            lblTest.text = "logging in...";
            //login logic
            }
            ]]>
            </mx:Script>
            <mx:Label x="8" y="20" text="Username"/>
            <mx:Label x="14" y="50" text="Password"/>
            <mx:TextInput x="78" y="18" id="txtUID"/>
            <mx:TextInput x="78" y="48" id="txtPWD" displayAsPassword="true"/>
            <mx:Button x="188" y="78" label="Login" click="handleLoginEvent()"/>
            <mx:Label x="78" y="82" text="Label" id="lblTest"/>
            </mx:Panel>

            I have been wondering if I have a configuration issue. I am confused about the architecture of Flex applications - particularly when Coldfusion is also involved.

            Dan
            • 3. Re: Trouble Getting Started With Flex
              Flex harUI Adobe Employee
              What's in the html wrapper?
              • 4. Re: Trouble Getting Started With Flex
                The html file:

                <!-- saved from url=(0014)about:internet -->
                <html lang="en">
                <head>
                <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
                <title>Main</title>
                <script src="AC_OETags.js" language="javascript"></script>
                <style>
                body { margin: 0px; overflow:hidden }
                </style>
                <script language="JavaScript" type="text/javascript">
                <!--
                // -----------------------------------------------------------------------------
                // Globals
                // Major version of Flash required
                var requiredMajorVersion = 9;
                // Minor version of Flash required
                var requiredMinorVersion = 0;
                // Minor version of Flash required
                var requiredRevision = 0;
                // -----------------------------------------------------------------------------
                // -->
                </script>
                </head>

                <body scroll="no">
                <script language="JavaScript" type="text/javascript" src="history.js"></script>
                <script language="JavaScript" type="text/javascript">
                <!--
                // Version check for the Flash Player that has the ability to start Player Product Install (6.0r65)
                var hasProductInstall = DetectFlashVer(6, 0, 65);

                // Version check based upon the values defined in globals
                var hasRequestedVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);


                // Check to see if a player with Flash Product Install is available and the version does not meet the requirements for playback
                if ( hasProductInstall && !hasRequestedVersion ) {
                // MMdoctitle is the stored document.title value used by the installation process to close the window that started the process
                // This is necessary in order to close browser windows that are still utilizing the older version of the player after installation has completed
                // DO NOT MODIFY THE FOLLOWING FOUR LINES
                // Location visited after installation is complete if installation is required
                var MMPlayerType = (isIE == true) ? "ActiveX" : "PlugIn";
                var MMredirectURL = window.location;
                document.title = document.title.slice(0, 47) + " - Flash Player Installation";
                var MMdoctitle = document.title;

                AC_FL_RunContent(
                "src", "playerProductInstall",
                "FlashVars", "MMredirectURL="+MMredirectURL+'&MMplayerType='+MMPlayerType+'&MMdoctitle='+MMdoctitle+"" ,
                "width", "100%",
                "height", "100%",
                "align", "middle",
                "id", "Main",
                "quality", "high",
                "bgcolor", "#869ca7",
                "name", "Main",
                "allowScriptAccess","sameDomain",
                "type", "application/x-shockwave-flash",
                "pluginspage", " http://www.macromedia.com/go/getflashplayer"
                );
                } else if (hasRequestedVersion) {
                // if we've detected an acceptable version
                // embed the Flash Content SWF when all tests are passed
                AC_FL_RunContent(
                "src", "Main",
                "width", "100%",
                "height", "100%",
                "align", "middle",
                "id", "Main",
                "quality", "high",
                "bgcolor", "#869ca7",
                "name", "Main",
                "flashvars",'historyUrl=history.htm%3F&lconid=' + lc_id + '',
                "allowScriptAccess","sameDomain",
                "type", "application/x-shockwave-flash",
                "pluginspage", " http://www.macromedia.com/go/getflashplayer"
                );
                } else { // flash is too old or we can't detect the plugin
                var alternateContent = 'Alternate HTML content should be placed here. '
                + 'This content requires the Macromedia Flash Player. '
                + '<a href=http://www.macromedia.com/go/getflash/>Get Flash</a>';
                document.write(alternateContent); // insert non-flash content
                }
                // -->
                </script>
                <noscript>
                <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
                id="Main" width="100%" height="100%"
                codebase=" http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab">
                <param name="movie" value="Main.swf" />
                <param name="quality" value="high" />
                <param name="bgcolor" value="#869ca7" />
                <param name="allowScriptAccess" value="sameDomain" />
                <embed src="Main.swf" quality="high" bgcolor="#869ca7"
                width="100%" height="100%" name="Main" align="middle"
                play="true"
                loop="false"
                quality="high"
                allowScriptAccess="sameDomain"
                type="application/x-shockwave-flash"
                pluginspage=" http://www.macromedia.com/go/getflashplayer">
                </embed>
                </object>
                </noscript>
                <iframe name="_history" src="history.htm" frameborder="0" scrolling="no" width="22" height="0"></iframe>
                </body>
                </html>
                • 5. Re: Trouble Getting Started With Flex
                  Flex harUI Adobe Employee
                  The wrapper looks ok. Time to start from scratch. Compile a one-file MXML, see if it works by hitting the wrapper.

                  When you say it fails, what happens?
                  1 person found this helpful