Link to home
Create AccountLog in
Avatar of flashdeviant_com
flashdeviant_comFlag for United States of America

asked on

Restraining size properties to what's visible?

I was working on a simple AS2 rollover effect that simply makes the movieclip 102% larger and then reverts on rollout. As well the object had a movieclip play of a shine tweening left to right. The shine was masked to only appear in the area the button existed but started and ended outside that region.

The result was if you rolled in/out at certain points in the animation, the size of the object changed because the shine existed outside the visible region and moved, affecting the width as it moved through it and out again. If the object was 200px and I tell it to go back to that size on rollout, if the shine was outside of the visible area it would result in the button seeming to shrink far too small.

Beyond writing an algorithm to compensate for the shifting width, I could not figure out a solution. Is their a work around so that masked out objects do not affect the size?
Avatar of quizengine
Flag of United Kingdom of Great Britain and Northern Ireland image

Are you able to post the fla ? (CS4 or older please)
Avatar of flashdeviant_com


Ok here's the .fla and a .swf
Small typo in the last code on line 13 with the var "origin1_h". Correct or use the corrected .fla below
Avatar of quizengine
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
@ quizengine, actually, it's a better programming practice to store the original fixed value of the clip and revert to that value (ie: 100%) rather than make it 98% smaller, due to the rounding errors that can (and often do) occur in Flash. Performed enough times, the clip could end up growing or shrinking. This problem may never materialize depending on how the clip is used, but the potential for error is there. Rule of thumb: never perform a calculation to revert to a previous state when you can just store that previous state and revert to it.
tomaugerdotcom: I agree that scaling errors might eventually grow or shrink the clip beyond it's intended size, and for that reason I agree it's not good practice to do this.

But, fixing the bigger issue of "it didnt work at all" was priority one, and I've done that.

And you would have to mousover / mouseout of this object dozens and perhaps scores of times to see any change in size at all. And you would need to keep up that pointless 'mouse on, mouse off...' (Karate Kid anyone ?) for hundreds and perhaps thousands of times to make a functional difference.

So yes, it's ugly programming and you wouldn't want to use it in an app for a nuclear reactor. But for the a button in an app or a web page - I think it's close enough for jazz.
tomaugerdotcom: oh, forgot to add... My first try at fixing this was exactly your suggestion. Problem is, it didn't work. I know it should have, but for some reason of something else buried in the code somewhere it didn't. So my solution was a plan B, but I still believe that it's serviceable.
I hear that.

and I like jazz :)

Didn't mean to butt in, just wanted to point out a programming flaw.... from a classical music perspective.

No you do right, and I agree with you completely. Then the person getting the fix hears "It'll work" from me, and "But if you do this again, better not to do it this way" from both of us.
This question has been classified as abandoned and is being closed as part of the Cleanup Program.  See my comment at the end of the question for more details.