5 Replies Latest reply on Jul 31, 2008 3:32 PM by Newsgroup_User

    Excercise 2.3

    EngHarley
      Hello Nancy,

      These videos are great to people exploring Flex for the first time, like me.

      Well, now back to business...I've been following the videos and excercises step by step; everything was working great until Excercise 2.3 in the Step 40 (Use the custom event class)

      In this step I'm supposed to locate the clickHandler function, but we never added to the code of this function before, right?

      What I need to now is where to put this function...I tried to add it in the Script with the rest of the functions but it seems to be something wrong, it gives me some errors in the statement

      var optionSelectEvent:OptionSelectEvent = new OptionSelectEvent("optionSelected",selection);
      dispatchEvent(optionSelectEvent);

      Could you post or upload the code of the files in order to compare and locate the errors more easly??

      Thanks a lot, again, great tutorial.

      Regards,
      Sergio
        • 1. Re: Excercise 2.3
          Level 7
          > These videos are great to people exploring Flex for the first time, like
          > me.

          They aren't horrible .. but they have several errors and they run through
          screens full of information before you have time to read them. I have to
          use the pause a lot. Wait till you get to Day 3. :)
          >
          > Well, now back to business...I've been following the videos and excercises
          > step by step; everything was working great until Excercise 2.3 in the Step
          > 40
          > (Use the custom event class)
          >
          > In this step I'm supposed to locate the clickHandler function, but we
          > never
          > added to the code of this function before, right?

          We did. We created the function in Step 5. We added the variable in Step
          6. We created a second variable in Step 10 and dispatched an event in Step
          11.
          >
          > What I need to now is where to put this function...I tried to add it in
          > the
          > Script with the rest of the functions but it seems to be something wrong,
          > it
          > gives me some errors in the statement

          It works.
          >
          > var optionSelectEvent:OptionSelectEvent = new
          > OptionSelectEvent("optionSelected",selection);
          > dispatchEvent(optionSelectEvent);

          Do you have this line?
          var selection:String = event.target.label;

          If you didn't define the first variable, selection, then the Event won't
          know where to get the second parameter.

          >
          > Could you post or upload the code of the files in order to compare and
          > locate
          > the errors more easly??

          Here's my entire script block:

          <mx:Script>

          <![CDATA[

          import events.OptionSelectEvent;

          private function clickHandler(event:Event):void{

          var selection:String = event.target.label;

          var optionSelectEvent:OptionSelectEvent = new
          OptionSelectEvent("optionSelected", selection);

          dispatchEvent(optionSelectEvent);

          }

          ]]>

          </mx:Script>

          Not sure why that insists on double spacing .. maybe it won't post that way.
          >
          > Thanks a lot, again, great tutorial.

          You don't think I wrote this, do you? :) I'm like you .. although I have
          done a bit with Flex, but I wanted to see what this thing was and learn
          shortcuts, etc .. make sure my coding is what I should be doing .. stuff
          like that.

          It's not bad .. although Day Three is disappointing so far. The examples
          are Java only .. you would have thought ADOBE would have used a Cold Fusion
          example, wouldn't you? Or at least provided code for CF and PHP. The funny
          thing is while Flex may love JAVA, JSP pages are not going to be supported
          in Dreamweaver with CS4 and beyond so this leaves a developer chasm, IMO.
          Course my first choice would be ASP Classic and I'm really out of luck using
          that! ;)

          Good luck!
          Nancy



          • 2. Excercise 2.3
            EngHarley Level 1
            Nancy,
            Thanks for the help and patience, I am eager to learn Flex, practically nobody knows Flex Development here in my city.

            I am looking forward to continue the one week tutorial...are there going to be any excercises with Flex + Data Base integration??

            Well here is my script. I made the modifications and problem solve...was just a typo...:S

            But when I try to Handle the custom event class (STEP 44-48) and save to continue to debug, FlexBuilder gives me an error...in line

            77:<comp:Options x="0" y="26" optionSelected="optionHandler(event)"/>

            Error 1118:: Implicit coercion of a value with static type flash.events:Event to a possibly unrelated type events:OptionSelectEvent.

            here is my AdobeODT.mxml code:

            <?xml version="1.0" encoding="utf-8"?>
            <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml"
            layout="vertical"
            backgroundColor="#FFFFFF"
            horizontalAlign="left"
            paddingTop="5"
            creationComplete="init()"
            xmlns:comp="components.*">


            <mx:Script>
            <![CDATA[
            import components.Options;
            import mx.events.ListEvent;
            import mx.collections.ArrayCollection;
            import mx.rpc.events.FaultEvent;
            import mx.controls.Alert;
            import mx.rpc.events.ResultEvent;
            import events.OptionSelectEvent;


            [Bindable] private var roomList:ArrayCollection;
            [Bindable] public var selectedOptions:ArrayCollection = new ArrayCollection();

            private function clickHandler(event:Event):void{
            var selection:String = event.target.label;
            var optionSelectEvent:OptionSelectEvent = new OptionSelectEvent("optionSelected",selection);
            dispatchEvent(optionSelectEvent);
            }

            private function optionHandler(event:OptionSelectEvent): void{
            /*Alert.show("A checkbox was checked");*/

            }

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

            private function changeHandler(event:ListEvent): void{

            }
            private function init():void{
            rooms.send();
            }
            private function httpResultHandler(event:ResultEvent):void{
            roomList= event.result.rooms.room;
            }

            ]]>
            </mx:Script>

            <mx:Metadata>
            [Event(name="optionSelected", type="events.OptionSelectEvent")]
            </mx:Metadata>

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

            </mx:HTTPService>

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

            <mx:HBox>
            <mx:Text x="10" y="41" text="111 49th Ave, Denver, CO 80634."/>
            <mx:Text x="208" y="41" text="Phone: 303-555-1234"/>
            <mx:Text x="345" y="41" text="Fax: 303-555-1234"/>
            </mx:HBox>

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

            <mx:Canvas height="100%">

            <mx:Label x="0" text="Please select any additional amenities needed
            for your room. Our staff will contact you to finalize your reservation."/>

            <comp:Options x="0" y="26" optionSelected="optionHandler(event)"/> /*ERROR*/

            <mx:Label x="0" y="116" text="Rooms Available:"/>
            <mx:Label x="116" y="26" id="mySelection"/>

            <mx:List x="0" y="142" id="dg" width="250"
            dataProvider="{roomList}"
            itemClick="changeHandler(event)"
            labelField="name">
            </mx:List>
            <comp:ReservationForm x="368" y="114" width="318" height="450"/>

            </mx:Canvas>

            </mx:Application>

            • 3. Re: Excercise 2.3
              Level 7
              > Thanks for the help, I am eager to learn Flex, practically nobody knows
              > Flex
              > Development here in my city.

              that's good .. where you from?
              >
              > I am looking forward to continue the one week tutorial...are there going
              > to
              > be any excercises with Flex + Data Base integration?? not just XML data
              > sources...

              I hope so .. the third part is doing remoting with Flex Data Services .. but
              sadly, the examples are all Java. Why on earth they would do THAT, I
              haven't a clue.

              Good for you on the script .. glad you got it going.

              Nancy



              • 4. Re: Excercise 2.3
                EngHarley Level 1
                I am from Mexicali, Mexico....in Baja California...I was thinking about taking the Adobe ColdFusion Developer Certification but the current cert. is to CFMX7... but I am not sure to be fully prepared...hehe..

                I was one of the first guys (I like to think) to introduce ColdFusion Development in my class....when I was in the University...in those days the teachers were starting to teach us Dynamic Pages with JSPs...but honestly I never liked JSP... then I discovered Dynamic Pages Development with ColdFusion and loved it....

                And now I am trying to learn Flex...my goal is to master Flex to increase the human interaction in the interfaces design with ColdFusion backing me up with the database management...


                Oh well...Nancy did you found why the example is giving me the error 77:<comp:Options x="0" y="26" optionSelected="optionHandler(event)"/>

                Error 1118: Implicit coercion of a value with static type flash.events:Event to a possibly unrelated type events:OptionSelectEvent.
                ????
                • 5. Re: Excercise 2.3
                  Level 7

                  "EngHarley" <harley1719@hotmail.com> wrote in message
                  news:g6t715$m82$1@forums.macromedia.com...
                  >I am from Mexicali, Mexico....in Baja California...I was thinking about
                  >taking
                  > the Adobe ColdFusion Developer Certification but the current cert. is to
                  > CFMX7... but I am not sure to be fully prepared...hehe..

                  > Oh well...Nancy did you found why the example is giving me the error
                  > 77:<comp:Options x="0" y="26" optionSelected="optionHandler(event)"/>
                  >
                  > Error 1118: Implicit coercion of a value with static type
                  > flash.events:Event
                  > to a possibly unrelated type events:OptionSelectEvent.
                  > ????
                  >

                  Oh .. I had that error .. I remember that I took out one line of code and it
                  solved it .. put it back and I got that error about 6 times. I think I
                  finally found a typo in the function itself and once I fixed that, it was
                  all good.

                  I did that exercise yesterday morning .. I'll see if I can find what caused
                  that in my code and what I did to fix it.

                  Nancy