Problem with JavaScript interacting with Flash
I'm trying to read in a cookie and go to whatever frame it specifies in a Flash movie. The reading of the cookie is working fine, but when I call GotoFrame, it stops working.
Here's my Javascript. Any help would be much appreciated!
Quote: var framenum = getCookie();
var bannerad = getFlashMovieObject('bannerad');if (framenum)
{
bannerad.GotoFrame(framenum);
}function getFlashMovieObject(movieName)
{
if (window.document[movieName])
{
return window.document[movieName];
}
if (navigator.appName.indexOf("Microsoft Internet")==-1)
{
if (document.embeds && document.embeds[movieName])
return document.embeds[movieName];
}
else // if (navigator.appName.indexOf("Microsoft Internet")!=-1)
{
return document.getElementById(movieName);
}
}function getCookie()
{
var dc = document.cookie;
var prefix = "bannerframe=";
var begin = dc.indexOf("; " + prefix);
if (begin == -1)
{
begin = dc.indexOf(prefix);
if (begin != 0) return null;
}
else
{
begin += 2;
}
var end = document.cookie.indexOf(";", begin);
if (end == -1)
{
end = dc.length;
}
return unescape(dc.substring(begin + prefix.length, end));
}
timjpriebe posted this at 03:14 — 30th September 2005.
He has: 2,667 posts
Joined: Dec 2004
Okay, turns out I need to just use bannerad.PercentLoaded to keep it from going to the frame framenum until it's completely loaded.
I'm currently scouring the web for solutions, but if anyone knows, that would be some good info for me to have. It will help me avoid staying up too late tonight to meet this deadline.
Tim
http://www.tandswebdesign.com
timjpriebe posted this at 04:17 — 30th September 2005.
He has: 2,667 posts
Joined: Dec 2004
Now I can get it working in Firefox using this line:
var bannerad = window.document.bannerad;
However, that won't work in IE. Everything I've read so far online says the following should work in IE:
var bannerad = document.getElementById("bannerad");
But that isn't working either.
If I have to chose, I'd rather get it working in IE than Firefox. Any ideas?
Tim
http://www.tandswebdesign.com
bja888 (not verified) posted this at 06:00 — 30th September 2005.
They have: 5,633 posts
Joined: Jan 1970
Well, I was not aware you can pull javascript veriables out of a flash object... All I can tell you is to make sure your id attribute is "bannerad". Also that you are putting the html in right.
timjpriebe posted this at 06:21 — 30th September 2005.
He has: 2,667 posts
Joined: Dec 2004
Neither was I before tonight.
For anyone wanting to check out my code, it's at http://tinyurl.com/cqd6l
And here's the javascript the Flash banner is executing once at the beginning of it's timeline.
var framenum = getCookie();
What's really wierd is that it seems to work fine here:
http://www.permadi.com/tutorial/flashGetObject/
Tim
http://www.tandswebdesign.com
timjpriebe posted this at 06:30 — 30th September 2005.
He has: 2,667 posts
Joined: Dec 2004
Okay, I'm getting ready to show this to a client tomorrow, so I'm going disable everything that's working in Firefox but not IE. Feel free to continue to comment if you know of any solutions.
Tim
http://www.tandswebdesign.com
bja888 (not verified) posted this at 13:02 — 30th September 2005.
They have: 5,633 posts
Joined: Jan 1970
wow, I have no idea....
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.