Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Scale Up on Mouse Over and Reverse on Mouse Out using AS3

New Here ,
Oct 24, 2015 Oct 24, 2015

Hello,

I am an expert in flash programming i am just a student learning and i am badly stuck.. i am trying to scale up a button on mouse over from 1 to 2 using as3. also when mouse is out i want the scaling up to reverse from whatever position it is currently on. say when i mouse over my button and it starts to scale from 1 to 2 and while it is scaling i move my mouse out then i want the scaling to reverse (mytween.yoyo) and go back to origional position.

so far i cud do this but it has some glitches it doesnt work properly...

plz help

import fl.transitions.Tween;

import fl.transitions.easing.*;

import fl.transitions.TweenEvent;

var myTween:Tween = new Tween(my_mc, "scaleX", None.easeIn, 1, 3, 2, true);

myTween.stop();{

my_mc.addEventListener(MouseEvent.MOUSE_OVER, fl_MouseOverHandler_4);

function fl_MouseOverHandler_4(event:MouseEvent){

  var myTween:Tween = new Tween(my_mc, "scaleX", None.easeIn, 1, 3, 2, true);

}

my_mc.addEventListener(MouseEvent.MOUSE_OUT, fl_MouseOutHandler_3);

function fl_MouseOutHandler_3(event:MouseEvent):void

{

  myTween.stop()

}

my_mc.addEventListener(MouseEvent.MOUSE_OUT, fl_MouseOutHandler_4);

function fl_MouseOutHandler_4(event:MouseEvent):void

{

  myTween.yoyo()

}

}

TOPICS
ActionScript
1.0K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Oct 24, 2015 Oct 24, 2015

You can use this code:

import fl.transitions.Tween;

import fl.transitions.easing.*;

import fl.transitions.TweenEvent;

var myTween:Tween;

my_mc.addEventListener(MouseEvent.MOUSE_OVER, fl_MouseOverHandler_4);

function fl_MouseOverHandler_4(event: MouseEvent) {

    myTween = new Tween(event.target, "scaleX", None.easeIn, event.target.scaleX, 2, 1, true);

}

my_mc.addEventListener(MouseEvent.MOUSE_OUT, fl_MouseOutHandler_3);

function fl_MouseOutHandler_3(event: MouseEvent): void {

    myTween = new Tween(event.target, "scaleX", None.easeIn, event.target.scaleX, 1, 1, true);

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 24, 2015 Oct 24, 2015

:

import fl.transitions.Tween;

import fl.transitions.easing.*;

import fl.transitions.TweenEvent;

var myTween:Tween;

my_mc.addEventListener(MouseEvent.MOUSE_OVER, fl_MouseOverHandler_4);

function fl_MouseOverHandler_4(event:MouseEvent){

  myTween= new Tween(my_mc, "scaleX", None.easeIn, my_mc.scaleX, 2, 2, true);

}

my_mc.addEventListener(MouseEvent.MOUSE_OUT, fl_MouseOutHandler_3);

function fl_MouseOutHandler_3(event:MouseEvent):void

{

myTween= new Tween(my_mc, "scaleX", None.easeIn, my_mc.scaleX, 1, 2, true);

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 25, 2015 Oct 25, 2015
LATEST

Make sure for your tweens that when you enlarge you go from a smaller number to a larger number and then when you want to shrink down you reverse the order of them.  Also, you appear to only be scaling one dimension.  You likely want to have another tween to scale the y dimension (scaleY)

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines