8 Replies Latest reply on Jun 5, 2006 10:02 PM by SteveDriveRa

    Tween & Web Service Component Help!

    SteveDriveRa
      I am trying to build a component for which I enter a paramater value, and it calls a web service, retrieves data, then tweens a movieclip based on the value.

      I cannot seem to be able to access the Label within the component to display the data, from within the webservice.onResult call. I am sooooooo lost!!!!!

      I would love some help! I'm in a deadline too!! Aaah actionscript!

        • 1. Re: Tween & Web Service Component Help!
          blemmo Level 1
          'this' inside an event normally refers to the object that holds that event, so inside 'onResult', it refers to the PendingCall object. There's not _parent property in that, so you can't get to the component this way. Instead, try to pass a reference to the component to the event:

          var me = this; // in openService()
          wsGetAllVals.onResult = function (result)
          {
          me.sensorMax = "400";
          trace("All Values received");
          var splitArr:Array = result.split(";");

          me.sensorMax = this.lblMax = splitArr[6].substring(9,15);
          me.sensorMin = this.lblMin = splitArr[5].substring(9,15);
          //sensorUnit =lblUnit = splitArr[3].substring(6,25);
          trace(splitArr);
          trace(sensorMax);

          _root.sensorMax = me.sensorMax;

          trace(_root.sensorMax);
          }

          I also noticed that the init() function is nested in the openService() function in the posted code, is that right? Dunno if this is important, but I thought it should be a part of the class, not of a function in that class.

          hth,
          blemmo
          • 2. Re: Tween & Web Service Component Help!
            SteveDriveRa Level 1
            Thanks Blemmo!

            The trace displays the value received - which is great, except I can't seem to reference the Label - lblMax - on the stage, within the Sensor Component to the value received (sensorMax).

            I was trying to have a paramater sensMax-sensorMax, and pass a value into that, and it reads it from there, but I cna't seem to do that.

            If I also place a trace outside the .onResult function - after the closing brace, it calls that trace first and displays the paramate value, and not the value received. Is this due to the pendingcall? It waits for a value and proceeds?

            I am really confused with this action script! hah

            Thanks again for your help!!!
            • 3. Re: Tween & Web Service Component Help!
              SteveDriveRa Level 1
              Oh wait!

              I did some debugging and it shows that sensorMax, sensorMin are being assigned to the values received in the paramater values....
              This is great!!! Wow! haha
              How do I now assigned the sensorMax,sensorMIn (component paramater values) to the Labels in the component?

              Thank you soooo much!
              Steve
              • 4. Re: Tween & Web Service Component Help!
                SteveDriveRa Level 1
                Sorry for so many posts.

                If I refer to sensorMax in the root level, it comes up undefined? Yet in my level0 instance it displays it as the value recevied?
                • 5. Re: Tween & Web Service Component Help!
                  blemmo Level 1
                  this.lblMax must be me.lblMax too, I forgot to change it. Does that display the values?
                  • 6. Re: Tween & Web Service Component Help!
                    SteveDriveRa Level 1
                    oh my god! I love you! Haha
                    Thanks again Blemmo for your help! It worked!!

                    I have been trying to conquer the scoping for variables in AS!! Thank you!

                    One quick question before I stop bothering you!
                    When I try to tween this object:
                    myTween = new mx.transitions.Tween(object, object_property, easeType, begin, end, duration, frames_flag);

                    it says there is no property with 'myTween' yet I am defining myTween as a new mx.tranistions.Tween object? Do I define this as an object before I tween?

                    • 7. Re: Tween & Web Service Component Help!
                      blemmo Level 1
                      Try
                      var myTween = new mx.transitions.Tween(...)

                      In AS 2, you have to define vars explicitely, I think.
                      • 8. Re: Tween & Web Service Component Help!
                        SteveDriveRa Level 1
                        Excellent, thanks again Blemmo, i really appreciate it!

                        Steve