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

Can you help me to find my mistake in code?

Community Beginner ,
May 02, 2012 May 02, 2012

Copy link to clipboard

Copied

Hello! Can you help me to find my mistake in code? Bottoms don't correctly work always and images shows inconsistently. Thank you.

stop();

import fl.transitions.Tween;

import fl.transitions.easing.*;

var arrayX:Array = [0,-600,-1200];

var currentIndex:Number = 0;

left_mc.addEventListener(MouseEvent.CLICK,navigate);

right_mc.addEventListener(MouseEvent.CLICK,navigate);

left_mc.buttonMode = true;

right_mc.buttonMode = true;

function navigate(e:MouseEvent):void

{

          if (e.currentTarget == left_mc)

          {

                    currentIndex--;

                    checkArrows();

                    var stw1:Tween = new Tween(content_mc,"x",Back.easeOut,arrayX[currentIndex],arrayX[currentIndex - 1],4,true);

          }

          else

          {

                    currentIndex++;

                    var stw:Tween = new Tween(content_mc,"x",Back.easeOut,arrayX[currentIndex - 1],arrayX[currentIndex],4,true);

                    checkArrows();

          }

}

function checkArrows():void

{

          if (currentIndex == 0)

          {

                    left_mc.visible = false;

          }

          else if (currentIndex == arrayX.length - 1)

          {

                    right_mc.visible = false;

          }

          else

          {

                    left_mc.visible = true;

                    right_mc.visible = true;

          }

}

TOPICS
ActionScript

Views

820

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 , May 02, 2012 May 02, 2012

the first problem i see is the tweens are local to a function so they are eligible to be gc'd before they complete.  the second is you need to call checkArrows() when you start:

stop();

import fl.transitions.Tween;

import fl.transitions.easing.*;

var arrayX:Array = [0,-600,-1200];

var currentIndex:Number = 0;

left_mc.addEventListener(MouseEvent.CLICK,navigate);

right_mc.addEventListener(MouseEvent.CLICK,navigate);

left_mc.buttonMode = true;

right_mc.buttonMode = true;

checkArrows;

var stw:Tween;

function n

...

Votes

Translate

Translate
Community Expert ,
May 02, 2012 May 02, 2012

Copy link to clipboard

Copied

the first problem i see is the tweens are local to a function so they are eligible to be gc'd before they complete.  the second is you need to call checkArrows() when you start:

stop();

import fl.transitions.Tween;

import fl.transitions.easing.*;

var arrayX:Array = [0,-600,-1200];

var currentIndex:Number = 0;

left_mc.addEventListener(MouseEvent.CLICK,navigate);

right_mc.addEventListener(MouseEvent.CLICK,navigate);

left_mc.buttonMode = true;

right_mc.buttonMode = true;

checkArrows;

var stw:Tween;

function navigate(e:MouseEvent):void

{

          if (e.currentTarget == left_mc)

          {

                    currentIndex--;

                    checkArrows();

                    stw = new Tween(content_mc,"x",Back.easeOut,arrayX[currentIndex],arrayX[current Index - 1],4,true);

          }

          else

          {

                    currentIndex++;

                    stw= new Tween(content_mc,"x",Back.easeOut,arrayX[currentIndex - 1],arrayX[currentIndex],4,true);

                    checkArrows();

          }

}

function checkArrows():void

{

          if (currentIndex == 0)

          {

                    left_mc.visible = false;

          }

          else if (currentIndex == arrayX.length - 1)

          {

                    right_mc.visible = false;

          }

          else

          {

                    left_mc.visible = true;

                    right_mc.visible = true;

          }

}

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 Beginner ,
May 02, 2012 May 02, 2012

Copy link to clipboard

Copied

Thank you so much!

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 ,
May 02, 2012 May 02, 2012

Copy link to clipboard

Copied

LATEST

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