Solved

edit swf files programmatically

Posted on 2007-03-21
14
574 Views
Last Modified: 2008-02-01
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
0
Comment
Question by:colinspurs
  • 8
  • 4
  • 2
14 Comments
 
LVL 4

Expert Comment

by:cow_monkey111
ID: 18765515
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
0
 
LVL 3

Author Comment

by:colinspurs
ID: 18765791
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
0
 
LVL 4

Expert Comment

by:cow_monkey111
ID: 18766133
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
0
 
LVL 4

Expert Comment

by:cow_monkey111
ID: 18766139
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
0
 
LVL 4

Expert Comment

by:cow_monkey111
ID: 18766475
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
0
 
LVL 3

Author Comment

by:colinspurs
ID: 18766658
Cmonkey

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

Cheers,
Colin
0
 
LVL 3

Author Comment

by:colinspurs
ID: 18769991
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>
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 3

Author Comment

by:colinspurs
ID: 18770563
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>
0
 
LVL 5

Accepted Solution

by:
victmo earned 500 total points
ID: 18772738
Hello colinspurs,

First of all, I recommend you not to use the Active Content Update from Adobe, its patchy and it doesnt comply with html standards. There are other options you can use like SWFObject.

There are many reasons why SWFObject is better than Adobe's ActiveContentUpdate. You can download SWFObject and get a list of improvements over ActiveContentUpdate in this page:

http://blog.deconcept.com/swfobject/

Once you start using it you'll see how easy you can pass variables to your flash movies.

I decompiled the arrow created by Dreamweaver so it can retrieve variables from its wrapper, in this case an HTML page.

http://asia-solutions.net/arrow/arrow.swf

And here's an example of how to pass variables to the arrow:

http://asia-solutions.net/arrow/arrow.html

Plus, the source of the arrow:

http://asia-solutions.net/arrow/arrow.fla


Good luck and let me know if it worked for you,

Vic
0
 
LVL 3

Author Comment

by:colinspurs
ID: 18773366
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
0
 
LVL 5

Expert Comment

by:victmo
ID: 18778004
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
0
 
LVL 3

Author Comment

by:colinspurs
ID: 18778451
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
0
 
LVL 3

Author Comment

by:colinspurs
ID: 18806989
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>";
0
 
LVL 3

Author Comment

by:colinspurs
ID: 18822233
I managed to get round it by sending the variables as separate parameters to the Flash file, and constructing the whole URL there.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now