9 Replies Latest reply on Mar 10, 2007 12:03 PM by ruchir123

    Following flex 1.5 code is not working in flex 2.0

    ruchir123 Level 1
      Hello

      With the code below, this function is assigned to the mouseover property of a vbox control. The expectation is whenever moues pointer enters into the vbox container it should highlight the container. This worked just fine in flex 1.5 but now it is giving me following error

      "1119: Access of possibly undefined property VBox through a reference with static type mx.containers:VBox."

      Below is the code which works just fine in flex 1.5 but not in 2.0

      Thanks million for providing your time in reading this posting. ~Ruchir.
      ------------------------------------
      <mx:VBox width="209" height="303" borderStyle="none" verticalGap="-1" marginLeft="1" id="sands" mouseOver="trackMouse()" mouseOut="leaveMouse()">
      </mx:VBox>
      <mx:Script>
      <![CDATA[
      function trackMouse(event) {
      var curX = event.target.mouseX;
      var curY = event.target.mouseY;
      sands.VBox = curX;
      sands.VBox = curY;
      if (curX != 0 && curY != 0) {
      // mx.controls.Alert.show("You found it!");
      sands.VBox = sands.setStyle("borderStyle","outset");
      }
      }
      function leaveMouse(event) {
      var curX = event.target.mouseX;
      var curY = event.target.mouseY;
      sands.VBox = curX;
      sands.VBox = curY;
      if (curX != 0 && curY != 0) {
      // mx.controls.Alert.show("You found it!");
      sands.VBox = sands.setStyle("borderStyle","none");
      }
      }]]></mx:Script>


        • 1. Re: Following flex 1.5 code is not working in flex 2.0
          cotm Level 1
          sands.VBox = curX; ? What do you wanna do with this?

          sands is already your vbox .. and vbox doesn't have a property called vbox.
          • 2. Re: Following flex 1.5 code is not working in flex 2.0
            ntsiii Level 3
            Yes, that is the problem. 2.0 classes are almost all non-dynamic, so the compiler knows when you are making a mistake.

            Tracy
            • 3. Re: Following flex 1.5 code is not working in flex 2.0
              ruchir123 Level 1
              Thanks much for the reply.

              So, how can I achieve following in flex 2.0 any idea?

              The expectation is whenever moues pointer enters into the vbox container it should highlight the container.

              Thanks,

              Ruchir
              • 4. Re: Following flex 1.5 code is not working in flex 2.0
                ntsiii Level 3
                Just drop the assignment, it is meaningless (was in 1.5 too, but was permitted.):
                sands.setStyle("borderStyle","outset");

                Tracy
                • 5. Re: Following flex 1.5 code is not working in flex 2.0
                  ruchir123 Level 1
                  You are the best! This really worked. I have modified the code as below. Now I am facing a little problem. When and as I navigate to several link buttons in that vbox(sands), the entire vbox container is vibrating constantly(like say if you are using the buzz feature of almost ubiquitous yahoo messenger).

                  The entire vbox container will vibrate as I navitage through the linkbuttons one by one. After researching lot I have finally given up.:(

                  Any idea why is this happening?

                  Below is the modified code.

                  --
                  <mx:Script>
                  <![CDATA[
                  private function trackMouse(event:MouseEvent):void {
                  var pt:Point = new Point(event.localX, event.localY);
                  pt = event.target.localToGlobal(pt);
                  pt = sands.globalToContent(pt);
                  if (pt.x != 0 && pt.y != 0) {
                  // mx.controls.Alert.show("You found it!");
                  sands.setStyle("borderStyle","outset");
                  sands.setStyle("backgroundColor","#edeefa");
                  }
                  }
                  private function leaveMouse(event:MouseEvent):void {
                  var ct:Point = new Point(event.localX, event.localY);
                  ct = event.target.localToGlobal(ct);
                  ct = sands.globalToContent(ct);
                  if (ct.x != 0 && ct.y != 0) {
                  // mx.controls.Alert.show("You found it!");
                  sands.setStyle("borderStyle","none");
                  sands.setStyle("backgroundColor","none");
                  }
                  }]]>
                  </mx:Script>

                  Thanks million for posting your feedback.

                  Ruchir
                  • 6. Re: Following flex 1.5 code is not working in flex 2.0
                    ntsiii Level 3
                    Sorry, I don't see what is doing that. Clearly it is a mouse event triggering it. Try some other events, maybe mouseIn and mouseOut, which probably only fire once, instead of the over which probably fires a lot.
                    • 7. Re: Following flex 1.5 code is not working in flex 2.0
                      ruchir123 Level 1
                      Okay, something strange is happening. Not sure if this is bug or problem with my code.

                      I have the MouseOut event for vbox sands and it is calling function leaveMouse()

                      the problem is instead of firing the leavemouse() functiona WHEN mouse leaves the borders of VBOX, it is firing for each individual linkbuttons contained under vbox sands. Hence the vibration.

                      To explain this through the example.

                      Vbox Sands needs to call leavemouse() only when mouse leaves the vbox. So, I am putting the mouseOut event.

                      controls under Vbox sands are arranged vertically like shown below

                      linkbutton1
                      linkbutton2
                      linkbutton3

                      now the current behaviour is the leavemouse() firest for each "mouseOut" event when mouse moves from linkbutton1 to linkbutton2 and hence it is trying to reset the backgroundcolor(to "none" when mouse leaves) coded in leavemouse(), thus, giving the impression of vibrating the entire container.

                      now question is, why would mouseOut event, even though set to execute at VBOX level, execute for each linkbutton control?

                      Below is the code.

                      <mx:HBox x="154" y="414" width="1140" height="331" borderColor="#FF9966" borderStyle="none" >
                      <mx:VBox width="230" height="224" borderStyle="none" verticalGap="-1" paddingLeft="1" id="sands" mouseOver="trackMouse(event)" mouseOut="leaveMouse(event)">
                      <mx:Text text="Services &amp; Solutions" width="185" height="20" fontWeight="bold" fontFamily="Verdana" color="#FF3333" x="91" y="422"/>
                      <mx:LinkButton label="Click2Develop" height="20" width="192" textAlign="left" paddingLeft="11" id="c2d"/>
                      <mx:LinkButton label="Project Point" height="20" width="190" textAlign="left" paddingLeft="11" id="pp" x="91" y="460"/>
                      <mx:LinkButton label="Support Center" height="20" width="194" textAlign="left" paddingLeft="11" id="sc" x="91" y="479"/>
                      <mx:LinkButton label="DBPoint" height="20" width="192" textAlign="left" paddingLeft="11" id="db" x="91" y="498"/>
                      <mx:LinkButton label="Resource Procurement" height="20" width="191" textAlign="left" paddingLeft="11" id="rp" x="91" y="517"/>
                      <mx:LinkButton label="RealTech Zone" height="20" width="193" textAlign="left" paddingLeft="11" id="rt" x="91" y="536"/>
                      <mx:LinkButton label="Made2Integrate" height="20" width="194" textAlign="left" paddingLeft="11" id="mi" x="91" y="555"/>
                      <mx:LinkButton label="Made2Order" height="20" width="191" textAlign="left" paddingLeft="11" id="mo" x="91" y="574"/>
                      <mx:LinkButton label="Process Re-engineering" height="20" width="191" textAlign="left" paddingLeft="11" id="pr"/>
                      <mx:LinkButton label="Industry Specifc Solutions" height="20" width="193" textAlign="left" paddingLeft="11" id="iss"/>
                      </mx:VBox>
                      </mx:HBox>

                      I am affraid, I am not asking too much. But these type of troubleshooting can not be discovered in any of flex documentaton.

                      Thanks,

                      Ruchir



                      • 8. Re: Following flex 1.5 code is not working in flex 2.0
                        dave cragg Level 2
                        Instead of using the mouseOver and mouseOut events, try using the rollOver and rollOut. I think these will stop the events firing when you roll over child objects.
                        • 9. Re: Following flex 1.5 code is not working in flex 2.0
                          ruchir123 Level 1
                          YES SIR! THAT DID IT.

                          Thank you so much.

                          Btw, is there any documentation that describes the functionality of each events in detail? I could not find it. :(

                          Thanks,

                          Ruchir