3 Replies Latest reply on Oct 16, 2011 12:57 PM by Shongrunden

    Clickable image using BitmapImage

    VivD

      My mobile app has a collage of images in a view. On click of each image I move to another screen passing some value on doing that.

       

      I achieved this using <s:Image> tags. However, I read that using BitmapImage is better on mobile in terms of performance but it doesn't have a click event.

       

      What are the best (in terms of performance) options to circummvent that limitation?

        • 1. Re: Clickable image using BitmapImage
          Shongrunden Adobe Employee

          You could wrap each BitmapImage with a Group:

          <s:Group click="…">

              <s:BitmapImage />

          </s:Group>

           

          <s:Group click="…">

              <s:BitmapImage />

          </s:Group>

           

          <s:Group click="…">

              <s:BitmapImage />

          </s:Group>

           

          This should be ok for a couple BitmapImages, but with a lot of images you end up with a lot of extra Groups.  For that case you might consider using a single Gorup that holds all the bitmaps and then its click handler would calculate which bitmap was actually clicked based on the localX/localY properties of the mouse event.

          • 2. Re: Clickable image using BitmapImage
            VivD Level 1

            Thanks. I'll try that. Meanwhile, I had implemented it using a Graphic tag. Is that ok?

             

            <s:Graphic click="callFuntion()">

                                <s:BitmapImage id="img" source="images/img.png"/>

                      </s:Graphic>

            1 person found this helpful
            • 3. Re: Clickable image using BitmapImage
              Shongrunden Adobe Employee

              That should work too since Graphic is a pretty simple subclass of Group.  Note that you can only use BasicLayout in Graphic.

              1 person found this helpful