PDA

View Full Version : Switch Content Script and flash buttons



robbrucker
11-10-2008, 01:38 PM
1) Script Title: Switch Content Script

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex17/switchcontent.htm

3) Describe problem: I'm looking to use a flash button or movie clip instead of the typical text used in this script. I have my page set up as such





<span id="bobcontent1-title" class="handcursor">


<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="200" height="50" id="bobcontent1-title" align="middle">
<param name="allowScriptAccess" value="sameDomain" />
<param name="allowFullScreen" value="false" />
<param name="movie" value="tester.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /> <embed src="tester.swf" quality="high" bgcolor="#ffffff" width="200" height="50" name="tester" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>



</span>


Basically I thought wrapping a span tag around it would do the trick, but it didn't. I also tried to declare the bobcontent in the id of the flash object, but that didn't work either. Does anyone have any suggestions, or know how to do this?

Thanks

Rob

ddadmin
11-11-2008, 06:27 AM
This will only work if your Flash code triggers a JavaScript onClick event when clicked on. Basically, if you can embed your Flash code in a way that you get an alert message when the below is clicked on?


<span onClick="alert('hi')">
Flash code here
</span>

I'm not familiar enough with Flash to know exactly what needs to be done unfortunately.

robbrucker
11-11-2008, 10:38 AM
I think I know what you mean, I will find out exactly how to get the flash to trigger a javascript action and post it in here

So just to make sure I'm on the right page, I would need my flash button to trigger a javascript variable, and then call that within the span on the onclick?

Thanks for your help!

ddadmin
11-11-2008, 10:43 AM
So just to make sure I'm on the right page, I would need my flash button to trigger a javascript variable, and then call that within the span on the onclick?

Not exactly. You want to either:

1) Configure your Flash code so clicking on it causes the onClick event handler of the containing SPAN to fire. In the above sample, an alert message will pop up if successful:


<span onClick="alert('hi')">
Flash code here
</span>

OR

2) Modify your Flash code to call a JavaScript code when clicked on, or the direct approach:

<span>

<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="200" height="50" id="bobcontent1-title" align="middle">
<param onClick="alert('hi')" />
</object>
</span>

For the later, that's just a mockup, as I have no idea how or if Flash can call a JavaScript code when clicked on directly.