Skip navigation
createflash@mail.ru
Currently Being Moderated

Can you help me to find my mistake in code?

May 2, 2012 9:08 AM

Tags: #problem #error #flash #script #3.0 #button #action #action_script_3 #as3.0 #actionscript_3.0

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[current Index - 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;

          }

}

 
Replies
  • kglad
    72,357 posts
    Jul 21, 2002
    Currently Being Moderated
    May 2, 2012 10:11 AM   in reply to createflash@mail.ru

    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;

              }

    }

     
    |
    Mark as:
  • kglad
    72,357 posts
    Jul 21, 2002
    Currently Being Moderated
    May 2, 2012 10:01 PM   in reply to createflash@mail.ru

    you're welcome.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points