Highlighted

Tween a movieclip to fadein with Javascript

Explorer ,
Sep 26, 2019

Copy link to clipboard

Copied

I'm tring to make a movieclip fade in after a mouse click. When I used AS 3 I was using Tween transition, but I'm now I'm using Animate Canvas. I'm not sure how to do this? my files FLA files

AS 3

 

 

 

function widgitFadeIn():void
{
fadeIn = new Tween(widgit_mc,"alpha",Strong.easeInOut,0,1,1,true);
}

iNav_mc.play_btn.addEventListener(MouseEvent.CLICK, onNext);

function onNext(e:MouseEvent):void
{
widgitFadeIn();
if (widgit_mc.currentFrame >= 1)
{
widgit_mc.nextFrame();
Tools.disableButton(iNav_mc.pause_btn);
Tools.enableButton(iNav_mc.back_btn);
direction_txt.text = "Click to advance";
}

if (widgit_mc.currentFrame == widgit_mc.totalFrames)
{
Tools.enableButton(iNav_mc.back_btn);
Tools.disableButton(iNav_mc.play_btn);
direction_txt.text = "Previous view";
}
}

 

 

 

 

Javascript

 

 

 

stage.on("drawstart", setInt, this, true);

function setInt(){
this.iNav_mc.back_btn.mouseEnabled = false;
this.iNav_mc.back_btn.alpha = .5;
this.direction_txt.textBaseline='top';
}

this.iNav_mc.play_btn.addEventListener("click", onNext.bind(this));

function onNext(){

if(this.widgit_mc.currentFrame >= 0){
this.widgit_mc.gotoAndStop(this.widgit_mc.currentFrame + 1);
}
if(this.widgit_mc.currentFrame == this.widgit_mc.timeline.duration -1){
this.iNav_mc.play_btn.mouseEnabled = false;
this.iNav_mc.play_btn.alpha = .5;
this.direction_txt.text = "END of Widgit";
}else{
this.iNav_mc.back_btn.mouseEnabled = true;
this.iNav_mc.back_btn.alpha = 1.0;
}
}

this.iNav_mc.back_btn.addEventListener("click", onPrev.bind(this));
function onPrev(){


if(this.widgit_mc.currentFrame == this.widgit_mc.timeline.duration -1 || this.widgit_mc.currentFrame > 0){
this.widgit_mc.gotoAndStop(this.widgit_mc.currentFrame - 1);
}
if (this.widgit_mc.currentFrame == 0){
this.iNav_mc.back_btn.mouseEnabled = false;
this.iNav_mc.back_btn.alpha = .5;
this.iNav_mc.play_btn.mouseEnabled = true;
this.iNav_mc.play_btn.alpha = 1.0;
this.direction_txt.text = "Click to advance";
}else{
this.iNav_mc.back_btn.mouseEnabled = true;
this.iNav_mc.back_btn.alpha = 1.0;
this.iNav_mc.play_btn.mouseEnabled = true;
this.iNav_mc.play_btn.alpha = 1.0;
this.direction_txt.text = "Click to advance";
}
}

 

 

 

Views

99

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

Tween a movieclip to fadein with Javascript

Explorer ,
Sep 26, 2019

Copy link to clipboard

Copied

I'm tring to make a movieclip fade in after a mouse click. When I used AS 3 I was using Tween transition, but I'm now I'm using Animate Canvas. I'm not sure how to do this? my files FLA files

AS 3

 

 

 

function widgitFadeIn():void
{
fadeIn = new Tween(widgit_mc,"alpha",Strong.easeInOut,0,1,1,true);
}

iNav_mc.play_btn.addEventListener(MouseEvent.CLICK, onNext);

function onNext(e:MouseEvent):void
{
widgitFadeIn();
if (widgit_mc.currentFrame >= 1)
{
widgit_mc.nextFrame();
Tools.disableButton(iNav_mc.pause_btn);
Tools.enableButton(iNav_mc.back_btn);
direction_txt.text = "Click to advance";
}

if (widgit_mc.currentFrame == widgit_mc.totalFrames)
{
Tools.enableButton(iNav_mc.back_btn);
Tools.disableButton(iNav_mc.play_btn);
direction_txt.text = "Previous view";
}
}

 

 

 

 

Javascript

 

 

 

stage.on("drawstart", setInt, this, true);

function setInt(){
this.iNav_mc.back_btn.mouseEnabled = false;
this.iNav_mc.back_btn.alpha = .5;
this.direction_txt.textBaseline='top';
}

this.iNav_mc.play_btn.addEventListener("click", onNext.bind(this));

function onNext(){

if(this.widgit_mc.currentFrame >= 0){
this.widgit_mc.gotoAndStop(this.widgit_mc.currentFrame + 1);
}
if(this.widgit_mc.currentFrame == this.widgit_mc.timeline.duration -1){
this.iNav_mc.play_btn.mouseEnabled = false;
this.iNav_mc.play_btn.alpha = .5;
this.direction_txt.text = "END of Widgit";
}else{
this.iNav_mc.back_btn.mouseEnabled = true;
this.iNav_mc.back_btn.alpha = 1.0;
}
}

this.iNav_mc.back_btn.addEventListener("click", onPrev.bind(this));
function onPrev(){


if(this.widgit_mc.currentFrame == this.widgit_mc.timeline.duration -1 || this.widgit_mc.currentFrame > 0){
this.widgit_mc.gotoAndStop(this.widgit_mc.currentFrame - 1);
}
if (this.widgit_mc.currentFrame == 0){
this.iNav_mc.back_btn.mouseEnabled = false;
this.iNav_mc.back_btn.alpha = .5;
this.iNav_mc.play_btn.mouseEnabled = true;
this.iNav_mc.play_btn.alpha = 1.0;
this.direction_txt.text = "Click to advance";
}else{
this.iNav_mc.back_btn.mouseEnabled = true;
this.iNav_mc.back_btn.alpha = 1.0;
this.iNav_mc.play_btn.mouseEnabled = true;
this.iNav_mc.play_btn.alpha = 1.0;
this.direction_txt.text = "Click to advance";
}
}

 

 

 

Views

100

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
Sep 26, 2019 0

Have something to add?

Join the conversation