Mouseover scaling

I’m new to actionscripting I want to make a MC scale when my crsor is over it and go back to normal when it’s not.

onClipEvent (enterFrame) {
if (_xscale<100 ) {_xscale = _yscale += 10;
}
}

This is all the as i have but i do not know how to make it so the mouseover function is involved

can someone help?

try this
[AS]
on(rollOver){
function shrink(){
this._xscale = this._yscale -= 10;
}
keepShrinking = setInterval(shrink, 100)//100 is speed in milliseconds
}
on(rollOut, DragOut){
clearInterval(keepShrinking);
this._xscale = this._yscale = 100;
}
[/AS]

Hope it helps, and I hope I typed that correctly, unfortunately I dont have flash at work so check it please.

Good Luck,
Shawn

I should have also said i want it to stop at a certain size

this will stop at a particular scale percentage:
[AS]
on(rollOver){
function shrink(){
if(this._xscale>20){
//replace the 20 with thesize you want to stop at
this._xscale = this._yscale -= 10;
}
}
keepShrinking = setInterval(shrink, 100)//100 is speed in milliseconds
}
on(rollOut, DragOut){
clearInterval(keepShrinking);
this._xscale = this._yscale = 100;
}
[/AS]

This will stop at a particular width or height:
[AS]
on(rollOver){
function shrink(){
if(this._width>20 && this._height>20){
//replace the 20 with thesize you want to stop at
this._xscale = this._yscale -= 10;
}
}
keepShrinking = setInterval(shrink, 100)//100 is speed in milliseconds
}
on(rollOut, DragOut){
clearInterval(keepShrinking);
this._xscale = this._yscale = 100;
}
[/AS]

Isn’t Flash fun,
Shawn

Sorry for the delay got kicked out for a while

yes, flash is fun :smiley:

I hope that code works I dont have flash at work or I would make a quick example

:*(

I do not know much about action scripting… but i do have this

onClipEvent (enterFrame) {
if (_xscale<grow) {
_xscale = _yscale += 5;
}
}
on (rollOver) {
grow = 100;
}
on (rollOut) {
grow = 70;
}

the only problem is I can’t get it to ease back to it’s original size once the cursor rolls out

pS paradox thanks for helping out :wink:

okay I think I got what you want this time make it shrink on rollover then grow back to original size on rollout. If that is backwards I will make notes next to the lines that need to be changed, makes the changes and it should work.
[AS]
onClipEvent(load){ //this is so the function is only defined once
function growOrShrink(){
this._xscale += gOrS;
this._yscale += gOrS;
}
on(rollOver){
gOrS = -1;//if you want it to shrink faster make the -1 a -3 or -4
grower = setInterval(growOrShrink,100);
if(this._xscale<20 || this._yscale<20){//change 20 to something else to make it grow or shrink more
clearInterval(grower);//might need “” around the name in there
}
}
on(rollOut){
gOrS = 1;//make a 3 or 4 to grow faster
grower = setInterval(growOrShrink,100);
if(this._xscale>=100 || this._yscale>=100){
clearInterval(grower);//might need “” around the name in there
}
}
[/AS]
okay that should do what you need to make it work the other way around use this for the rollover/rollout states:
[AS]
on(rollOver){
gOrS = 1;//if you want it to shrink faster make the -1 a -3 or -4
grower = setInterval(growOrShrink,100);
if(this._xscale>120 || this._yscale>120){//change 120 to something bigger to make it frow more
clearInterval(grower);//might need “” around the name in there
}
}
on(rollOut){
gOrS = -1;//make a 3 or 4 to grow faster
grower = setInterval(growOrShrink,100);
if(this._xscale<=100 || this._yscale<=100){
clearInterval(grower);//might need “” around the name in there
}
}
[/AS]
if this is still not what you need feel free to email me at shawn@veuphoria.com and I could build you an little example file or maybe look at your .fla and get you going in the right direction.
I get off work at 6am US eastern time so it will be a few minutes before I can check my personal email.

I hope that’s right this time,
Shawn

Place this on the timeline in which your movieclip is in:


MovieClip.prototype.resizeTo = function(to) {
	this.onEnterFrame = function() {
		this._xscale = this._yscale = to-(to-this._xscale)/1.2
		this._xscale > to-1 && this._xscale < to+1 ? delete this.onEnterFrame : null
	};
};
mc.onRollOver = function(){
	this.resizeTo(150);
}
mc.onRollOut = function(){
	this.resizeTo(100)
}

Example FLA:

ya that works too,
Thanks Voetsjoeba

Going to look into prototypes :nerd:

Senocular has showed me an amazing tutorial on OOP and prototypes, constructors and all. It’s besically an entire guide through ActionScript 1.0. It’ll be up on kirupa.com in a while, so keep an eye out for it =)

:beam: thank you much para and voet. Both of you are a credit to the kirupa forums =)

You’re welcome, Kay :wink:

para what type of work requires you to sit in front of a computer till six am?

I work for the Air Force on 12 hour night shifts making sure people dont nuke something somewhere. But luckily my job is boring, so I get to check out Kirupa and other slightly less cool Forums

Anyway I will be waiting to see that tutorial, and good luck Kay

Have fun flashing,
Shawn

I modified Voetsjoeba’s great sample file to have several of these scalable buttons in a row. But I now have a stacking order problem – if the buttons are too close together to start out with, the button that is targeted will grow to either cover a button next to it, or be partially hidden by a button next to it.
My question is , would it be easier in AS to Swap Depths so that every targeted button goes to the top (it’ll still partially cover buttons next to it), or is there a way to make the x of neighbor buttons move aside upon rolling over the target button?

here’s an example, it’s not perfect yet. i’m still trying to get the mc’s back to their original position if you rollover a few off them.

scotty(-:

That’s impressive. I see what you mean about moving back to their original postion, but the AS is far more efficient than motion-tweening would ever be. What does “schaal” mean?

it’s Dutch. in this case it means “scale”

scotty

with movie clips acting as buttons :frowning: anyone know a way around this?