I have a flash (AS2.0) application with a function that i need to trigger from a html form link
The flash function only runs a gotoAndPlay(‘label name’);
So my HTML is
<a href="" id="flashTrigger" />
and my flash function is
function myFunction(){
gotoAndPlay("myLabel");
}
Anyone know either how I can fire the flash function from the html link tag, OR run a “gotoAndPlay” from a Javascript function
Iv looked around and only seem to find how to fire a javascript function from flash
Here is the code I have so far – Im prob doing something stupid
Flash:
ExternalInterface.addCallback( "myExternalMethod", this, myFunction );
function myFunction(){
gotoAndPlay("fade");
}
Javascript
function executeFlash()
{
getObjectById("myFlashID").myExternalMethod();
}
function getObjectById(objectIdStr) {
var r = null;
var o = document.getElementById(objectIdStr);
if (o && o.nodeName == "OBJECT") {
if (typeof o.SetVariable != undefined) {
r = o;
}
else {
var n = o.getElementsByTagName(OBJECT)[0];
if (n) {
r = n;
}
}
}
return r;
}
$(function() {
$('#WhatDoesmean').click(function(){
executeFlash();
});
});
I have set myFlashID to the id of:
initial ‘Object tag’
and IE only ’embed tag’
EDIT:
At the moment I am targeting the flash object fine, it’s the external (flash side) function which is not working
– error message, myExternalMethod is not a function
I have managed to crack the problem by using SWFObject
Accessign the flash objects method was easy through SWFObject.js, however it just wasnt working without it. Not sure why though.
All the above suggestions work with SWFObject.js, but none seemed to work without it
Cheers for everyones suggestions
Andy