3 Replies Latest reply on Jun 13, 2009 10:44 AM by David_F57

    Setting the center of transform for the Resize effect

    João Saleiro



      I've seen that in Flex 4 is now possible to set the autoCenterTransform in the Scale effect to make the transformation occur from the center. I wonder why it's not possible to do the same with the Resize effect. The Scale effect receives a percentage from the original size of the component being transformed. The Resize receives a well defined pixel size, which is more likely to be used than the Scale effect. But unfortunately it seems I can't make a Resize from the center. Is there any valid reason for this?


      A real life example would be the following:




      When the user changes the picture, I want the white area around the picture to resize to the size of the new picture - similar to what Lightbox does ( http://www.huddletogether.com/projects/lightbox2/ ) . Using the Resize effect I can't resize it from the center. Using the Scale effect I have to make aditional calculation to get the desired behaviour and it seems a bit unreliable on some cases (if I'm using constraint layout to define the first dimensions of the white area, for example).


      Is there any alternative?


      Thank you,


      João Saleiro

        • 1. Re: Setting the center of transform for the Resize effect
          David_F57 Level 5

          if the image is held inside a container you could then set its verticalCenter and horizontalCenter to 0 that would lock the position of the image central to the container no matter what filter you applied to it.

          • 2. Re: Setting the center of transform for the Resize effect
            João Saleiro Level 1

            I am sorry, but that's not what I am asking. When you do a Resize/Scale effect (an animation...), by default it scales from the 0,0 point. The Scale effect allows you to change this point, but the Resize doesn't. And it should allow also - or at least, the Scale effect could also receive the fixed size instead of a percentage.

            I am asking if there's a straighforward solution for this problem, and if not, why doesn't the SDK support this by default?





            • 3. Re: Setting the center of transform for the Resize effect
              David_F57 Level 5

              A smart philospher once said there are no wrong answers only wrong questions.... Flex unlike flash does not  allows you to reset the point of origin and as you have realised this is the case for the resize filter. but as you asked is there another alternative- and I said yes,  and I answered it,  if the object you wish to resize is locked by its center it will emulate having a point of origin that is at the centre, it is very simple and very effective. Resize filter animates a change in the width and height of an object it doesnt care if something else is changeing the x and y co-ordinates at the same time(if memory serves correctly the resize function checks for layout constraints), for all intents and purposes the animation be it the frame shrinking or the image growing (whatever)  will appear as though it is happening from the centre. If you think my idea wasn't the right solution for you thats fine, but in the end it was only a suggestion and YES it was an answer to your question.


              If you want features added to the scale and resize capabilities then you could put a request in for these features. I think that it would be nice to have a bit more control of the positioning capabilities of many of the flex features. But by definition scaling means a factorial change in size, scaling by dimension sorta defeats the whole scaling concept, I think they call that resizing.