Skip to main content
Known Participant
June 20, 2009
Question

tween problem

  • June 20, 2009
  • 1 reply
  • 585 views

hi

I have created a button with the help of the pointer class, to tween a movieClip instance into different positions.

However when the moviec has been initialized onClick4 it

wont carry out the tween in onCloseClick.

Can you tell me why?

thanks very much

mt


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


var myTween : Tween;

tab4_mc.buttonMode = true;
tab4_mc.close_mc.buttonMode = true;

tab4_mc.addEventListener( MouseEvent.ROLL_OVER, Roll4 );
tab4_mc.addEventListener( MouseEvent.ROLL_OUT, Out4 );
tab4_mc.addEventListener( MouseEvent.CLICK, onClick4 );

var tab4RollPoint : Point = new Point ( 372.1 , -218.6 );
var tab4OutPoint : Point = new Point ( 372.1 , -232.1 );
var tab4DownPoint : Point = new Point ( 372.1 , 222.1 );

function Roll4 ( e: MouseEvent ){
   
    myTween = new Tween ( e.target, 'y' , Back.easeOut, e.target.y, tab4RollPoint.y, 1 , true )

}

function Out4 ( e: MouseEvent ){
   
    myTween = new Tween ( e.target, 'y', Back.easeOut, e.target.y, tab4OutPoint.y, 1 , true );
   
}

function onClick4 ( e: Event ) : void {

       
    myTween = new Tween ( e.target, 'y', Back.easeOut, e.target.y, tab4DownPoint.y, 1 , true );
    tab4_mc.removeEventListener( MouseEvent.ROLL_OUT, Out4 );
    tab4_mc.removeEventListener( MouseEvent.ROLL_OVER, Roll4 );
    tab4_mc.close_mc.addEventListener( MouseEvent.CLICK, onCloseClick );
    tab4_mc.buttonMode = false;

}

   
function onCloseClick ( e: Event ) : void {
   
   
    myTween = new Tween ( e.target, 'y', Back.easeOut, e.target.y, tab4OutPoint.y, 1 , true );   ////////this tween does not work !!!

  
   
}

This topic has been closed for replies.

1 reply

funkysoul
Inspiring
June 20, 2009

the oncloseClick function has to be called on a click again, and you need to remove the previous click event when it has been clicked:


something like this:

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


var myTween : Tween;

tab4_mc.buttonMode = true;
tab4_mc.close_mc.buttonMode = true;

tab4_mc.addEventListener( MouseEvent.ROLL_OVER, Roll4 );
tab4_mc.addEventListener( MouseEvent.ROLL_OUT, Out4 );
tab4_mc.addEventListener( MouseEvent.CLICK, onClick4 );

var tab4RollPoint : Point = new Point ( 372.1 , -218.6 );
var tab4OutPoint : Point = new Point ( 372.1 , -232.1 );
var tab4DownPoint : Point = new Point ( 372.1 , 222.1 );

function Roll4 ( e: MouseEvent ){
   
    myTween = new Tween ( e.target, 'y' , Back.easeOut, e.target.y, tab4RollPoint.y, 1 , true )

}

function Out4 ( e: MouseEvent ){
   
    myTween = new Tween ( e.target, 'y', Back.easeOut, e.target.y, tab4OutPoint.y, 1 , true );
   
}

function onClick4 ( e: Event ) : void {

       
    myTween = new Tween ( e.target, 'y', Back.easeOut, e.target.y, tab4DownPoint.y, 1 , true );
    tab4_mc.removeEventListener( MouseEvent.ROLL_OUT, Out4 );
    tab4_mc.removeEventListener( MouseEvent.ROLL_OVER, Roll4 );

    tab4_mc.removeEventListener( MouseEvent.CLICK, onClick4 );
    tab4_mc.close_mc.addEventListener( MouseEvent.CLICK, onCloseClick );
    tab4_mc.buttonMode = false;

}

   
function onCloseClick ( e: Event ) : void {
   
   
    myTween = new Tween ( e.target, 'y', Back.easeOut, e.target.y, tab4OutPoint.y, 1 , true );   ////////this tween does not work !!!

  
   
}

Known Participant
June 21, 2009

thanks for the reply!
it works, however it tweens my close_mc  button up to the top of my stage and not tab4_mc, which is what I want to achieve.

My close_mc button is inside my tab4_mc, does that mean i need to change the definition of my tween statment inside the onCloseClick function?

cheers
mt

Ned Murphy
Legend
June 21, 2009

Instead of e.target, try using e.currentTarget in the Tween arguments