1 Reply Latest reply on Jan 31, 2008 10:26 AM by Ratsnackbar

    An Image Tag With A Child

      I'm building a slideshow applications that is randomly showing images from a folder.

      I would like to add another semi-transparent image on top of each picture as it shows. A bug.

      But I can't figure out how to do that so it always stays in the same corner of the image as the dimensions of each picture changes.

      Any suggestions or hints?

        • 1. Re: An Image Tag With A Child
          Ratsnackbar Level 2
          This is only one of many ways to do that but it is one I use for similar instances.

          You can capture the height and width of the image being loaded. It does not matter when you acquire that information but you will need to sync it with the change.

          Load the next images Height, Width and if you wanted possibly the Image in an Active ValueObject and fire off an Event notifying of the ValueObjects data change. (Use the Singleton Patter for the Value Object so you do not end up with multiple instances if you would to have different objects rotating through the SAME data.)

          Your overlay child object can then have an instance of the ValueObject instantiated and listening for that Event. When it hears the event you can then acquire the Height and Width of the image from the VO and use it in a calculation to figure out the X and Y of the object and set a new X and Y for the object as the image loads.

          For example:
          myChildObject.x = myActiveVO.getWidth() - myChildObject.width;
          myChildObject.y = myActiveVO.getHeight() - myChildObject.height;

          Anyway something like that is possible. Might seem like more work then it is worth but your Active ValueObject then becomes reusable for different purposes. I use methods similar to this to move crap all over the place as the screen size changes or someone resizes an object.

          Another cool thing about doing this is your event NAME itself can then be made to be a variable so the object can fire off different event names based on what object is using it.