Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mouse-driven object scale 1

Status
Not open for further replies.

apollo85

Technical User
Mar 29, 2007
5
GB
Hello,

I'm trying to create an effect in Flash MX:
I have a number of graphic objects (movie clips) clustered on the Stage. What I need is when the mouse clicks on an object, that object scales up to a pre-determined value (say 200%) - when the mouse rolls off the object, it scales back down to its original size. I've been trying to figure out the Actionscript for this, but with no luck. It's important that the scaling be gradual and not just a sudden increase/decrease. Just to confirm:

a) OnRollOver - no change
b) OnClick - object scales up
c) OnRollOut - object scales back down

I would be very grateful if someone can give me the AS code to do this. Thanks in advance!

Benny
 
movie clip with instance name my_mc

my_mc.onRelease = function() {
this._xscale = this._yscale=200;
};
my_mc.onRollOut = function() {
this._xscale = this._yscale=100;
};
 
Hello Bill,
thanks for your response... I used the code you gave me. First, I applied the code to the individual MCs - that didn't work, so I made it a frame action. This works, but there are still a couple of problems:

1) The scaling up/down is too sudden and abrupt.
2) The object clicked has to be 'brought to front'... this is crucial. Maybe an action like 'swap depths' or something?

Here are 2 versions I made - 4 files in total, the .swf and .fla:


The above use the code you provided. Below is a 'tweened' version with exactly the effect I'm looking for:

^^click on the 'laughing buddha' to see the effect I'm after.

It's better if the tweening was done in Actionscript... surely this can be achieved? Please feel free to download these files and look into the problem. Many thanks for your help and your time!
Benny
 
Hi Bill,
seems to be a problem... the links don't work. I've tried repeatedly, but keep getting a "Cannot find server or DNS Error".
 
probably a time difference

i am in canada and files are stored on my pc so only available when my pc is on

if you hit that error again then just email me and i will send the files to you
 
Hello Bill,
the links are working now. I downloaded the .fla (after viewing the .swf) and can now open/edit it. You've done a great job, revised my patchy code and I liked the way you made the AS nice and concise! I'll let you know if I run into any other problems. Many thanks for all your help, you're a star!
Benny
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top