None of the similar answered questions fixed my problem, so here it goes. I want to call actionscript 3 function from JavaScript but in FF error console it says that the function I'm calling from JS does not exist. It says functions mover and mout are not defined.
Here is the JS functions in JS file
function getFlashMovieObject(movieName) {
var isIE = navigator.appName.indexOf("Microsoft") != -1;
return (isIE) ? window[movieName] : document[movieName];
}
function playF() {
getFlashMovieObject("Button2").mover();
}
function playB() {
getFlashMovieObject("Button2").mout();
}
Here's the code in HTML
<object style="width: 413px; height: 76px;" id="Button2" onMouseOver="playF()" onMouseOut="playB()">
<param name="movie" value="homepage/flash/Button2.swf">
<param value="transparent" name="wmode"/>
<param value="false" name="loop"/>
<embed wmode="transparent" play=false src="homepage/flash/Button2.swf" width="413" height="76" loop="false" swliveconnect="true" name="Button2"></embed>
</object>
And the code in Actionscript 3
ran.stop();
function mover() {
stopPlayReverse();
this.addEventListener(Event.ENTER_FRAME, playForward, false, 0, true);
}
function mout() {
stopPlayForward();
this.addEventListener(Event.ENTER_FRAME, playReverse, false, 0, true);
}
function playReverse(e:Event):void {
if (ran.currentFrame == 1) {
stopPlayReverse();
} else {
ran.prevFrame();
}
}
function playForward(e:Event):void {
if (ran.currentFrame == ran.totalFrames) {
stopPlayForward();
} else {
ran.nextFrame();
}
}
function stopPlayForward():void {
if (this.hasEventListener(Event.ENTER_FRAME)) {
ran.removeEventListener(Event.ENTER_FRAME, playForward);
}
}
function stopPlayReverse():void {
if (this.hasEventListener(Event.ENTER_FRAME)) {
ran.removeEventListener(Event.ENTER_FRAME, playReverse);
}
}
ExternalInterface.addCallback("mover", mover);
ExternalInterface.addCallback("mout", mout);
The idea is that I want to control the mouse hovering with javascript and when I hover over the object the movie plays normally but when I hover out then the movie plays backwards. I have the movie clip on one layer and on the other layer I have my actionsrcript code. Can anyone tell me what I'm doing wrong? Thanks
return document.getElementById(movieName)