Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

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

Community Beginner ,
Jul 24, 2020 Jul 24, 2020

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 !

 

TOPICS
ActionScript
960
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 24, 2020 Jul 24, 2020

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 26, 2020 Jul 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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 27, 2020 Jul 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 28, 2020 Jul 28, 2020

thank you for your inputs - the problem is, that the way you sugest, it plays over and over again - instead of playing it once and then stop.

my idea is, that the mc_subtraktiv plays whithin itself until frame 31. on frame 31 of the mc_subtraktiv is the code to drag and drop the mc_cyan2.  if i click on the button on the main timeline, the mc-subtraktiv should play again from frame 1 - but it does it only with the mc's i did not drag and drop before.

the drag and drop does obviousley not only work on frame 31 of the mc _subtraktiv. when i drop it somewhere it is out of control... it does not move at all anymore. what am i doing wrong? 

 

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 29, 2020 Jul 29, 2020

are you saying this.stop() fails to work on frame 31 of mc_subtraktive after working once?  ie, mc_subtraktive loops after its first stop at frame 31?

 

if not, what do you mean by:  "..it plays over and over again..."

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 30, 2020 Jul 30, 2020

yes i am saying this.stop(); on frame 31 of mc_subtraktiv which is not on stage but in the library.

the idea is that it is loading a new instance every time i put the button, to make sure, that it really starts at frame 1 with the original position of cyan2. but it does not. after i drag and drop and then click the button - it should load the instance new. but it obviously don't. the cyan2 stays where it was before.

here is the code

maybe you see, what i do wrong? thanks so much for your help!

var neueInstanzSubtraktiv:Subtraktiv = new Subtraktiv();
addChild(neueInstanzSubtraktiv);



button1.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler);

function fl_MouseClickHandler(event:MouseEvent):void
{

	trace("Mausklick erfolgt");
	
	
	neueInstanzSubtraktiv.gotoAndPlay(1);

}



neueInstanzSubtraktiv.cyan2.addEventListener(MouseEvent.MOUSE_DOWN, fl_ClickToDrag_2);

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


this.addEventListener(MouseEvent.MOUSE_UP, fl_ReleaseToDrop_2);

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


 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 30, 2020 Jul 30, 2020

you'll need to reset cyan2's position or create a new Subraktiv instance.  eg, the former:

 

button_1.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler);

function fl_MouseClickHandler(event:MouseEvent):void
{

subtraktiv.cyan2.x = whatever_x;

subtraktiv.cyan2.y = whatever_y;
subtraktiv.play();
}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 31, 2020 Jul 31, 2020

unfortunately this does not work. after clicking the button, the mc subtraktiv does not play anymore. it stays static in the whatever_y position if i wirte the script the way you suggest.

the mc subtraktiv is in the library and the mc cyan2 inside is a blue dot, animated with single frames, that moves in mc subtraktiv from one place to another. i think this is correct.

then i load the mc subtraktiv with

var neueInstanzSubtraktiv:Subtraktiv = new Subtraktiv();
addChild(neueInstanzSubtraktiv);

the idea is, that it loads it new and after i click the button, it plays it from the original position - but it doesn't.

what am i doing wrong?

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 01, 2020 Aug 01, 2020

use:

 

button_1.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler);

function fl_MouseClickHandler(event:MouseEvent):void
{

neueInstanzSubtraktiv.cyan2.x = whatever_x;

neueInstanzSubtraktiv.cyan2.y = whatever_y;
neueInstanzSubtraktiv.play();
}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 04, 2020 Aug 04, 2020

it still does not work! after clicking the button, the mc subtraktiv does not play anymore. it stays static in the whatever_x, whatever_y position if i wirte the script the way you suggest.

if i click the button, it should play the neueInstanzSubtraktiv from frame 1 to frame 31 again - but it doesn't. why?

thanks for help again!

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 05, 2020 Aug 05, 2020

if you want to play from frame 1, use:

 

neueInstanzSubtraktiv.gotoAndPlay(1);

 

but i think we've already gone through that option though possibly you tried subtraktiv.gotoAndPlay(1) because you gave incorrect information at that time.

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 06, 2020 Aug 06, 2020

i did exactly the way you suggest. it does not work !

if i write neueInstanzSubtraktiv.gotoAndPlay(1);

it only plays from frame 2 - i controlled it with a blue line only visible in frame 1 and a black dot only visible in frame 2 of the mc neueInstanzSubtraktiv - they should blink up, when i click the button.

the black dot blinks up when i wirte neueInstanzSubtraktiv.gotoAndPlay(1);

the blue line and the black dot blink up when i wirte neueInstanzSubtraktiv.play();

this seems to me quite strange...? if i write neueInstanzSubtraktiv.gotoAndPlay(2); it plays from frame 3

if i write neueInstanzSubtraktiv.gotoAndPlay(0); it still plays from frame 2

why does it not play from frame 1 if i wirte so?

 

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 10, 2020 Aug 10, 2020

someone will probably need to download your fla and correct your code.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 16, 2020 Aug 16, 2020
LATEST

yes i think so to. unfortunately i do not know anybody who could do this. the only forum i found is this here - is there a possibility to upload it here?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines