View Full Version : can html trigger flash events?
01-07-2005, 05:22 AM
I guess that's the question. I thought it would be simple to find an answer, but I'm having trouble finding a concise one.
Essentially I'd like an "onclick" event on a link to trigger a flash animation, rather than having an entire flash menu. Ideas?
01-07-2005, 02:15 PM
u could try something like this
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
document.getElementById("flash").innerHTML="<embed src='yourflash.swf' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='xx' height='xx'></embed>";
just be careful not to add any " in between the innerHTML quotes or u'll get a script error, but what this code does is with the onclick even in the link it will embed the flash file dynamically into the page into the span that has an id of flash, and just change the xx's in the height and width to your liking
01-07-2005, 11:17 PM
Thanks, but I'm not sure I'd go that route...
b) the animation will actually already be embedded; what I'm trying to do is have a link, when clicked, trigger a sound or movement from the animation, without having to have the entire menu in Flash.
Hopefully that clears things up a bit... thanks for your help, though :)
01-08-2005, 01:23 AM
if you give your flash embed/object tag an id ..
etc ... id="my_movie">
then set a refererence point (poxy detection (courtesy of MM ;)))
var InternetExplorer = navigator.appName.indexOf("Microsoft") != -1;
var mc = InternetExplorer ? window.my_movie : window.document.my_movie;
should work , once you have the movie reference (mc) you can even call functions and methods declared in that movie (e.g. mc.do_something(variable) )
01-08-2005, 01:50 AM
I did a quick bit of research, and apparently this should work:
//<object> with id="movie"
// <a> with id="playSwf"
document.getElementById('playSwf').onclick = PassFlash;
The 'SetVariable' function is from the MM docs, I think it may be horribly out of date (and won't work with IE/mac)
Then you would create an empty, hidden dynamic text field with a var of 'text' (not an instance name of 'text') which would receive the variable. To detect the presence of the variable from Flash, I'd use an onEnterFrame routine that starts the clip and calls 'delete onEnterFrame;' once the var has been found. The downside of this is that the onEnterFrame routine will eat the users resources (only a tiny bit, but still...) until it is told to get lost.
An easier way would be to dynamically insert a flashvar (http://www.ultrashock.com/ff.htm?http://www.ultrashock.com/tutorials/flashmx/FlashVars.php) into the object tag, unfortunately those variables are read by flash on load, so you would have to find a way of triggering the flashvar import again, which would probably mean refreshing the <object> tag... not ideal, not at all :(
I'm happy to nut this one out a bit more, I just don't have Flash at home so I can't test any of these theories :o
Forget my insane jibberish -- go with firepages' option! :eek:
01-08-2005, 02:47 AM
Cool, thanks for the help guys!
Either way, the movie reference function is just what I need...
01-08-2005, 05:03 AM
I'm assuming that I can assign the target of the link to "href" and call the function through "onclick"?
And you'll also want to 'return false;' so the link isn't followed if js is working.
01-08-2005, 09:05 AM
Oh man, there you go offering valuable, accessible advice that only makes me work harder :D
I was just planning to offer text link alternatives, but your method seems like something I should at least try. Again, I am a total js/flash newbie, so this might take awhile :) The Flash, btw, is only for a silly effect; there's a floating head that makes comments based on your navigation choices. (yes, this is a fun website I'm working on!)
01-15-2005, 11:10 PM
if it cud trigger flash events! learn soming new every day
01-15-2005, 11:41 PM
omg yess u rnt kdding!
Powered by vBulletin® Version 4.2.2 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.