Solved

Restraining size properties to what's visible?

Posted on 2010-09-13
11
291 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
ID: 33669699
Are you able to post the fla ? (CS4 or older please)
0
 

Author Comment

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

Author Comment

by:flashdeviant_com
ID: 33674597
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
ID: 33679965
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
ID: 33832555
@ 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 19

Expert Comment

by:quizengine
ID: 33833427
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
ID: 33833444
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
ID: 33833565
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
ID: 33833585
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
ID: 34078430
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Pushing Adobe Flash Player Fails with Error %%2 1 476
How to disable  HTML5 video in chrome 2 1,542
blocked plugin flash 5 111
how can flash builder 4.X version make use of java 8 5 273
Sometimes you know that one object has a specific child in it, but you can't find the child. This happened to me when I was trying to code some actionScript to make a toolbar work with its embedded buttons.  My partner had created the toolbar usi…
I have found that much of my time doing support ends up being a constant repetition of the same steps to different people.  Early on I stated using web pages with Frequently Asked Questions (FAQs) to alleviate most of the burden.  Sometimes this jus…
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 how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.

867 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

16 Experts available now in Live!

Get 1:1 Help Now