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

Alpha resets to 1 after code is executed

New Here ,
Aug 12, 2019 Aug 12, 2019

Copy link to clipboard

Copied

Every time I roll out away from the button, the movie clip alpha resets to 1 after about a second.  Here is the script:

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

b1.addEventListener(MouseEvent.MOUSE_OVER, b1over);
b1.addEventListener(MouseEvent.MOUSE_OUT, b1out);

mc1.alpha = 0;

function b1over(event:MouseEvent):void
{
var tween1:Tween = new Tween(mc1,"alpha",Strong.easeOut,0,1,2,true);
}

function b1out(event:MouseEvent):void
{
var tween2:Tween = new Tween(mc1,"alpha",Strong.easeOut,1,0,1,true);
}

I've tried putting "mc1.alpha = 0;" in at every opportunity, as well as making the movie clip invisible from the stage or whatever it's called, but nothing is working.

TOPICS
ActionScript

Views

183

Translate

Translate

Report

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

correct answers 1 Correct answer

Community Expert , Aug 12, 2019 Aug 12, 2019

Hi.

This is probably happening because you have concurrent tweens going on.

A way of solving this is to use only one variable for both tweens and also to stop the tween from the mouse over event before creating another one. Like this:

import fl.transitions.Tween;

import fl.transitions.easing.*;

var tween:Tween;

function b1over(event:MouseEvent):void

{   

    tween = new Tween(mc1, "alpha", Strong.easeOut, 0, 1, 2, true);

}

function b1out(event:MouseEvent):void

{

    tween.stop();

    tween = new Tween(mc1,

...

Votes

Translate

Translate
Community Expert ,
Aug 12, 2019 Aug 12, 2019

Copy link to clipboard

Copied

Hi.

This is probably happening because you have concurrent tweens going on.

A way of solving this is to use only one variable for both tweens and also to stop the tween from the mouse over event before creating another one. Like this:

import fl.transitions.Tween;

import fl.transitions.easing.*;

var tween:Tween;

function b1over(event:MouseEvent):void

{   

    tween = new Tween(mc1, "alpha", Strong.easeOut, 0, 1, 2, true);

}

function b1out(event:MouseEvent):void

{

    tween.stop();

    tween = new Tween(mc1, "alpha", Strong.easeOut, 1, 0, 1, true);

}

mc1.alpha = 0;

b1.addEventListener(MouseEvent.MOUSE_OVER, b1over);

b1.addEventListener(MouseEvent.MOUSE_OUT, b1out);

Regards,

JC

Votes

Translate

Translate

Report

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
New Here ,
Aug 12, 2019 Aug 12, 2019

Copy link to clipboard

Copied

Thanks so much!  It works perfectly now.

Votes

Translate

Translate

Report

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 ,
Aug 12, 2019 Aug 12, 2019

Copy link to clipboard

Copied

LATEST

Excellent! You're welcome!

Votes

Translate

Translate

Report

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