Link to home
Start Free TrialLog in
Avatar of Colin Brazier
Colin BrazierFlag for United Kingdom of Great Britain and Northern Ireland

asked on

edit swf files programmatically

Hi experts,

I'll try to explain this as clearly as I can...

I'm developing using php.

I have a series of weekly reports kept as html pages.  These are linked to via a central page by a compiled Flash file (swf).  I have a separate instance of this swf for each report (there are hundreds in total).  When I have a new report, I upload the html page containing it, giving the page a unique name for the report, eg. report_1_Orpington_A_040412.htm.

I then go into Dreamweaver 8, open a page with an old swf file present, right-click it, edit, change the link destination in the Insert Flash Button dialog box so that it goes to the new report html page, then 'Save as' a new .swf file with a name indicative of the new report. In this case I'd save it as report1040412.swf.

I then ftp this swf file up to my site, as well as the new report page, and the calling page that the swf appears on.

Now, I am redesigning my site using CSS and would like to simplify/automate (I know the two don't always go together!) this procedure.  I'd like authorised users of the site to be able to add reports and their links without resorting to Dreamweaver.

Ideally, I'd like just 1 swf file so that when a user clicks on it to go to a particular report, the program passes it available information (eg date selected) and links to the report with that date in its filename. So how to pass parameters to a swf file ie. automating the Dreamweaver Insert Flash Button dialog box ?

If it is not possible, could I automate the editing of a swf and save as a new file?

You can see the site I'm referring to here http://www.fobgfc.org/FOBG_CSS2.php?team=1 with the swf files being the green arrows.  I know it might be better to use CSS rollovers instead, and control the link destination programmatically in those, but I like the arrow animations and would like to keep them.

I'd better stop there, if you have any questions please ask!

Thanks, Colin
Avatar of cow_monkey111
cow_monkey111

Hi,

I'm sorry to say, but using Dreamweaver, this is not possible. You would have to go into complete detail with creating the button using external veriables and a mixture of PHP. Dreamweaver likes to simplify so you cannot go in and edit the main fla of the button. It would be very complicated and would require lots of time. If you feel as though you want to do this, you can send me the php file in email (cowmonkey111@gmail.com) and I can edit it myself but it would take lots of time.

Hope this helped alittle,
Cmonkey
Avatar of Colin Brazier

ASKER

Thanks.  I wondered if there was a way of doing this just using php, replicating what Dreamweaver does in the edit box.  I don't have the fla files - how does Dreamweaver edit them?  No need to answer that if it's very complex!  Maybe a plain CSS rollover is the way to go...

I'll wait a while to see if there are any more ideas...

Colin
I could make a quick button that would do the same thing. It wont be as fancy as the ones dreamweaver makes but it will still look good and I can guide you though some of the steps so you can do it. Post me if you want to

Cmonkey
I could make a quick button that would do the same thing. It wont be as fancy as the ones dreamweaver makes but it will still look good and I can guide you though some of the steps so you can do it. Post me if you want to

Cmonkey
Here,

when you do your php page. Add this little bit for the swf into the edit box.

<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="30" height="38" id="greenbutton" align="middle">
<param name="allowScriptAccess" value="sameDomain" />
<param name="FlashVars" value="buturl=<? echo reportUrl; ?>" />
<param name="movie" value="Untitled-3.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /><embed src="greenbutton.swf" quality="high" FlashVars="buturl=<? echo reportUrl; ?>" bgcolor="#ffffff" width="30" height="38" name="Untitled-3" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>

As you see, the buturl will be used with the greenbutton.swf to do the url. Now because you are using PHP, I put some PHP echos on there for the reportUrl variable. You can change that. When you start to list your reports with PHP, the buturl variable will be the reportUrl when you set it. I can only take you that far with the PHP. You can probably do all the other PHP stuff by yourself.

Here is the greenbutton.swf file: http://www.tulsafrohlichs.com/greenbutton.swf

Hope this helps,
Cmonkey
Cmonkey

I appreciate your help.  I won't be able to look for a while but I will get back to you.

Cheers,
Colin
CMonkey
looking promising; however when I tried it, inserting the buturl below, it still tried to find the link as it was when I last edited it in DW8, so I'm struggling to change it on the fly.

'report4test' and 'match_reports/FOBG_Firsts_Report.htm' are variables in the php.

<script type='text/javascript'>AC_FL_RunContent
('codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0','width','18','height','16','src','report4test','quality','high','bgcolor','#FFFF00','name','report4test','allowscriptaccess','sameDomain','pluginspage','http://www.macromedia.com/go/getflashplayer','movie','report4test' ) </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' width='18' height='16'>
<param name='BASE' value='.'>
<param name=movie value='report4test.swf'>
<param name=quality value=high>
<param name='BGCOLOR' value='#FFFF00'>
                              
*******  <param name='FlashVars' value='buturl=match_reports/FOBG_Firsts_Report.htm'>   *********
                              
<embed src='report4test.swf'> quality=high pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash' type='application/x-shockwave-flash' width='18' height='16' bgcolor='#FFFF00' base='.'>
</embed>
 </object>
      </noscript>
Okay, getting there.  I was trying to use the original swf with your code.

It works OK as long as I don't have the javascript wraparound (the "click to activate this control" fix). When I included that, as seen below, I get a 404 error.

Where am I going wrong?  (The code is from view source......it was parameterised for the url.)

<script type='text/javascript'>
AC_FL_RunContent
('codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0','width','18','height','16','src','greenbutton','quality','high','bgcolor','#FFFF00','name','greenbutton','allowscriptaccess','sameDomain','pluginspage','http://www.macromedia.com/go/getflashplayer','movie','greenbutton' ) </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' width='18' height='16'>
<param name='BASE' value='.'>
<param name='allowScriptAccess' value='sameDomain' />
<param name=movie value='greenbutton.swf'>
<param name=quality value=high>
<param name='BGCOLOR' value='#FFFF00'>
                              
<param name='FlashVars' value='buturl=match_reports/FOBG_Firsts_Report.htm'>
                              
<embed src='greenbutton.swf'> quality=high pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash' type='application/x-shockwave-flash' width='18' height='16' allowScriptAccess='sameDomain' FlashVars='buturl='match_reports/FOBG_Firsts_Report.htm' bgcolor='#FFFF00' base='.'>
</embed>
</object></noscript>
ASKER CERTIFIED SOLUTION
Avatar of victmo
victmo

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi Vic,
Fabulous!  I was having trouble validating the html.  It certainly works with hard coded parameters!  I just need to feed them in programmatically and test.  I do have a couple of wide ranging questions though...

- what do I need to do if the user doesn't have Flash installed?  I never really dealt with that problem using the old method either.
- thanks for the source...not being a great user of Flash I can't see where the animation is, I can see the button states but can't find the mouseover action/animation.
- By the way, what did you use to decompile the DW file?  

Thanks again, I'll be back on when I've written some more php!

Colin
Hi again, Colin

You can place optional code in case the user doesn't have flash player installed. As you can see the SWFObject replaces the content of the specified div. If the user doesn't have flash player installed the object wont render and the div will stay with the original code.

<div id="arrow01">

  <a href="http://www.google.com"><img src="arrow.gif"></a>

  <script type="text/javascript">
    var so = new SWFObject("arrow.swf", "movie_id01", "33", "33", "8", "#FFFFFF");
    so.addVariable("href", "http://www.google.com");
    so.addVariable("target", "_blank");
    so.write("arrow01");
  </script>
</div>

On this example^ we place an image inside the div "arrow1", which stays if the swfobject can't find flash on the user's machine.

I used Sothink SWF Decompiler to decompile the movie: http://www.sothink.com/product/flashdecompiler/index.htm

You can google "swf decompilers", there are many cheaper options, one of them, SWF Viewer is free.

Glad it worked!

Vic
Vic,
Okay, so I could put a message and a link to Flash download site within the div.

I've programmed it in and it works perfectly.

Thanks again, and to Cmonkey too - I never cease to be amazed by EE and its members.

Colin
Vic,
I can make this another question if necessary. I'm trying to add parameters to the URL, and it doesn't seem to like the ampersand, the destination URL doesn't know about the second parameter.  Have I got my quotes wrong, or something?

$report_url = "FOBG_CSS_Report.php?report_date=".$match_date."&amp;side=1";

echo  "<td height='16' valign='top'>
<div id='".$arrow_div_id."'>
<script type='text/javascript'>
  var so = new SWFObject('gifs/arrow.swf', '".$arrow_id."', '18', '16', '7','".$br_color."');
  so.addVariable('href', '".$report_url."');
  so.addVariable('target', '_blank');
  so.write('".$arrow_div_id."');
</script>
</div>
</td>";
I managed to get round it by sending the variables as separate parameters to the Flash file, and constructing the whole URL there.