Jump to content

convert code embedding swf file into a js file


Recommended Posts

Hi all.

The code embedding the swf file using AC_RunActiveContent.js looks as below:

<script type="text/javascript" >
AC_FL_RunContent('codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0','width','800','height','580','align','middle','src','FlashWebsite','quality','high','bgcolor','#ffffff','name','FlashWebsite','allowscriptaccess','sameDomain','pluginspage','http://www.macromedia.com/go/getflashplayer','movie','FlashWebsite' );

1. I would like to run this off a .js file so that this could be CSP compatible & would replace the above code.

2. I also need to pass two php variables as FlashVars in the above code. For eg like this 

FlashVars = "var1=$var1&var2=$var2"

So I would need to pass these two variables from php into the .js file that i wish to create in 1.


i would be much obliged for any help on this.

Thanks all !!

Edited by ajoo
Link to comment
Share on other sites

Store them in array of key/value pairs

$params = Array
    [codebase] => http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0
    [width] => 800
    [height] => 580
    [align] => middle
    [src] => FlashWebsite
    [quality] => high
    [bgcolor] => #ffffff
    [name] => FlashWebsite
    [allowscriptaccess] => sameDomain
    [pluginspage] => http://www.macromedia.com/go/getflashplayer
    [movie] => FlashWebsite

Then it's easy to add

$params['var1'] = $var1;
$params['var2'] = $var2;

Then you can json_encode() the $params array to pass it to JS.

Link to comment
Share on other sites

Hi Guru Barand, 


Thanks for the reply !


I just tried as follows : 


In the HTML HEAD block I added 

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script language="javascript">AC_FL_RunContent = 1;</script>
<script src="AC_RunActiveContent.js" language="javascript"></script>
<script type="text/javascript" src="fl.js"></script>



created the fl.js simply as 

	if (AC_FL_RunContent == 0) 
		alert("This page requires AC_RunActiveContent.js.");
	} else {
			'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0',
			'width', '550',
			'height', '400',
			'src', 'AS3_swf_php_comm_1',
			'quality', 'high',
			'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
			'align', 'middle',
			'play', 'true',
			'loop', 'true',
			'scale', 'showall',
			'wmode', 'window',
			'devicefont', 'false',
			'id', 'AS3_swf_php_comm_1',
			'bgcolor', '#ffffff',
			'name', 'AS3_swf_php_comm_1',
			'menu', 'true',
			'allowFullScreen', 'false',
			'movie', 'AS3_swf_php_comm_1',
			'salign', ''

leaving aside the flashvars for the moment.


If i paste the contents of fl.js using <SCRIPT>tags directly in HTML, all works fine. But with the fl.js as above, I get a perpetually loading fevicon symbol and the disabled flash player symbol saying "Click to enable Adobe Flash Player".


There is no other error or anything else in the chrome inspector. If I comment out the params section in the fl.js and simply put an alert, the messages appears and there is no perpetual fevicon. Of-course no running swf either. 


Please help. 



Link to comment
Share on other sites

Hi Guru Barand & all !


Please can someone help me out with this. 


@Guru Barand:

Then you can json_encode() the $params array to pass it to JS.


SIr it's not working even when I put the params directly in the JQuery as in #3. Kindly guide. 


Thanks all !

Edited by ajoo
Link to comment
Share on other sites

This thread is more than a year old.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.