4 Replies Latest reply on Feb 21, 2012 11:42 AM by 56231

    access to undefined properties on a button. How is this undefined please?

    56231 Level 1

      I have a play pause button. I want the triangle to be visible until clicked. Then triangle is replaced by pause bars.

      Errors: access to undefined properties pauseBars and playTriangle.

      pauseBars and playTriangle are both located in skins.WirePlayPauseButtonS

      kin.

       

      Am I missing something here? Is there a better way to do this? Thanks.

       

      <fx:Script>
        <![CDATA[
          private function flipStartPause(e:MouseEvent):void {
             if (playTriangle.visible==true) {
               playTriangle.visible=false;
               pauseBars.visible=true;
            }else{
          playTriangle.visible=true;
          pauseBars.visible=false;
      }
          }
        ]]>
      </fx:Script>


      <s:Group id="groupPlayPauseButton"  click="flipStartPause(event)">
        <s:ToggleButton id="playPauseButton"
           focusIn="event.target.depth=1"
           focusOut="event.target.depth=0"
           skinClass="skins.WirePlayPauseButtonSkin"/>                   
      </s:Group>

      <s:Path id="playTriangle" width="17" height="17"
        data="M 0 1 L 1 7 L 1 0 L 0 1 Z"
        winding="evenOdd" visible="true">
         <s:fill>
            <s:SolidColor color="0xffffff"/>
         </s:fill>
      </s:Path>

      <s:Rect id="pauseBars" width="10" height="10" visible="false">
        <s:fill>
           <s:SolidColor color="0xffffff"/>
        </s:fill>
      </s:Rect>

        • 1. Re: access to undefined properties on a button. How is this undefined please?
          56231 Level 1

          I have discovered that this actionscript function cannot find the two components playTriangle and pauseBars because they are located in the WirePlayPauseButtonSkin.mxml file. When I move one of those components to the videoPlayerSkin.mxml file, the error goes away. Am I supposed to add something to this function so it can find the playTriangle and pauseBars components? Thanks.

           

          <fx:Script>
            <![CDATA[
              private function flipStartPause(e:MouseEvent):void {
                 if (playTriangle.visible==true) {
                   playTriangle.visible=false;
                   pauseBars.visible=true;
                }else{
              playTriangle.visible=true;
              pauseBars.visible=false;
          }
              }
            ]]>
          </fx:Script>

           

          I tried this but it did not work.

           

          <fx:Script>
            <![CDATA[
              private function flipStartPause(e:MouseEvent):void {
                 if (
          skins.WirePlayPauseButtonSkin.playTriangle.visible==true) {
                  
          skins.WirePlayPauseButtonSkin.playTriangle.visible=false;
                  
          skins.WirePlayPauseButtonSkin.pauseBars.visible=true;
                }else{
             
          skins.WirePlayPauseButtonSkin.playTriangle.visible=true;
             
          skins.WirePlayPauseButtonSkin.pauseBars.visible=false;
          }
              }
            ]]>
          </fx:Script>

          • 2. Re: access to undefined properties on a button. How is this undefined please?
            56231 Level 1

            Can someone throw me a clue.

             

            Can anyone point me to a book or tutorial on making a play pause button that can change its appearance when clicked from a play triangle to pause bars? Thanks.

            • 3. Re: access to undefined properties on a button. How is this undefined please?
              Flex harUI Adobe Employee

              The skin should define different icons for different states.  You shouldn’t need to write code to change visible.

              • 4. Re: access to undefined properties on a button. How is this undefined please?
                56231 Level 1

                Thanks for that. The three books I have, just didn't cover this subject (states and buttons) adequately. Maybe the authors thought it was too simple and assumed the reader would just know. I discovered a tutorial on google late yesterday using four images and four states. No need for action script.

                 

                Thanks again.