Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-13-2007, 10:48 AM   PM User | #1
jpmad4it
New Coder

 
Join Date: Jan 2006
Posts: 85
Thanks: 2
Thanked 0 Times in 0 Posts
jpmad4it is an unknown quantity at this point
Adding advanced flash code & JavaScript to a PHP variable

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:

Code:
$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:

Code:
<!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:

Code:
<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
jpmad4it is offline   Reply With Quote
Old 07-13-2007, 06:17 PM   PM User | #2
StupidRalph
Senior Coder

 
Join Date: Mar 2003
Location: Atlanta
Posts: 1,037
Thanks: 14
Thanked 30 Times in 28 Posts
StupidRalph is on a distinguished road
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.

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.
__________________
Most of my questions/posts are fairly straightforward and simple. I post long verbose messages in an attempt to be thorough.
StupidRalph is offline   Reply With Quote
Old 07-13-2007, 06:37 PM   PM User | #3
jpmad4it
New Coder

 
Join Date: Jan 2006
Posts: 85
Thanks: 2
Thanked 0 Times in 0 Posts
jpmad4it is an unknown quantity at this point
Quote:
Originally Posted by StupidRalph View Post
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.

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.
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
jpmad4it is offline   Reply With Quote
Old 07-14-2007, 02:16 AM   PM User | #4
StupidRalph
Senior Coder

 
Join Date: Mar 2003
Location: Atlanta
Posts: 1,037
Thanks: 14
Thanked 30 Times in 28 Posts
StupidRalph is on a distinguished road
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. 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.)
__________________
Most of my questions/posts are fairly straightforward and simple. I post long verbose messages in an attempt to be thorough.

Last edited by StupidRalph; 07-14-2007 at 02:17 AM.. Reason: Update Link
StupidRalph is offline   Reply With Quote
Old 07-16-2007, 11:09 AM   PM User | #5
jpmad4it
New Coder

 
Join Date: Jan 2006
Posts: 85
Thanks: 2
Thanked 0 Times in 0 Posts
jpmad4it is an unknown quantity at this point
Quote:
Originally Posted by StupidRalph View Post
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. 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?
jpmad4it is offline   Reply With Quote
Old 07-17-2007, 04:53 AM   PM User | #6
StupidRalph
Senior Coder

 
Join Date: Mar 2003
Location: Atlanta
Posts: 1,037
Thanks: 14
Thanked 30 Times in 28 Posts
StupidRalph is on a distinguished road
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 to place all of that information in the variable.

PHP Code:
$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; 
__________________
Most of my questions/posts are fairly straightforward and simple. I post long verbose messages in an attempt to be thorough.
StupidRalph is offline   Reply With Quote
Old 07-17-2007, 12:50 PM   PM User | #7
jpmad4it
New Coder

 
Join Date: Jan 2006
Posts: 85
Thanks: 2
Thanked 0 Times in 0 Posts
jpmad4it is an unknown quantity at this point
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?
jpmad4it is offline   Reply With Quote
Old 07-17-2007, 07:02 PM   PM User | #8
StupidRalph
Senior Coder

 
Join Date: Mar 2003
Location: Atlanta
Posts: 1,037
Thanks: 14
Thanked 30 Times in 28 Posts
StupidRalph is on a distinguished road
Quote:
Originally Posted by jpmad4it View Post
Hey, yeah I looked at the SWFObject it looks like a better way if doing things!
I know, it really is.
Quote:
Originally Posted by jpmad4it View Post
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.
Quote:
Originally Posted by jpmad4it View Post
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.
__________________
Most of my questions/posts are fairly straightforward and simple. I post long verbose messages in an attempt to be thorough.
StupidRalph is offline   Reply With Quote
Old 07-17-2007, 08:19 PM   PM User | #9
jpmad4it
New Coder

 
Join Date: Jan 2006
Posts: 85
Thanks: 2
Thanked 0 Times in 0 Posts
jpmad4it is an unknown quantity at this point
Quote:
Originally Posted by StupidRalph View Post
I know, it really is.

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

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.
got it working !

Yay for SWFObject!!!
jpmad4it is offline   Reply With Quote
Old 07-17-2007, 08:25 PM   PM User | #10
StupidRalph
Senior Coder

 
Join Date: Mar 2003
Location: Atlanta
Posts: 1,037
Thanks: 14
Thanked 30 Times in 28 Posts
StupidRalph is on a distinguished road
__________________
Most of my questions/posts are fairly straightforward and simple. I post long verbose messages in an attempt to be thorough.
StupidRalph is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:30 AM.


Advertisement
Log in to turn off these ads.