Skip to main content
Known Participant
July 24, 2020
Question

drag and drop in instance, button on main timeline dos not play instance from beginning

  • July 24, 2020
  • 1 reply
  • 1328 views

hi - i created an mc with instancename subtraktiv that plays automaticly until frame 31. in frame 31 i have the actionscript for drag and drop for a mc named cyan2

here is the code in the timeline of mc subtraktiv :

this.stop();

cyan2.addEventListener(MouseEvent.MOUSE_DOWN, fl_ClickToDrag_8);

function fl_ClickToDrag_8(event:MouseEvent):void
{
cyan2.startDrag();
}

stage.addEventListener(MouseEvent.MOUSE_UP, fl_ReleaseToDrop_8);

function fl_ReleaseToDrop_8(event:MouseEvent):void
{
cyan2.stopDrag();
}

 

in the main scene is a button to replay the mc subtraktiv

here is the code:

button_1.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler);

function fl_MouseClickHandler(event:MouseEvent):void
{
subtraktiv.play();
}

 

the problem - when i klick on the button - it works - the mc subtraktiv plays again. but when i drag and drop the mc cyan2 and afterwards i click on the button to replay the mc subtraktiv - it does replay the mc subtraktiv but the moved element befor does not play anymore - it remains on the draged position.

why?

i say - play it again from frame number 1 where the element has its fixed place - why does it ignore it?

what am i doing wrong?

thanks for help !

 

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
July 24, 2020

subtraktiv needs to play a keyframe where cyan2 is at its initial position.

Known Participant
July 26, 2020

this is what i thought that i am doing with the command subtraktiv.play();

i tried to write subtraktiv.play(1); but this does not work

kglad
Community Expert
Community Expert
July 27, 2020

subtraktiv.play() continues playing subtraktiv from where it last stopped.  that's not necessarily from the keyframe where cyan2 was instantiated and because of what you report seeing, it is NOT the frame where cyan2 was instantiated.

 

eg, if cyan2 is created on the initial frame of subtraktiv, then you would use:

 

subtraktiv.gotoAndPlay(1)

 

to play subtraktiv from its initial frame where cyan2 is created and at its initial position.