• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 307
  • Last Modified:

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?
0
flashdeviant_com
Asked:
flashdeviant_com
  • 5
  • 2
  • 2
  • +1
1 Solution
 
quizengineCommented:
Are you able to post the fla ? (CS4 or older please)
0
 
flashdeviant_comAuthor Commented:
Ok here's the .fla and a .swf
EE-demo.fla
EE-demo.swf
0
 
flashdeviant_comAuthor Commented:
Small typo in the last code on line 13 with the var "origin1_h". Correct or use the corrected .fla below
EE-demo.fla
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
quizengineCommented:
Hi. Have fixed it.

I didn't see why your code was misbehaving, but I do like for code to be consistent, so I thought I would try something.

On mouseover you make the clip 2% larger using a calculation, but when you try to restore it, you use a fixed value. What I've done is a reverse calculation of the width - make it 98% smaller, and it appears to work.

Although I might be intellectually curious and continue to dig and find out why your original code failed, I'm also pretty pragmatic about these sorts of things - I've learned to stop working on something as soon as I fix it ! (earning your money as a freelancer tends to encourage that sort of thinking...)

EE-demo-v2-cs3.fla
0
 
tomaugerdotcomCommented:
@ 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.
0
 
quizengineCommented:
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.
0
 
quizengineCommented:
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.
0
 
tomaugerdotcomCommented:
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.

T
0
 
quizengineCommented:
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.
0
 
CyanBlueCommented:
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.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 5
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now