...

View Full Version : Adding advanced flash code & JavaScript to a PHP variable



jpmad4it
07-13-2007, 11:48 AM
Hey people!

I have a PHP variable named flash, and within it I have the <object> element which creates the flash output. So whenever i call the variable i get the flash. Now the problem is that I am getting the "click to activate and use this control" box which I want to get rid of. So to do this I want to add the AC_RunActiveContent.js script to this variable. Is this possible? If so how do I write the code? This is the code I have already:


$flash = "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0\" width=\"157\" height=\"198\">
<param name=\"movie\" value=\"http://www.mysite.com/scroller.swf\">
<param name=\"quality\" value=\"high\">
<embed src=\"http://www.mysite.com/scroller.swf\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\"157\" height=\"198\"></embed></object>";

Now here is the code I require to put in the $flash variable:


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script language="javascript" type="text/javascript">AC_FL_RunContent = 0;</script>
<script src="AC_RunActiveContent.js" language="javascript" type="text/javascript"></script>
</head>

<body>
<script language="javascript" type="text/javascript">
if (AC_FL_RunContent == 0) {
alert("This page requires AC_RunActiveContent.js. In Flash, run \"Apply Active Content Update\" in the Commands menu to copy AC_RunActiveContent.js to the HTML output folder.");
} else {
AC_FL_RunContent(
'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0',
'src', 'http://www.mysite.com/scroller',
'quality', 'high',
'pluginspage', 'https://www.macromedia.com/go/getflashplayer',
'play', 'true',
'loop', 'true',
'scale', 'showall',
'devicefont', 'false',
'bgcolor', '#ffffff',
'menu', 'true',
'allowScriptAccess','sameDomain',
'movie', 'http://www.mysite.com/scroller',
'class', '',
'salign', ''
); //end AC code
}
</script>
<noscript>
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" class="Flash" title="team">
<param name="movie" value="http://www.mysite.com/scroller.swf" />
<param name="quality" value="high" />
<param name="wmode" value="opaque" />
<param name="allowScriptAccess" value="sameDomain" />
<embed src="http://www.mysite.com/scroller.swf" class="Flash" quality="high" wmode="opaque" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" allowScriptAccess="sameDomain"></embed>
</object>
</noscript>
</body>
</html>

I'm not sure if I have to put all the <Html> tags etc in, but I do know that these 2 lines are required in the <head> tag:


<script language="javascript" type="text/javascript">AC_FL_RunContent = 0;</script>
<script src="AC_RunActiveContent.js" language="javascript" type="text/javascript"></script>

Any help would be grrrrreeeeeeaaaaat!!

Kind regards
Jonathan :thumbsup:

StupidRalph
07-13-2007, 07:17 PM
Maybe I'm missing your point...but why do you have to add the javascript to the variable? I guess if you really had to add the javascript to the variable and you didn't want to escape all of the quotation marks you can use the HEREDOC syntax (http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc).

You also, might want to take a look at SWFObject. It avoids the "Click here to activate" as well. I just like pushing it on people opposed to alternatives. :D

jpmad4it
07-13-2007, 07:37 PM
Maybe I'm missing your point...but why do you have to add the javascript to the variable? I guess if you really had to add the javascript to the variable and you didn't want to escape all of the quotation marks you can use the HEREDOC syntax (http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc).

You also, might want to take a look at SWFObject. It avoids the "Click here to activate" as well. I just like pushing it on people opposed to alternatives. :D

Ah right so SWFObject eliminates the user input. I'll look into that.

I think the javascript is needed because I assume it passes the paramaters to the AC_RunActiveContent.js file? I'm a newbie/intermediate so i'm not totally sure :confused:

StupidRalph
07-14-2007, 03:16 AM
Well,even if it did pass parameters to the .js script file you have, it would be the exact same thing.

As you may or may not be aware of, PHP is a server-side language and javascript is client-side. So what this basically means that all of the PHP stuff will be processed on the server and then delivered to the client. Unless, you have some variables being passed from PHP into the javascript, there is no reason to have it in your PHP. In fact, its slower b/c your server has to spend the extra time processing the extra text. Whether PHP writes out this code dynamically or you hard code it into your script, the browser won't be able to tell the difference.

Now that I've said that, here is the link for SWFObject (http://blog.deconcept.com/swfobject/). He has really good documentation and its really easy to use. (You can just add the javascript to your pages, you do not have to put them in your PHP code.)

jpmad4it
07-16-2007, 12:09 PM
Well,even if it did pass parameters to the .js script file you have, it would be the exact same thing.

As you may or may not be aware of, PHP is a server-side language and javascript is client-side. So what this basically means that all of the PHP stuff will be processed on the server and then delivered to the client. Unless, you have some variables being passed from PHP into the javascript, there is no reason to have it in your PHP. In fact, its slower b/c your server has to spend the extra time processing the extra text. Whether PHP writes out this code dynamically or you hard code it into your script, the browser won't be able to tell the difference.

Now that I've said that, here is the link for SWFObject (http://blog.deconcept.com/swfobject/). He has really good documentation and its really easy to use. (You can just add the javascript to your pages, you do not have to put them in your PHP code.)

So would the SWFObject work with the PHP script i'm trying to use?

StupidRalph
07-17-2007, 05:53 AM
Did you check the links I gave you? Try reading the 2nd paragraph of my previous post again. It makes no difference whether its the javascript is dynamically written or if its static. The browser will not know the difference.

With your example, as I've stated in my first post, you can use the HEREDOC syntax (http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc) to place all of that information in the variable.


$flash = <<<HEREDOC
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script language="javascript" type="text/javascript">AC_FL_RunContent = 0;</script>
<script src="AC_RunActiveContent.js" language="javascript" type="text/javascript"></script>
</head>

<body>
<script language="javascript" type="text/javascript">
if (AC_FL_RunContent == 0) {
alert("This page requires AC_RunActiveContent.js. In Flash, run \"Apply Active Content Update\" in the Commands menu to copy AC_RunActiveContent.js to the HTML output folder.");
} else {
AC_FL_RunContent(
'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0',
'src', 'http://www.mysite.com/scroller',
'quality', 'high',
'pluginspage', 'https://www.macromedia.com/go/getflashplayer',
'play', 'true',
'loop', 'true',
'scale', 'showall',
'devicefont', 'false',
'bgcolor', '#ffffff',
'menu', 'true',
'allowScriptAccess','sameDomain',
'movie', 'http://www.mysite.com/scroller',
'class', '',
'salign', ''
); //end AC code
}
</script>
<noscript>
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" class="Flash" title="team">
<param name="movie" value="http://www.mysite.com/scroller.swf" />
<param name="quality" value="high" />
<param name="wmode" value="opaque" />
<param name="allowScriptAccess" value="sameDomain" />
<embed src="http://www.mysite.com/scroller.swf" class="Flash" quality="high" wmode="opaque" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" allowScriptAccess="sameDomain"></embed>
</object>
</noscript>
</body>
</html>
HEREDOC;

jpmad4it
07-17-2007, 01:50 PM
Hey, yeah I looked at the SWFObject it looks like a better way if doing things!

I've just realised that I dont need to use the PHP at all. Sorry for the confusion I got mixed up along the way somewhere!

What I have is a swf file that calls text in from an XML file just to display a simple news scroller. The problem is that using the AC_RunActiveContent doesn't take notice of the XML file at the moment. I read up on the SWFObject documentation but I have yet to try it. Thats what I am about to do now! Should it work even though the SWF relies on an external XML file?

StupidRalph
07-17-2007, 08:02 PM
Hey, yeah I looked at the SWFObject it looks like a better way if doing things!
I know, it really is. :D


I've just realised that I dont need to use the PHP at all. Sorry for the confusion I got mixed up along the way somewhere!
Thats kinda what I've been trying to tell you the last two post.:p


What I have is a swf file that calls text in from an XML file just to display a simple news scroller. The problem is that using the AC_RunActiveContent doesn't take notice of the XML file at the moment. I read up on the SWFObject documentation but I have yet to try it. Thats what I am about to do now! Should it work even though the SWF relies on an external XML file?
Yes. SWFObject is used to add the .swf to your web page. I'm not sure how your actionscript is set up to call the XML file so I don't know if you have to pass in the path to the XML file within your actionscript, but if you must, you can do that also with SWFObject. If you still need help post your actionscript in that forum and reply here with a link to the thread.:thumbsup:

jpmad4it
07-17-2007, 09:19 PM
I know, it really is. :D

Thats kinda what I've been trying to tell you the last two post.:p

Yes. SWFObject is used to add the .swf to your web page. I'm not sure how your actionscript is set up to call the XML file so I don't know if you have to pass in the path to the XML file within your actionscript, but if you must, you can do that also with SWFObject. If you still need help post your actionscript in that forum and reply here with a link to the thread.:thumbsup:

:thumbsup: got it working !

Yay for SWFObject!!! :D

StupidRalph
07-17-2007, 09:25 PM
:thumbsup:



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum