# Animation through actionscript

**URL:** <https://forum.kirupa.com/t/animation-through-actionscript/18247>\
**Category:** Uncategorized\
**Created:** [April 14, 2003, 10:14pm UTC](https://forum.kirupa.com/t/animation-through-actionscript/18247 "2003-04-14T22:14:25Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![slinky](https://avatars.discourse-cdn.com/v4/letter/s/ecb155/32.png) [@slinky](https://forum.kirupa.com/u/slinky)\
**Post date:** [April 14, 2003, 10:14pm UTC](https://forum.kirupa.com/t/animation-through-actionscript/18247/1 "2003-04-14T22:14:25Z")

</div>

MyPic1\_mc.onEnterFrame = function(){  
var speed = 2;

```
    this._height+=(_root.Pic1H-this._height)/speed;
    this._width+=(_root.Pic1W-this._width)/speed;

```

}  
Hi, Hope someone can help me with the code i need?!  
I have six portfolio images that i need to animate using actionscript. I want the images to enlarge as they are hovered over and the other images that are not hovered over i want to get smaller. I found this code - but i can’t get it working - i am doing something - wrong does anyone have any ideas?? Help would be really appreciated!

MyPic1.onMouseOver=function(){  
\_root.Pic1H=150;  
\_root.Pic1W=150;  
\_root.Pic2H=50;  
\_root.Pic2W=50;  
\_root.Pic3H=50;  
\_root.Pic3W=50;  
\_root.Pic4H=50;  
\_root.Pic4W=50;  
\_root.Pic5H=50;  
\_root.Pic5W=50;  
\_root.Pic6H=50;  
\_root.Pic6W=50;

}

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [April 15, 2003, 2:06am UTC](https://forum.kirupa.com/t/animation-through-actionscript/18247/2 "2003-04-15T02:06:22Z")

</div>

how about creating a function which has an if statement to see whether the mouse is over a pic and an else statement for when it’s not. then apply the function to all the pics…

[AS]maxscale = 300;  
fadeSpeed = 4;  
sizeChange = function () {  
if (this.hitTest(\_xmouse, \_ymouse)) {  
this.\_xscale = (this.\_xscale-(this.\_xscale-maxscale)/fadeSpeed);  
this.\_yscale = (this.\_yscale-(this.\_yscale-maxscale)/fadeSpeed);  
} else {  
this.\_xscale = (this.\_xscale-(this.\_xscale-100)/fadeSpeed);  
this.\_yscale = (this.\_yscale-(this.\_yscale-100)/fadeSpeed);  
}  
};  
pic1.onEnterFrame = sizeChange;  
pic2.onEnterFrame = sizeChange;  
pic3.onEnterFrame = sizeChange;[/AS]

the function is called sizeChange. there are two variables, maxscale and fadeSpeed which are self explanitory. the function should be called six times in your case but in my case i called it three times because i had 3 pics. the scale is changed using inertia which allows you to control the speed at which you change the scale and the maximum scale you want to allow you pic to enlarge to.

hope that helps 😉

-mike

p.s. if you need the fla, look below, if you need more explainin, just ask 🙂

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [April 15, 2003, 6:54am UTC](https://forum.kirupa.com/t/animation-through-actionscript/18247/3 "2003-04-15T06:54:03Z")

</div>

thats an awesome little script there, zylum. Yoink!

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [April 15, 2003, 7:17am UTC](https://forum.kirupa.com/t/animation-through-actionscript/18247/4 "2003-04-15T07:17:20Z")

</div>

I agree… simple and effective. 🙂

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [April 15, 2003, 7:46pm UTC](https://forum.kirupa.com/t/animation-through-actionscript/18247/5 "2003-04-15T19:46:24Z")

</div>

thanks guys 🙂 appreciate it
