1 Reply Latest reply on Jun 20, 2012 8:43 AM by BennoFlo

    MultiDPIBitmapSource with states

    BennoFlo

      Hi All,

      What's the proper way to use the MultiDPIBitmapSource class with state changes:

       

      I'm making a simple button skin that just uses an image and changes the image source based on state. The following code doesn't capture state. The image will stay in the normal position and never capture the over or down events and swap to the proper source. This seems possible, or autocomplete in Flash Builder lies. What am I doing wrong here?

       

      Example:

      {code}

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

      <s:SparkSkin name="myButtonSkin"

                   xmlns:fx="http://ns.adobe.com/mxml/2009"

                   xmlns:s="library://ns.adobe.com/flex/spark"

                   xmlns:fb="http://ns.adobe.com/flashbuilder/2009">

          <s:states>

              <s:State name="up" />

              <s:State name="over" />

              <s:State name="down" />

              <s:State name="disabled" />

          </s:states>

          <fx:Metadata>

              <![CDATA[

              [HostComponent("spark.components.Button")]

              ]]>

          </fx:Metadata>   

          <s:BitmapImage>

              <s:source>

                  <s:MultiDPIBitmapSource

                      source160dpi="/assets/images/icon160.png"

                      source240dpi="/assets/images/icon240.png"

                      source320dpi="/assets/images/icon320.png"

                      source160dpi.over="/assets/images/icon160over.png"

                      source240dpi.over="/assets/images/icon240over.png"

                      source320dpi.over="/assets/images/icon320over.png"

                      source160dpi.down="/assets/images/icon160down.png"

                      source240dpi.down="/assets/images/icon240down.png"

                      source320dpi.down="/assets/images/icon320down.png"/>

              </s:source>

          </s:BitmapImage>

      </s:SparkSkin>

      {code}

        • 1. Re: MultiDPIBitmapSource with states
          BennoFlo Level 1

          I've found what I was doing wrong. Here's the solution:

          <s:source>

                      <s:MultiDPIBitmapSource

                          source160dpi="/assets/images/icon160.png"

                          source240dpi="/assets/images/icon240.png"

                          source320dpi="/assets/images/icon320.png"/>

          </s:source>

          <s:source.over>

                       <s:MultiDPIBitmapSource

                          source160dpi="/assets/images/icon160over.png"

                          source240dpi="/assets/images/icon240over.png"

                          source320dpi="/assets/images/icon320over.png"/>

          </s:source.over>

           

          etc... So the source tag actually takes the state not, the MultiDPIBitmapSource.