Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 10 of 10
  1. #1
    New Coder
    Join Date
    Jan 2006
    Posts
    89
    Thanks
    3
    Thanked 0 Times in 0 Posts

    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

  • #2
    Senior Coder
    Join Date
    Mar 2003
    Location
    Atlanta
    Posts
    1,037
    Thanks
    14
    Thanked 30 Times in 28 Posts
    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.

  • #3
    New Coder
    Join Date
    Jan 2006
    Posts
    89
    Thanks
    3
    Thanked 0 Times in 0 Posts
    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

  • #4
    Senior Coder
    Join Date
    Mar 2003
    Location
    Atlanta
    Posts
    1,037
    Thanks
    14
    Thanked 30 Times in 28 Posts
    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.)
    Last edited by StupidRalph; 07-14-2007 at 03:17 AM. Reason: Update Link
    Most of my questions/posts are fairly straightforward and simple. I post long verbose messages in an attempt to be thorough.

  • #5
    New Coder
    Join Date
    Jan 2006
    Posts
    89
    Thanks
    3
    Thanked 0 Times in 0 Posts
    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?

  • #6
    Senior Coder
    Join Date
    Mar 2003
    Location
    Atlanta
    Posts
    1,037
    Thanks
    14
    Thanked 30 Times in 28 Posts
    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.

  • #7
    New Coder
    Join Date
    Jan 2006
    Posts
    89
    Thanks
    3
    Thanked 0 Times in 0 Posts
    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?

  • #8
    Senior Coder
    Join Date
    Mar 2003
    Location
    Atlanta
    Posts
    1,037
    Thanks
    14
    Thanked 30 Times in 28 Posts
    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.

  • #9
    New Coder
    Join Date
    Jan 2006
    Posts
    89
    Thanks
    3
    Thanked 0 Times in 0 Posts
    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!!!

  • #10
    Senior Coder
    Join Date
    Mar 2003
    Location
    Atlanta
    Posts
    1,037
    Thanks
    14
    Thanked 30 Times in 28 Posts
    Most of my questions/posts are fairly straightforward and simple. I post long verbose messages in an attempt to be thorough.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •