Skip to main content
Participant
October 16, 2012
Question

Moving three movie clips together to a y co-ordinate of an event click

  • October 16, 2012
  • 3 replies
  • 848 views

I have 9 buttons (with instance names mov_1 - mov_9) verticle along a page. I want movie clips a, b and c. with instance names (ltop, graphic and lbottom). to move in parrallel down the page to the y co-ordinates of each of the 9 button movie clips when clicked on. My code so far for each of the cases is:

  public function onClicked( e:MouseEvent ):void

  {

   var circle:MovieClip = e.currentTarget as MovieClip;

   HtmlTextFieldFactory.formatTextFields(  [panel.title, panel.content], this.context );

  

   switch( circle )

   {

    case mov_1:

     panel.title.htmlText = _modelDataHelper.getTextAssets( "ct1" );

     panel.content.htmlText = _modelDataHelper.getTextAssets( "c1" );

     panel.x = 30;

     panel.y = 438;

     circle.alpha = 1;

     circle.removeEventListener(MouseEvent.MOUSE_OUT, onMouseOut );

     circle.removeEventListener(MouseEvent.MOUSE_OVER, onMouseOver );

    

     var mov_1_y:Number = mov_1.y;

     var myTween1a:Tween = new Tween(graphic, "scaleY", Strong.easeOut, graphic.scaleY, 1, 2, true);

     var myTween1b:Tween = new Tween(graphic, "y", Strong.easeOut, graphic.y, mov_1_y, 2, true);

     var myTween1c:Tween = new Tween(ltop, "y", Strong.easeOut, ltop.y, graphic.y, 2, true);

     var myTween1d:Tween = new Tween(lbottom, "y", Strong.easeOut, lbottom.y, graphic.y + 135, 2, true);

    

     break;

Currently on one click of mov_1, graphic moves to the correct place. But it takes a second click before ltop and lbottom move to the correct place. I am needing them to move at the same time, together.

Any suggestions?

Thanks

This topic has been closed for replies.

3 replies

kim shepAuthor
Participant
October 17, 2012

Thanks for your replys.

Yes I realised it was getting the y values of where the graphic was before the tween. therefore it wasnt following it. I changed it to mov_1 and its working fine now. Silly mistake!

Ned Murphy
Legend
October 17, 2012

You're welcome

Inspiring
October 16, 2012

This is happening because of what the value of graphic.y is at the time of instantiating myTween1c and myTween1d. Perhaps they should be this:

var myTween1c:Tween = new Tween(ltop, "y", Strong.easeOut, ltop.y, mov_1_y, 2, true);

var myTween1d:Tween = new Tween(lbottom, "y", Strong.easeOut, lbottom.y, mov_1_y + 135, 2, true);

HTH

Ned Murphy
Legend
October 16, 2012

How are things located before the first click?  The value of graphic.y that will be used for tweening the other two is whatever it is before graphic moves.  Are the conditions you set for lbottom and ltop already equal to what they would be for the first tween such that they would not have to move (is ltop.y already == graphic.y and is lbottom.y already == graphic.y + 135 before the first click occurs)?  Should their relocations be based on the same thing that the graphic uses (mov_1_y)  instead of graphic?

I am not sure if that is a typo as far as mov_1_y goes... should that be mov_1.y?