AS3 scalex on MouseEvent

Posted on 2009-04-25
Last Modified: 2013-11-11
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.addEventListener(MouseEvent.MOUSE_OVER, HomeOver)
            homeButton.addEventListener(MouseEvent.MOUSE_OUT, HomeOut)
            homeButton.scalex = 1;
            homeButton.scaley = 1;
            function HomeOver(e:MouseEvent):void{
            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{
            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);

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

    Accepted Solution


    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" ;)

    LVL 1

    Author Comment

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

    Thanks for your help!

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    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.

    755 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

    18 Experts available now in Live!

    Get 1:1 Help Now