12 Replies Latest reply on Oct 25, 2008 10:57 AM by sort2008

    Problem with the Code in exercise 1.3

      Can you provide the final code for the exercises so we can see where we went wrong. I keep getting an undefined error.
        • 1. Re: Problem with the Code in exercise 1.3
          anirudhs Level 2
          Hi,

          Better yet, post the code that you have written so we can exactly help you out with what has gone wrong.
          • 2. Re: Problem with the Code in exercise 1.3
            Level 7
            That exercise worked for me. Here is my final code.

            <?xml version="1.0" encoding="utf-8"?>

            <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute"
            backgroundColor="#FFFFFF" creationComplete="init()">

            <mx:Script>

            <![CDATA[

            import mx.events.ListEvent;

            import mx.collections.ArrayCollection;

            import mx.rpc.events.FaultEvent;

            import mx.rpc.events.ResultEvent;

            import mx.controls.Alert;

            [Bindable]

            private var roomList:ArrayCollection;

            private function changeHandler(event:ListEvent):void{

            }

            private function init():void{

            rooms.send();

            }

            private function httpFaultHandler(event:FaultEvent):void{

            Alert.show("There was a problem","Error");

            }

            private function httpResultHandler(event:ResultEvent):void{

            roomList = event.result.rooms.room;

            }

            ]]>

            </mx:Script>

            <mx:HTTPService id="rooms" url="assets/roomList.xml"
            fault="httpFaultHandler(event)" result="httpResultHandler(event)"/>


            <mx:Label x="10" y="10" text="XYZ Convention Center" fontSize="21"
            fontWeight="bold"/>

            <mx:Text x="10" y="41" text="111 49th Ave, Denver, CO 80634"/>

            <mx:Text x="208" y="41" text="Phone: 303-555-1212"/>

            <mx:Text x="345" y="41" text="Fax: 303-555-1234"/>

            <mx:Label x="10" y="72" text="Room Reservation System" fontSize="14"
            fontWeight="bold"/>

            <mx:Label x="10" y="108" text="Rooms Available:"/>

            <mx:Label x="121" y="108" id="mySelection"/>

            <mx:List id="dg" x="10" y="134" width="250"

            dataProvider="{roomList}"

            itemClick="changeHandler(event)"

            labelField="name" />

            </mx:Application>



            The only difference is that the example put mx:List with a closing /mx:List
            tag and I used one tag with the / at the end of it. I have always been
            taught that one shouldn't have empty tags (nothing in between) so I only use
            their way when there is something in the middle. I got their results so I
            don't think it matters.

            Nancy




            • 3. Re: Problem with the Code in exercise 1.3
              cqprod
              I'm getting a different error.

              [SWF] C:\adobeFlexTraining\AdobeODT\bin-debug\AdobeODT.swf - 1,033,968 bytes after decompression
              *** Security Sandbox Violation ***
              Connection to assets/roomList.xml halted - not permitted from file:///C:/adobeFlexTraining/AdobeODT/bin-debug/AdobeODT.swf

              Here's my code ....

              <?xml version="1.0" encoding="utf-8"?>
              <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute"
              backgroundColor="#FFFFFF" creationComplete="init()">
              <mx:Script>
              <![CDATA[
              import mx.events.ListEvent;
              import mx.collections.ArrayCollection;
              import mx.rpc.events.FaultEvent;
              import mx.controls.Alert;
              import mx.rpc.events.ResultEvent;

              private function changeHandler(event:ListEvent):void {

              }

              [Bindable]
              private var roomList:ArrayCollection;

              private function init():void{
              rooms.send();
              }

              private function httpFaultHandler(event:FaultEvent):void {
              Alert.show("There was a problem", "Error");
              }

              private function httpResultHandler(event:ResultEvent):void {

              }

              ]]>
              </mx:Script>
              <mx:HTTPService id="rooms" url="assets/roomList.xml"
              fault="httpFaultHandler(event)"
              result="httpResultHandler(event)" />

              <mx:Label x="10" y="10" text="XYZ Covention Center" fontWeight="bold" fontSize="21"/>
              <mx:Text x="10" y="41" text="111 49th Ave. Denver, CO 80634"/>
              <mx:Text x="208" y="41" text="303-555-1212"/>
              <mx:Text x="345" y="41" text="Fax: 303-555-1234"/>
              <mx:Label x="10" y="72" text="Room Reservation System" fontWeight="bold" fontSize="14"/>
              <mx:Label x="10" y="108" text="Rooms Available"/>
              <mx:Label x="121" y="108" id="mySelection"/>
              <mx:List x="10" y="134" id="dg" width="250"
              dataProvider="{roomList}"
              itemClick="changeHandler(event)"></mx:List>

              </mx:Application>

              I'm not showing any errors when I save, this only shows up when I run debugging. (Step 24)

              Thanks
              • 4. Re: Problem with the Code in exercise 1.3
                cqprod Level 1
                Never mind ... I was able to run the exact same code on my personal computer, there must be some permission issues I missed on my machine at work.

                Thanks anyway,
                :-)
                • 5. Re: Problem with the Code in exercise 1.3
                  JustStartingOut
                  There appears to be a typo in the PDF file people. Where it says to make the file "assets/roomList.xml", you need to change to go up one directory first, so it should be "../assets/roomList.xml". It should run for you then.
                  • 6. Re: Problem with the Code in exercise 1.3
                    JustStartingOut Level 1
                    Woops, my mistake. I initially unzipped the assets ZIP file into AdobeODT, instead of AdobeODT/src (as instructed). Maybe the original poster did something similar?
                    • 7. Re: Problem with the Code in exercise 1.3
                      smeagol-fish Level 1
                      I get the same error message in the console:

                      ############################################################
                      [SWF] C:\adobeFlexTraining\AdobeODT\bin-debug\AdobeODT.swf - 1,033,781 bytes after decompression
                      *** Security Sandbox Violation ***
                      Connection to assets/roomList.xml halted - not permitted from file:///C:/adobeFlexTraining/AdobeODT/bin-debug/AdobeODT.swf

                      ############################################################

                      Any Adobe representatives can explain what that error means or if its a configuration problem on my Adobe Flex installation?
                      • 8. Re: Problem with the Code in exercise 1.3
                        anirudhs Level 2
                        Hi,

                        If you are running from Flex builder, extract the assets folder to the src folder. Flex Builder will automatically copy it to bin-debug folder when you hit Run. Leave the url attribute of HTTPService to assets/roomList.xml itself.
                        • 9. Re: Problem with the Code in exercise 1.3
                          smeagol-fish Level 1
                          I have followed your sugesstion which is what the tutorial told me to do as well. But I still get the same error.

                          >Flex Builder will automatically copy it to bin-debug folder when you hit Run
                          I can confirm the asset folder is present in the bin-debug folder

                          do I need to add a "cross-domain" policy file to fix this?
                          • 10. Re: Problem with the Code in exercise 1.3
                            smeagol-fish Level 1
                            I Solved my problem by going to http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04.htm l#117502 and in the "Global Security Settings" add the c:/adobeFlexTraining folder so that Flash player knows its a trusted location.

                            I think this needs to be documented in the Tutorial.
                            • 11. Re: Problem with the Code in exercise 1.3
                              BruceEvent
                              I agree rockwallgeek. Thank you for the info!

                              • 12. Re: Problem with the Code in exercise 1.3
                                sort2008
                                Running excercise 3 (day 1) as described, you will get a fault with Error #2148 (using the most recent releases of the player). Whether you see this error or not is dependent on you player version AND build.

                                If you examine the fault and see "cannot access local resource assets/roomList.xml. Only local-with-filesystem and trusted local SWF files may access local resources.", you can correct this by:
                                1. In Eclipse, go to Project Properties and select the Flex Compiler. Add -use-network=false to the "additional compiler options" edit box; e.g. -locale en_US -use-network=false. This will, of course, prevent you from accessing network resources with this project. If using the command line compiler, add -use-network=false to your build command.
                                2. Package and deploy this to a server; you might still end up having to set the cross-domain policy.
                                3. Make this an AIR project instead of a Flex Project You might have to adjust the path.
                                4. Change the player security settings as described in the previous post.