Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

href css to trigger function in javascript

Status
Not open for further replies.

Wulfgen

Technical User
Dec 31, 2004
283
US
I have an interesting one here - I jave a client who wants a sound file to play whenever a user scrolls over a link/menu item ( external javascript menu system) Yea, I know, I've been around the midi-wav-mov thing and the best results I have at this point is an embeded swf file with the sound effect and stop start play triggers inside attached via actionscript the the audio.

there is an external soundcheck.js file (checks the browser version and writes the flash variables to the page - using a document.write)

the trigger on the page is <A href="#" target="_blank" onmouseover="mySwf.Play(); return false">Rollover Me</A>

the external js is:<SCRIPT LANGUAGE="JavaScript" SRC="arrays/efx.js"></SCRIPT>

and the js is

Code:
winIEpass = ((navigator.appName.indexOf("Microsoft") != -1) && 
(navigator.appVersion.indexOf("Windows") != -1)) && 
(parseFloat(navigator.appVersion) >= 4) ? true : false;

NNpass = ((navigator.appName == "Netscape") && 
(navigator.userAgent.indexOf("Mozilla") != -1) && 
(parseFloat(navigator.appVersion) >= 4) && 
(navigator.javaEnabled())) ? true : false;

supportedBrowser = (winIEpass || NNpass) ? true : false;

// check for Flash Plug-in in Mac or Win Navigator. Get plug-in version.


minPlayer = 4;
var mySwf;

function Flash_checkForPlugIn() {
  var plugin = (navigator.mimeTypes &&
  navigator.mimeTypes["application/x-shockwave-flash"]) ?
  navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
  if (plugin) {
    var pluginversion =      parseInt(plugin.description.substring(plugin.description.indexOf(".")-1)) 
    if(pluginversion >= minPlayer) {return true;}
  }
  return false;
}

// vbscript check for Flash ActiveX control in windows IE
if(supportedBrowser && winIEpass)
{
document.write(
		'<script language=VBScript>' + '\n' +
		'Function Flash_checkForActiveX()' + '\n' +
			'Dim hasPlayer, playerversion' + '\n' +
			'hasPlayer = false' + '\n' +
			'playerversion = 10' + '\n' +
			'Do While playerversion >= minPlayer' + '\n' +
				'On Error Resume Next' + '\n' +
				'hasPlayer = (IsObject(CreateObject(\"ShockwaveFlash.ShockwaveFlash.\" & playerversion & \"\")))' + '\n' +
				'If hasPlayer = true Then Exit Do' + '\n' +
				'playerversion = playerversion - 1' + '\n' +
			'Loop' + '\n' +
			'Flash_checkForActiveX = hasPlayer' + '\n' +
		'End Function' + '\n' +
		'<\/script>'
		);
}



function Flash_checkForMinPlayer()
{
if(!supportedBrowser) return false;
if(NNpass) return (Flash_checkForPlugIn());
if(winIEpass) return (Flash_checkForActiveX());
}



function Flash_embedSWF(srcURL, swfbgColor)
{

if (!Flash_checkForMinPlayer()) return;

var defaultColor = (document.bgColor != null) ? document.bgColor : "#ffffff";
var bgcolor = (swfbgColor != null) ? swfbgColor : defaultColor;

document.writeln(
'<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"' +
'codebase="[URL unfurl="true"]http://active.macromedia.com/flash2/cabs/swflash.cab#version=4,0,0,0"'[/URL] +
'ID="sonify" WIDTH=1 HEIGHT=1>' +
'<PARAM NAME=movie VALUE="' + srcURL + '">' + 
'<PARAM NAME=quality VALUE=low>' +
'<PARAM NAME=wmode VALUE=transparent>'+
'<PARAM NAME=bgcolor VALUE=' + bgcolor + '>' +
'<EMBED swLiveConnect="true" NAME="sonify"' +
'src="' + srcURL + '"' +
'quality=low' +
'wmode=transparent' +
'bgcolor=' + bgcolor + 
'WIDTH=1 HEIGHT=2' +
'TYPE="application/x-shockwave-flash"'+	
'PLUGINSPAGE="[URL unfurl="true"]http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">'[/URL] +
'</EMBED>' + 
'</OBJECT>'
);
}

function sonified_flash(myFrame){
if(!Flash_checkForMinPlayer()) {return;}

	mySwf = window.document.sonify;
	if (mySwf.PercentLoaded()<100) return

	mySwf.GotoFrame(myFrame);
	mySwf.GotoFrame(0);
}


Flash_embedSWF("flash/pop.swf");var mySwf = window.document.sonify;

it works great on a page by itself but as you can see from the snippet below there are no parameters for me to address any other calls from the menu

Code:
/// tech	
addmenu(menu=["tech",,,200,1,,style1,0,"left",effect,0,,,,,,,,,,,
	,"&nbsp;&nbsp;Amber GyroBall","ambergyro.html",,,1
	,"&nbsp;&nbsp;Blue GyroBall","bluegyro.html",,,1
	,"&nbsp;&nbsp;DynaFlex Dynamo Gyro","dynamo.html",,,1
	,"&nbsp;&nbsp;DynaBee Super Gyro","supergyro.html",,,1
	,"&nbsp;&nbsp;Gel Shoulder Strap","shoulder.html",,,1
	,"&nbsp;&nbsp;Gel Handle Strap","handle.html",,,1
	,"&nbsp;&nbsp;PowerDock [Electric Starter]","dock.html",,,1
	,"&nbsp;&nbsp;Pro Plus Gyro","proplus.html",,,1
	,"&nbsp;&nbsp;Pro Gyro","progyro.html",,,1
	,"&nbsp;&nbsp;Speedmeter","meter.html",,,1
	,"&nbsp;&nbsp;Theragrip Sports Gyro","sportsgyro.html",,,1
	])

so... bear with me... is there a way to have the onmouseover="mySwf.Play(); return false" function activate from ANY href rollover using css ( something like a:active { do_funtion(); }?? or a.something?
I'm not THAT good at css -- Thanks
.
 
Could aural style sheets help if you are just looking to play a sound? use with a:hover?

or am I being silly
 
No... aural sounds deal with midi and other speech synthesizers

Speech synthesizer to speak headers in a voice (a kind of "audio font") called "paul", on a flat tone, but in a very rich voice. Before speaking the headers, a sound sample will be played from the given URL. Paragraphs with class "heidi" will appear to come from front left (if the sound system is capable of spatial audio), and paragraphs of class "peter" from the right. Paragraphs with class "goat" will be very soft.

and as I mentioned numerous times above and even included code - I'm strictly dealing with an embeded flash file as opposed to a backfground midi or wav file...

....... ??
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top