Click to See Complete Forum and Search --> : Need to change the onclick


swoop80
06-25-2007, 12:34 AM
Well... i've blown an entire day searching for solutions on this... that's not exactly surprising... i'm a rookie at javascript and all things webbish... haha

I've learned how to use basic 'flash' now... and i've incorporated it into a website I'm playing with... but I then decided I wanted the flash movie (swf) to also act as a 'link' to another page on the site....

Well... the DIV in question (where I'm placing my swf - which is in an IFRAME) is first defined as a regular old DIV... with a static image (a picture of a camera) and an "onclick" event ... to go to the same "photos" page that I want my nifty flash movie to link to... if I can get it working...

I added some detection logic that checks to see if flash is installed on the client computer. The idea is to replace the contents of the DIV (which starts out as the static picture of a camera... with link to a "photo" page on the site) with the nifty flash 'rotating camera' movie... But I really wanted the nifty flash object to also link to that same 'photo page'.

Now, I've been told that there is a way within flash to have the movie do it's own "onclick" event... but I'm trying to learn how to do it in javascript or HTML and not rely on flash for that...

Here is the 'body' of my document...

the swfobject thing is the gizmo that tells me if the client has flash on their computer...

hope you folks can straighten me out

oh.. I actually have tried lots of things in place of the line that is underlined below... (a few of them just made the newly supplied onclick go ahead and fire - without even being clicked on... but I cant even recall what those formats were that made it do that... it was much earlier in the day... haha).

one more quick thing... i was actually thinking that if the DOM record of the onclick simply could be retained (not clobbered) when I copy my flash goodies in via the 'write' statement near the end... then I wouldn't even need to reestablish an onclick... (but then, I probably wouldn't learn everything I'd like to learn here, either...)


<body bgcolor="#000000" text="#FFFFFF" link="#FFFFFF" vlink="#999999" alink="#33FFFF">


<script type="text/javascript" src="swfobject.js"> </script>



<div id="flashcamera" onclick="doPhotos()" style="position:absolute; width:200px; height:150px; z-index:1; left:35px; top:380px;">

<img src="/images/webd_graphics/camera_static.gif" align="absbottom">

</div>



<script type="text/javascript">

var so = new SWFObject("camera3Dg.swf", "mymovie", "140", "110", "3", "#000000");

so.write("flashcamera");

document.getElementById('flashcamera').onclick="doPhotos()";

</script>


</body>

nshiell
06-25-2007, 06:06 AM
What i don't understand what r u trying to do?

swoop80
06-25-2007, 08:57 AM
sorry it's unclear.

in my "body", i define a "DIV" (see above code).

Then, I replace the contents of that DIV by doing the 'write' near the end... (which inserts the flash movie into that DIV).

When I insert the flash movie into the DIV, this makes me lose my "onclick" value for that DIV...

So, I want to find a javascript way to re-establish an 'onclick' to that DIV once the clobber has happened.

Thanks.

nshiell
06-25-2007, 09:06 AM
how do u know that u have "lost" your onclick?

What might happen is that because flash is not part of the document it just sits in side it when you click on the Flash movie it will not fire off your onclick event because the contects of the flash movie are not part of the document i.e. HTML so the browser won't recognise a click on the flash movie

swoop80
06-25-2007, 10:00 AM
well... I don't know if the onclick is physically present and simply has been rendered inoperative... or if the onclick itself has been clobbered by the swf write that was done... but since in normal circumstances, you can associate an onclick with the image WITHIN the DIV or you can asociate it with the DIV itself, I would assume that there is some way to do what I'm trying to do...

what approach can be used to make onclick operative again (or to attach a new onclick to the DIV that now has the swf in it)?

appreciate the help

nshiell
06-25-2007, 10:07 AM
Question why would you want a javascript onclick event to be accessed from a flash movie?

couldn't you goto into your fla file find the button and edit it's actions so you would have:

on (release)
{
getURL('javascript:doPhotos()');
}
then re-export to swf and try again

swoop80
06-25-2007, 10:13 AM
I tried that in Flash (and yes - supposedly it's doable... but my version of Flash (2004 MX) isn't accepting my encoding of it, though I've tried it several ways... boy, is the Flash programming enviroment a bad one... sheesh) - and couldn't get it to work....

But, I really wouldn't want "logic" to be dictated by my 'graphics' in any way... because then I'd need to know always that I'd have logic updates to do not only in the source code but in those "graphics"... it's just bad business... and besides, there really seems like there'd have to be a way to to control the DOM and the onclick within via the scripting... so, I'm mainly just needing to learn how to do that dynamic work here....