Copy link to clipboard
Copied
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?
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
...Copy link to clipboard
Copied
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();
}
Copy link to clipboard
Copied
Hi
Thanks but is not working any other idea?
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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();
}
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
follow the suggestions in message 3 to debug your code.
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
you used .play instead of .play() somewhere.
check line 144 of start.js
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
is zivtn.arowbtn a movieclip (and not a button or anything else)?
Copy link to clipboard
Copied
zivbtn is a movie clip
inside zivbtn there is arowbtn which is a movie clip
both "zivbtn" and "arowbtn" are the instance names
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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();
}
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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();
}
Copy link to clipboard
Copied
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
thanks
Copy link to clipboard
Copied
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); |
Copy link to clipboard
Copied
Thank you very much
it works!! great explantion works in first shot
i'll try to lean from it for the next time