Solved

Restraining size properties to what's visible?

Posted on 2010-09-13
11
286 Views
Last Modified: 2012-05-10
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
Comment
Question by:flashdeviant_com
  • 5
  • 2
  • 2
  • +1
11 Comments
 
LVL 19

Expert Comment

by:quizengine
Comment Utility
Are you able to post the fla ? (CS4 or older please)
0
 

Author Comment

by:flashdeviant_com
Comment Utility
Ok here's the .fla and a .swf
EE-demo.fla
EE-demo.swf
0
 

Author Comment

by:flashdeviant_com
Comment Utility
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
 
LVL 19

Accepted Solution

by:
quizengine earned 125 total points
Comment Utility
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
 
LVL 14

Expert Comment

by:tomaugerdotcom
Comment Utility
@ 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 19

Expert Comment

by:quizengine
Comment Utility
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
 
LVL 19

Expert Comment

by:quizengine
Comment Utility
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
 
LVL 14

Expert Comment

by:tomaugerdotcom
Comment Utility
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
 
LVL 19

Expert Comment

by:quizengine
Comment Utility
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
 
LVL 37

Expert Comment

by:CyanBlue
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Here are some practices and techniques that can be adopted into your Flash/Flex application development process. Note: Not all "performance tips" provide an immediately-recognizable benefit.   This article does not include timing validation data,…
While working over numerous projects I often had the requirement for doing a screen capture in AS3.0. Unfortunately I found no "ready made" solutions in google search that suited my requirements. But I did come across some great resources which help…
The goal of the tutorial is to teach the user how to set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.
The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now