Highlighted

Alpha resets to 1 after code is executed

New Here ,
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.

Adobe Community Professional
Correct answer by JoãoCésar | Adobe Community Professional

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

TOPICS
ActionScript

Views

63

Likes

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

Alpha resets to 1 after code is executed

New Here ,
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.

Adobe Community Professional
Correct answer by JoãoCésar | Adobe Community Professional

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

TOPICS
ActionScript

Views

64

Likes

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
Aug 12, 2019 0
Adobe Community Professional ,
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

__________________________________________
HTML5, JSFL, and AS3 samples: http://bit.ly/2mJgDoG

Likes

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
Reply
Loading...
Aug 12, 2019 1
New Here ,
Aug 12, 2019

Copy link to clipboard

Copied

Thanks so much!  It works perfectly now.

Likes

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
Reply
Loading...
Aug 12, 2019 1
Adobe Community Professional ,
Aug 12, 2019

Copy link to clipboard

Copied

Excellent! You're welcome!

__________________________________________
HTML5, JSFL, and AS3 samples: http://bit.ly/2mJgDoG

Likes

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
Reply
Loading...
Aug 12, 2019 0