Solved

# AS3 scalex on MouseEvent

Posted on 2009-04-25
4,585 Views
I'm new to AS3 - I found some code in AS2 that I would like to make work.  I'm trying to scale up a button when the mouse is over.  When the mouse is off, I need it to scale back.  here's my code:

import fl.transitions.Tween;
import fl.transitions.easing.*;

homeButton.scalex = 1;
homeButton.scaley = 1;
function HomeOver(e:MouseEvent):void{
trace(homeButton.scalex);

var lngth:Number = 1.2;
var xscaleUp:Tween = new Tween(homeButton, "scalex", Elastic.easeOut, homeButton.scalex, 100, lngth, true);
var yscaleUp:Tween = new Tween(homeButton, "scaley", Elastic.easeOut, homeButton.scaley, 100, lngth, true);
}

function HomeOut(e:MouseEvent):void{
trace("Goodby");

var lngth:Number = 1.6;
var xscaleBack:Tween = new Tween(homeButton, "scalex", Elastic.easeOut, 100, 100, lngth, true);
var yscaleBack:Tween = new Tween(homeButton, "scaley", Elastic.easeOut, 100, 100, lngth, true);
}
stop();

I'm not sure what I'm doing wrong.  Any help would be appreciated!
0
Question by:steverguy

LVL 11

Accepted Solution

Hi,

Well, the first thing is the quantities are scaleX and scaleY, so the case of X and  Y are important.

Second, the scales in AS3 are not based on 100, but 1.  1 represents a normal scale, 100 means 100 times normal size.

Third, your "HomeOut" event just sets the scale because your start and end values are the same.  If that's what you want, you don't need the tween.

Fourth, you misspelled "Goodbye" ;)

HTH
Gene
0

LVL 1

Author Comment

:)  Thanks, it was the case issue.  scaleX not scalex.

0

## Featured Post

### Suggested Solutions

Recently, I was asked to recommend a tracking system to be implemented on a clients website. As the entire site was built on flash, my first thought was to suggest custom built tracking system. However, our company at that point of time didn't h…
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…
In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…
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.