Skip to main content
Known Participant
May 18, 2015
Question

Button control Movie clip

  • May 18, 2015
  • 1 reply
  • 321 views

Hi,

I have a script that work well: (No problems..)

Buth_CathRed.addEventListener(MouseEvent.CLICK, fl_ClickToGoToNextFrame_2);

function fl_ClickToGoToNextFrame_2(event:MouseEvent):void

{

  nextFrame();

}

This script controa simple timline (Just jump from one keyframe to another and back..  - Only 2 keyFrames at this movie)

I want to add another script that will work when i will press on the same button (Buth_CathRed).

This is the script that want to add:

this.Pannel_m.gotoAndStop(2);


The button suppose to control also another movie clip that is outside the button movieclip.


I dont understand how and were do I add that script  ( this.Pannel_m.gotoAndStop(2);  )


I cant put them on the same timeline becouse one has animation and one is static..



also: what is the simplest way to creat simple scrip the button that control movie clip (The button is outside the MC)?..


Thanks alot!!!

and hope I wrote it right.. (:

This topic has been closed for replies.

1 reply

Ned Murphy
Legend
May 18, 2015

It is not clear from your description where the different object reside relative to the main timeline.  One way to approach a design is to keep all of the code in the main timeline to make it simpler to determine the path to targeting different objects.

If the button is inside a movieclip and Pannel_m is also in the timeline that the movieclip is in then you would have to use a Movieclip(parent) reference to target back to the parent timeline.  But if you place all the code in the main timeline it becomes easier to manage the targeting because everything has the same reference basis.

The following works if Pannel_m is in the same timeline as the Buth_CathRed

Buth_CathRed.addEventListener(MouseEvent.CLICK, fl_ClickToGoToNextFrame_2);

function fl_ClickToGoToNextFrame_2(event:MouseEvent):void

{

     nextFrame();

     Pannel_m.gotoAndStop(2);

}

The following works if Pannel_m is in the same timeline as the movieclip that contains Buth_CathRed

Buth_CathRed.addEventListener(MouseEvent.CLICK, fl_ClickToGoToNextFrame_2);

function fl_ClickToGoToNextFrame_2(event:MouseEvent):void

{

     nextFrame();

     Movieclip(parent).Pannel_m.gotoAndStop(2);

}

Known Participant
May 19, 2015

Thanks!!

Ned Murphy
Legend
May 19, 2015

You're welcome