en en en en en en en en en en en en en en en en en en fa en en fr hbs_lat en en en es en en en ms en de en fr en en en ca en en en en en en en en en en en en en en en en en en en en en en en en en en en en en nl en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en it en en en pt en es en en en en en en en de en nl en en en en en en en fr cv es tr es en en en en ms en en en en en en fr en hbs_lat en en en en en en en fr cv es tr es en en en en de en en en ca en en en en en
I came back here because of one little (or not) thing to repair and I would like to have your opinion about that.
On the video below I have showed how the scaling reacts on the button (MovieClip with elements inside).
It goes wrong when I try to scale it from the handles you will see in the video.
Element Button is a MovieClip which is containing background and textfield (not visible in the video, cause I have forgotten to enable it), Anyway I can't scale the Element Button like usually, because the background has to be redrawn to keep original radius corners or gradients and the text cannot be scaled always on the center of the button. What I did is:
In the Main class where all elements are managed is:
transformItem = transformManager.addItem(element); transformItem.minScale = 0; transformItem.minWidth = 20; transformItem.minHeight = 20; transformItem.addEventListener(TransformEvent.MOVE, onMoveElement, false, 0, true); transformItem.addEventListener(TransformEvent.FINISH_INTERACTIVE_MOVE, onMoveElementComplete, false, 0, true); transformItem.addEventListener(TransformEvent.SCALE, onScaleElement, false, 0, true) transformItem.addEventListener(TransformEvent.SELECT, onSelectElement, false, 0, true); transformItem.addEventListener(TransformEvent.DESELECT, onDeselectElement, false, 0, true); transformItem.addEventListener(TransformEvent.DELETE, onRemoveElement, false, 0, true); transformItemsArray.push(transformItem);
While scaling the element I call updateProperties() method in the Element itself, this way I have always 'fresh' data. So in this case width, height, x, y, so the background can be drawn correctly.
This is how the ButtonElement class look like.
My question is, do you already know what's the problem and how to possibly fix it or you have advices to to that thing differently. Any help would be awesome. Thank you.
Share on other sites
GreenSock    17,227 Likes (Superhero)
Posted May 22, 2013
I definitely looks like some sort of problem with your redraw/update logic, but I don't have time to sift through all the code and troubleshoot it for you (not that you were asking for that). I wish I had more time. However, here's an idea (maybe you're already doing this): use a dummy Sprite that has alpha:0, and that's the one you'd add to TransformManager. Then, you just listen for TransformEvents and whenever you receive one, you update your REAL object that's visible which is BEHIND the dummy object. So to the user, it'd look like they're transforming the real object, but they're just affecting the transparent dummy Sprite. You can use whatever logic you want to ensure that your real object is positioned/scaled/draw appropriately.
I hope that helps!
Share on other sites
undefinedman    1 Likes (Newbie)
Posted May 22, 2013
Hah you're the man! This solution was more than perfect. It resolved all my problems. Now button and other elements works exactly how it should be. Many many thanks for this clever idea
Share on other sites
Create an account or sign in to comment
You need to be a member in order to leave a comment
Sign up for a new account in our community. It's easy!
Register a new account
Already have an account? Sign in here.
Sign in to follow this   Followers 1
Go to topic listing
Recently Browsing   0 members
No registered users viewing this page.
Scaling the objects inside MovieClip
“+1 to GreenSock. It’s just one of the deepest and most reliable javascript libraries I’ve ever used”
“GreenSock has encouraged me to play with the code, to dream up new and exciting things to do.”
“Massive shoutout to GreenSock for having an amazing product with fantastic documentation, hugely talented support staff and an active and helpful community. If you do anything with web animation you should *definitely* be using them.”
“GSAP makes my job fun, because it allows me to focus on creating rich, engaging web experiences, while GSAP handles much of the implementation details behind the scenes.”
“GSAP and CSS Transitions: I've done both, and its like comparing an F16 to a horse. Take like 10 minutes to try.”
“Performance has been of paramount importance for GreenSock, so there is always peace of mind for us, developers.”
“This is by far the fastest and most active community I've ever seen for getting personalized answers to questions. Only with the help of GSAP and this forum was I able to accomplish my project.”
“This stuff is so incredibly amazing I can't believe it. The level of details and options put into these things and the natural instinct GreenSock has for solving everyday problems is impressive.”
“This is why I have absolutely no issues with paying for a subscription to GSAP, great product and awesome forum!”
Sign Up For Our Newsletter
Get the latest updates on GreenSock products, exclusive offers, and more right in your inbox.
Your information will always be kept confidential.
Thanks for signing up!
Now you'll begin receiving the latest GreenSock updates, exclusive offers, and more right in your inbox. Welcome aboard.