Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • EspaƱol
      • FranƧais
      • PortuguĆŖs
  • ę—„ęœ¬čŖžć‚³ćƒŸćƒ„ćƒ‹ćƒ†ć‚£
  • ķ•œźµ­ ģ»¤ė®¤ė‹ˆķ‹°
0

Trying to play a movie clip within a movie clip when hover

Contributor ,
Jul 01, 2017 Jul 01, 2017

Like the  title say i have a MC2 inside MC1

when hover MC1 i want it to stop and MC2 to play

this is my code which is not working

var frequency = 1000;

stage.enableMouseOver(frequency);

this.zivbtn.cursor = "pointer";

stage.enableMouseOver();

myLocalThis01 = this;

this.zivbtn.addEventListener("mouseover", fl_MouseOverHandler);

function fl_MouseOverHandler()

{

  myLocalThis01.zivbtn.stop();

  myLocalThis01.zivbtn.arow-btn.stop();

}

What i am doing wrong?

1.5K
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

correct answers 1 Correct answer

LEGEND , Jul 03, 2017 Jul 03, 2017

You have given arowbtn a name at frame 55, but not in frame 1. Select arowbtn in frame 1 of zivbtn and set the name to be arowbtn.

Also, any one of the movieclips under the cursor could trigger the mouseover, but only zivbtn is of interest. After you add the "click" listener to zivbtn, put this line:

this.zivbtn.mouseChildren = false;

Lastly, the animation you want to show starts at frame 55 (you loop back to 56 in that animation). As it take 55 frames of arowbtn to get to that animation you can ge

...
Translate
Community Expert ,
Jul 01, 2017 Jul 01, 2017

use:

var frequency = 1000;

stage.enableMouseOver(frequency);

this.zivbtn.cursor = "pointer";

stage.enableMouseOver();

myLocalThis01 = this;

this.zivbtn.addEventListener("mouseover", fl_MouseOverHandler.bind(this));

function fl_MouseOverHandler()

{

  this.myLocalThis01.zivbtn.stop();

  this.myLocalThis01.zivbtn.arow-btn.stop();

}

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
Contributor ,
Jul 01, 2017 Jul 01, 2017

Hi

Thanks but is not working any other idea?

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 01, 2017 Jul 01, 2017

open your browser's developer console to see if you have any errors in your code.

if not, use console.log to debug 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 Expert ,
Jul 01, 2017 Jul 01, 2017

If I am reading this correctly and you want one to stop and the other to play then you have to have one on play and the other on stop. You currently have both on stop.

var frequency = 1000;

stage.enableMouseOver(frequency);

this.zivbtn.cursor = "pointer";

stage.enableMouseOver();

myLocalThis01 = this;

this.zivbtn.addEventListener("mouseover", fl_MouseOverHandler);

function fl_MouseOverHandler()

{

  myLocalThis01.zivbtn.stop();

  myLocalThis01.zivbtn.arow-btn.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
Contributor ,
Jul 02, 2017 Jul 02, 2017

You are correct its my fault i change it for testing and copy it to here

regardless it is still not functioning whether it is to stop or to play

To my logic it is seems fine but i am sure i am missing something

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 02, 2017 Jul 02, 2017

follow the suggestions in message 3 to debug 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
Contributor ,
Jul 02, 2017 Jul 02, 2017

this is what i get in console when hover

Uncaught TypeError: Cannot read property 'play' of undefined

at fl_MouseOverHandler (start.js?1499016483388:144)

at lib.Zivbtn.b._dispatchEvent (createjs-2015.11.26.min.js:12)

at a.b.dispatchEvent (createjs-2015.11.26.min.js:12)

at a.b._dispatchMouseEvent (createjs-2015.11.26.min.js:13)

at a.b._testMouseOver (createjs-2015.11.26.min.js:13)

at createjs-2015.11.26.min.js:13

fl_MouseOverHandler @ start.js?1499016483388:144

b._dispatchEvent @ createjs-2015.11.26.min.js:12

b.dispatchEvent @ createjs-2015.11.26.min.js:12

b._dispatchMouseEvent @ createjs-2015.11.26.min.js:13

b._testMouseOver @ createjs-2015.11.26.min.js:13

(anonymous) @ createjs-2015.11.26.min.js:13

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 02, 2017 Jul 02, 2017

you used .play instead of .play() somewhere.

check line 144 of start.js

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
Contributor ,
Jul 02, 2017 Jul 02, 2017

OK

I checked the JS line 144 its the line of the mouse over function

the code is the same as i paste at the begining of the post for some reason it's an error

can anyone explain (attached screenshot)?

* I removed the "-" in arow-btn to make sure its not something with the name

Capture.JPG

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 02, 2017 Jul 02, 2017

is zivtn.arowbtn a movieclip (and not a button or anything else)?

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
Contributor ,
Jul 02, 2017 Jul 02, 2017

zivbtn is a movie clip

inside zivbtn there is arowbtn which is a movie clip

both "zivbtn" and "arowbtn" are the instance names

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 02, 2017 Jul 02, 2017

did you edit the js file and fail to edit your animate code?

if so, fix your animate code and retest.

if you edited your animate code, show your current animate 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
Contributor ,
Jul 02, 2017 Jul 02, 2017

i didn't edit any other file than the animate cc itself

this is the full code i have now in my animate

* when the bold line removed than everything work no errors

this.zivbtn.addEventListener("click", fl_MouseClickHandler.bind(this));

function fl_MouseClickHandler()

{

parent.abc();

}

var frequency = 1000;

stage.enableMouseOver(frequency);

this.zivbtn.cursor = "pointer";

stage.enableMouseOver();

myLocalThis01 = this;

this.zivbtn.addEventListener("mouseover", fl_MouseOverHandler);

function fl_MouseOverHandler()

{

myLocalThis01.zivbtn.stop();

myLocalThis01.zivbtn.arowbtn.play();

}

this.zivbtn.addEventListener("mouseout", fl_MouseOutHandler);

function fl_MouseOutHandler()

{

myLocalThis01.zivbtn.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 Expert ,
Jul 02, 2017 Jul 02, 2017

place arowbtn in a layer of the first frame of zivbtn and extend its layer to the last frame of zivbtn.  make sure there are no keyframes in arowbtn's layer.  test.

if the same error occurs, embed a screenshot showing zivbtn's timeline, arowbtn selected on stage and the properties panel.

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
LEGEND ,
Jul 02, 2017 Jul 02, 2017

I used your code exactly as you wrote it, and made my own zivbtn and arowbtn movieclips, and it worked fine. If I click I get an error, because parent.abc() is unlikely to be a valid statement.

My test was no doubt set up like kglad is telling you to do. One thing though, arowbtn can have keyframes, so long as the 'arowbtn' instance name is there all along.

I added a line to make arowbtn stop too, so my script is:

this.zivbtn.addEventListener("click", fl_MouseClickHandler.bind(this));

function fl_MouseClickHandler() {

  parent.abc();

}

var frequency = 1000;

stage.enableMouseOver(frequency);

this.zivbtn.cursor = "pointer";

stage.enableMouseOver();

myLocalThis01 = this;

this.zivbtn.addEventListener("mouseover", fl_MouseOverHandler);

function fl_MouseOverHandler() {

  myLocalThis01.zivbtn.stop();

  myLocalThis01.zivbtn.arowbtn.play();

}

this.zivbtn.addEventListener("mouseout", fl_MouseOutHandler);

function fl_MouseOutHandler() {

  myLocalThis01.zivbtn.arowbtn.stop();

  myLocalThis01.zivbtn.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
Contributor ,
Jul 03, 2017 Jul 03, 2017

Hi and thanks all

i created a really simple file with and it works

but when i tried to do the same it with my more complex file it didn't work

i don't know if its ok to share files here but here is my .fla if you can take a look i'll be grateful

start.fla - Google Drive

thanks

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
LEGEND ,
Jul 03, 2017 Jul 03, 2017

You have given arowbtn a name at frame 55, but not in frame 1. Select arowbtn in frame 1 of zivbtn and set the name to be arowbtn.

Also, any one of the movieclips under the cursor could trigger the mouseover, but only zivbtn is of interest. After you add the "click" listener to zivbtn, put this line:

this.zivbtn.mouseChildren = false;

Lastly, the animation you want to show starts at frame 55 (you loop back to 56 in that animation). As it take 55 frames of arowbtn to get to that animation you can get confusing behavior. Try changing this line:

myLocalThis01.zivbtn.arowbtn.play();

to be:

myLocalThis01.zivbtn.arowbtn.gotoAndPlay(56);
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
Contributor ,
Jul 03, 2017 Jul 03, 2017
LATEST

Thank you very much

it works!! great explantion works in first shot

i'll try to lean from it for the next 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