2

Overview:

I have a SWF banner ad template which loads in JSON from a platform that I have developed and then cycles through some products that were specified in that JSON. Each product is made up of your standard title, price and image.

On the platform, the user has the ability to modify the JSON feed via some UI tools such as image upload, title change etc.

Once they've done this, they can save and preview the ad. The preview is a SWF file embedded on the current page with some FlashVars that reference the location of the JSON they just created.

The request:

The user wants the ability to be able to archive all versions that they have created locally (as SWFs on their drive).

I offered a few solutions such as:

  • Download a bundle containing a HTML page with the SWF embedded with the appropriate FlashVars define in the HTML (this is easy).
  • Download a bundle that contains an XML document in the same directory as the SWF, which the SWF can load (this is a slightly altered version of the SWF) and obtain the JSON URL from.

Unfortunately, they are pushing to have a single SWF downloaded which they can save as an encapsulated file. The idea is that this eliminates an abundance of files down the track, as well as the ability to place components in the wrong directories, etc.

Question:

I need to use PHP (if possible) to do the following:

  1. Create a copy of the SWF template.
  2. Alter the value of the variable inside the copied SWF containing the URL to the appropriate archived JSON URL.
  3. Save that version and then begin downloading it.

Is this possible? If so, how?

Marty
  • 39,033
  • 19
  • 93
  • 162
  • Could the server execute `mxmlc` compiler, altering a config ActionScript class to build a SWF? – Jason Sturges Jul 03 '12 at 07:48
  • @JasonSturges I'm not sure what that is, so assuming that in a normal situation that was possible, then yes I'm interested in that approach :) Do you have any resources that I could look at? – Marty Jul 03 '12 at 07:50
  • Not sure if this will give you what you're looking for or not but it is possible to execute runtime as3. Check out this lib: http://code.google.com/p/as3scriptinglib/ – francis Jul 03 '12 at 12:54

1 Answers1

3

I've heard of companies using the mxmlc compiler to encapsulate a monolithic build creating custom SWFs server-side.

This has been leveraged to build SWFs on the fly which would otherwise require heavy loading of resources.

The approach:

  1. PHP script would alter an ActionScript file, setting variables and [Embed] resources.

  2. PHP script would call mxmlc command line compiler to build the SWF, essentially the same as Flash Builder would compile a pure ActionScript project.

Perhaps an ANT task could automate the build.

References:

Community
  • 1
  • 1
Jason Sturges
  • 15,855
  • 14
  • 59
  • 80
  • Thanks Jason, I'll have to play around with this as I have no experience even with Flex/Flashbuilder (always used Flash). From what I can see this is going to be nontrivial. – Marty Jul 03 '12 at 08:06
  • 1
    It might be as simple as: `mxmlc -o output.swf -source-path="src/"`. Maybe isolating your Flash Project to a SWC and updating a single AS file would be easy. `mxmlc -library-path+=flash.swc`. There might be an easier approach than this... – Jason Sturges Jul 03 '12 at 08:24