5

I've written a framework (it's been a year) which will render AS3 code as HTML5

I want to reach into a swf and parse the guts into my framework so that you can upload an AS3 swf and get the HTML5 equivalent back.

Any ideas on how to parse a swf/fla using php?

** edit **

As a reference, google does something similiar to this. However, swiffy only parses AS2 code.

** edit 2 **

For further clarification, I only want to be able to parse a swf for layout props and actionscript. I've got the rest figured out.

Brock Adams
  • 90,639
  • 22
  • 233
  • 295
Jacksonkr
  • 31,583
  • 39
  • 180
  • 284
  • 1
    Converting Flash into HTML is a task of *insanely* huge dimensions. – Pekka Jul 01 '11 at 22:49
  • 2
    Google has Swiffy, Adobe has Wallaby, and neither of them can convert AS3 (only legacy AS2). to accomplish this task you would have to be a master of AS3 code and the AVM2 runtime and be up-to-date with the latest HTML5 abilities. i think you're trying to bite off more than you can chew. – Chunky Chunk Jul 01 '11 at 22:52
  • I respect the reasons to doubt. However, here is a prototype of Google streetview using strictly HTML5 and written with AS3 formed lingo: http://flanvas.com/development/streetview/index.html – Jacksonkr Jul 01 '11 at 23:04

2 Answers2

6

Take a look at SWFTools - that can dump the code out of SWFs apparently, and has source code, though you could use the command line utilities from PHP and parse the output to get the actionscript sections out. God knows what you will do with it then.

Orbling
  • 20,413
  • 3
  • 53
  • 64
  • +1 For being the first person who chose to help rather than critique me for my idea. Thank you. – Jacksonkr Jul 01 '11 at 23:10
  • @Jackson: Thanks, though I think the others were trying to help by saying do not attempt to replicate Flash automatically, if that is what you are attempting - the complexity would be vast. Sort of thing a large professional team would need to spend a year on or so. – Orbling Jul 02 '11 at 08:58
  • I see your reasoning and don't doubt I would say the same thing. It's a very big process, which I've been undertaking for some time now. However, I can render ~actionscript in an HTML5 canvas with minimal effort (thanks to a framework I have developed). There's still a long way to go, but I'm focusing on core functionality now, which I have. Take a look at flanvas.com if you're curious. – Jacksonkr Jul 02 '11 at 17:29
  • Also, I was toying with SWFTools last night. I compiled a copy and was trying swfdump, but couldn't get any AS out, just stage properties (width, height, fps, etc). I tried from as2 fp5 to as3 fp10. I've contacted Matthias (the developer of swfdump) and hopefully he'll have more answers for me. – Jacksonkr Jul 02 '11 at 17:31
  • @Jackson: I can imagine a good case for allowing AS like actions via an interpreter, would be hard to provide *all* the features of Flash directly though, the timeline handling and shape tweening would be the most desirable features I imagine. Have you tried the `swfdump -a` option? – Orbling Jul 02 '11 at 19:14
  • yep. I tried swf dump with every option listed (separately and collectively). I will have to do more testing with it. And yes, providing all the features is going to be a feat in it's self. However, I've started with the core functionality and am branching outward. My main purpose is to help push scripters/coders out of flash and back in to javascript/html. – Jacksonkr Jul 02 '11 at 19:38
  • @Jackson: A very valiant purpose, my team have all but stopped using Flash, we do almost everything in JS/jQuery (with server-side support), just written something akin to Photoshop in it (without using the canvas even). Good luck with it, I'll try and keep up with flanvas. – Orbling Jul 02 '11 at 19:53
  • @Orbling let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/1089/discussion-between-jackson-and-orbling) – Jacksonkr Jul 02 '11 at 21:48
0

https://github.com/iborodikhin/php-swiffy/

use this lib and implement like this

require_once('php-swiffy-master/vendor/autoload.php');

$swiffy = new Swiffy\Client();
$html = $swiffy->convert("test.swf");
$myfile = fopen("test.html", "w");
if(!empty($html)){

    fwrite($myfile, $html);
    fclose($myfile);
}
nthall
  • 2,847
  • 1
  • 28
  • 36
Rick
  • 11
  • 2