PDA

View Full Version : activate swf without clicking on it.



dgnara
04-23-2007, 10:19 AM
Hi,
I dont know why the swf file has to be clicked in order to start working in explorer, it shows outlined until you click, and then it starts running, any way arround this?

Thanks a bunch! :)

djr33
04-23-2007, 10:34 AM
There's a javascript method, I believe, as well as, I think, modification of part of the object/embed tags.
Try searching the forum, as there have been several discussions of this.

nwalton
04-23-2007, 05:18 PM
The javascript method is discussed in my posts here (http://www.dynamicdrive.com/forums/showthread.php?t=19854).

Hound
04-25-2007, 04:21 PM
I am trying this also.
My test page is www.nickschale.us/joni (the test nav bar is on the ABOUT page)

Pulling my last few hairs out with this... could someone take a look and lend some advice?

pcbrainbuster
04-25-2007, 06:47 PM
Well in JavaScript do this -

<script>
document.onload=function() {
document.getElementById('id').click()
}
</script>

Just replace id with the objects id, though I do not know if this would work for what your looking for, but it does with things like check boxes...

djr33
04-25-2007, 09:02 PM
I doubt it. That's taking too much control of the user's computer. With that, if it worked for anything, you could help the user click ok to agree to install a bunch of spyware, ok to delete all the files on his/her harddrive, then ok to give you his/her credit card numbers.
:p

pcbrainbuster
04-26-2007, 05:18 PM
Its not like that...

nwalton
04-26-2007, 05:52 PM
I am trying this also.
My test page is www.nickschale.us/joni (the test nav bar is on the ABOUT page)

Pulling my last few hairs out with this... could someone take a look and lend some advice?

I looked at your source. One question I have is where your swfobject.js file resides. Is it in the same directory as your page? You probably also want to move your link to that file from the <td> up to the head. Other than that, the only thing I see is that I've never tried to use it within a table. But I can't see why it wouldn't work that way.

pcbrainbuster
04-26-2007, 05:59 PM
It will basically click on the whole obejct itself and not a single area on any object... EG a checkbox...

nwalton
04-26-2007, 05:59 PM
<td colspan="3" bgcolor="#990000"><div id="flashcontent">


<script type="text/javascript" src="swfobject.js"></script>
<div id="flashcontent">
<a href="index.html">Home</a> | <a href="about.html">About</a> | <a href="services.html">Services</a> | <a href="benefits.html">Benefits</a> | <a href="menu.html">Menus</a> | <a href="faq.html">FAQ</a> | <a href="contact.html">Contact</a>
</div>

<script type="text/javascript">
var so = new SWFObject("flash/navbar.swf", "navbar", "790", "25", "8", "#990000");
so.write("flashcontent");
</script></td>

I looked again and found the problem. You've got the "flashcontent" <div> started twice. Delete the first one, and I'd guess you should be good to go.

nwalton
04-26-2007, 06:03 PM
It will basically click on the whole obejct itself and not a single area on any object... EG a checkbox...

By inserting the SWF with a javascript like this, you bypass the need for it to even be clicked in the first place.

pcbrainbuster
04-26-2007, 06:12 PM
I realize that but it was just something I suggested he should try as I had not...

jscheuer1
04-26-2007, 06:47 PM
Well in JavaScript do this -

<script>
document.onload=function() {
document.getElementById('id').click()
}
</script>

Just replace id with the objects id, though I do not know if this would work for what your looking for, but it does with things like check boxes...

That is IE only (if it would even work for this) but, 'click to activate' happens in other browsers. Adobe has a script to fix this whole mess in browsers or you can simply take your tag(s) and surround them in a <noscript></noscript> tag so that non-javascript enabled users will still see the content, albeit with that 'click to activate' nonsense. Then make a script with your tag(s) in it:

document.write('<object etc....');

Save that as an external script (text only file) - say media.js, and place the tag for it after the closing </noscript> tag:


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

Proper escaping of line breaks should be followed in the script, ex:


document.write('<object>\n\
<param name="whatever" value="whatever">\n\
</object>');

If you have any single quotes (') in your tag(s) - you shouldn't, generally - they must also be escaped, like so:


\'

Other script methods also work but the outerHTML=outerHTML one is IE only and that and the innerHTML=innerHTML ones can fail if there is any non-standard markup that might get trashed in the translation.

dgnara
04-30-2007, 12:36 PM
I found this http://www.kirupa.com/developer/flash8/flash_fix.htm to fix the problem apparently it had to do with the embed method. I will try it and let you all know if it works.

Thanks everyone for your willingness to help :D

dgnara
04-30-2007, 12:48 PM
http://www.nickschale.us/joni/index.html

hey from the design point of view.. is pretty good..
I would recommend that you move the about image to touch the bottom border and the left one.. same with the homepage.. just a thought.

:)

jscheuer1
04-30-2007, 12:52 PM
I believe that will work.

The problem though, is any multimedia object. Whether it uses the embed, applet, object or a combination of these tags makes no difference.

Generally, if you write the tag(s) to the page via any external javascript, you are OK. When doing so, it is best to also provide fall back, non-javascript enabled code. Some methods for doing this work better (in more cases) than others. I've recently made up a wizard that will do this for you in virtually all cases. All you need are your otherwise working tags, the ones that cause the 'click to activate' thing:

http://home.comcast.net/~jscheuer1/side/click_to_activate_w.htm

killerchutney
04-30-2007, 05:07 PM
I think Dreamweaver CS3 has a function that disables that inbuilt, when I open a page with a flash thing on in CS3 it asks me to convert the code to JS for some reason.

dgnara
05-02-2007, 03:07 AM
I believe that will work.

The problem though, is any multimedia object. Whether it uses the embed, applet, object or a combination of these tags makes no difference.

Generally, if you write the tag(s) to the page via any external javascript, you are OK. When doing so, it is best to also provide fall back, non-javascript enabled code. Some methods for doing this work better (in more cases) than others. I've recently made up a wizard that will do this for you in virtually all cases. All you need are your otherwise working tags, the ones that cause the 'click to activate' thing:

http://home.comcast.net/~jscheuer1/side/click_to_activate_w.htm
so just use your wizard? and not the kirupa stuff?

jscheuer1
05-02-2007, 04:33 AM
so just use your wizard? and not the kirupa stuff?

That choice is up to you. Either should work. I can help out if you have problems with the wizard, perhaps even with other code you might use. But, I am of course more familiar with how my code own works.

Eventually, if you do this sort of thing much at all, you may want to gain an understanding of the principals involved so as to inform your choice of method as it most applies to a given situation.

Or, you may just want to take the approach of using whatever works and is easiest for you to implement.

Either way, it is still up to you.