Log in
Please log in or register.
Pages: [1]
  Print  
Author Topic: HOW-TO: Automatically Focus the flash object when the page loads  (Read 1185 times)
nitram_cero (2bam)
Sr. Member
****
Posts: 472



View Profile WWW
« on: Sun, Dec 13, 2009 »

If you're using swfobject like myself, do like this:

Quote
...
<head>

   <script src="js/swfobject.js" type="text/javascript"></script>
   <script type="text/javascript">
      var flashvars = {
      };
      var params = {
         menu: "false",
         scale: "noScale",
         allowFullscreen: "true",
         allowScriptAccess: "always",
         bgcolor: "#000000"
      };
      var attributes = {
         id:"flashObject"
      };
      swfobject.embedSWF("flashgame.swf", "flashAltContent", "800", "600", "10.0.0", "expressInstall.swf", flashvars, params, attributes);
   </script>

</head>
<body bgcolor="#000000" onLoad="document.getElementById('flashObject').focus();">

...

If you're using the straight dope, do like this:
Quote
<body bgcolor="#000000" onLoad="document.getElementById('flashObject').focus();">
...
<object id="flashObject" width="800" height="600" type="application/x-shockwave-flash" data="flashgame.swf">

And you can start playing right away, without having to click on the game to start.

Regards!
« Last Edit: Tue, Dec 15, 2009 by nitram_cero » Logged

2BAM
I Hate Islands, SpaceCoffee, Finding Her, Caverns, Explosive Cats, The Duke, Run, A View on Relationships, RabbitClock's Quest
BullitSpeed
Full Member
***
Posts: 210


View Profile WWW
« Reply #1 on: Sun, Dec 13, 2009 »

Awesome.  Beer for you!
Logged
Adam Atomic
Administrator
Hero Member
*****
Posts: 724


hostest w/ the mostest


View Profile WWW
« Reply #2 on: Sun, Dec 13, 2009 »

oh nice one Cheesy
Logged

nitram_cero (2bam)
Sr. Member
****
Posts: 472



View Profile WWW
« Reply #3 on: Tue, Dec 15, 2009 »

Thanks... I'll put it on the wiki.
Logged

2BAM
I Hate Islands, SpaceCoffee, Finding Her, Caverns, Explosive Cats, The Duke, Run, A View on Relationships, RabbitClock's Quest
CosMind
Newbie
*
Posts: 4

stuff 'n stuff


View Profile WWW
« Reply #4 on: Sun, Dec 20, 2009 »

tapping in to this will make me happy - but, pardon my ignorance, where exactly do we place this code?
Logged
nitram_cero (2bam)
Sr. Member
****
Posts: 472



View Profile WWW
« Reply #5 on: Sun, Dec 20, 2009 »

Somewhere in your page's HTML

inside the head / body tags (as shown in the example)

Regards
Logged

2BAM
I Hate Islands, SpaceCoffee, Finding Her, Caverns, Explosive Cats, The Duke, Run, A View on Relationships, RabbitClock's Quest
Pages: [1]
  Print  
 
Jump to: