#1
  1. /*
    Devshed Novice (500 - 999 posts)

    Join Date
    Mar 2007
    Location
    Sydney, Australia
    Posts
    729
    Rep Power
    620

    Running flash on a web server


    Hi folks,

    I work on a lot of digital media projects; which often require dynamic graphics. I find flash to be a great tool for this purpose. It's very easily to dynamically change text inside a swf, compensate for text overflow and apply lots of nice filters and effects. Not to mention font embedding.

    This technique works great for web pages, however quite often we want to use flash generated artwork in a html email. How can we do this? Well, we can use as3corelib to generate a jpg from a swf, and then use the generated image in an email.

    This is fine, so long as we can pre-generate all of the images, before sending out the emails. But say we need to generate the dynamic jpeg on the fly from a webpage? If the user on the webpage has flash installed we could configure a swf to generate the image for us.

    But what if the user has flash disabled? Maybe they are using an ios device or simply don't like flash.

    What I would like to do is set up a server side fallback that could run a swf, replace text in the swf based on supplied variables, generate a jpg using as3corelib and save the jpeg somewhere. The trick here is running flash player on the server. It would also need to run in a multithreaded way in case the server needed to process multiple requests.

    Anyone have any ideas? I appreciate any comments.
    */
  2. #2
  3. No Profile Picture
    Gotta get to the next screen..
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2003
    Location
    Legion of Dynamic Discord
    Posts
    6,675
    Rep Power
    3164
    Howdy, you can try using Flash and PHPs GD image library. Just google all of those for some relevant tutorials. The gist of the idea is that you use Flash to make a screenshot of itself which it then sends to PHP that then uses the GD library to save a still image file i.e. jpg.

    The downside is that someone has to run the SWF for the image to be saved. Also, you don't want it to save a new image each time anyone views the SWF. What might work nicely is if you made your normal Flash version as you have now. Then make a new SWF that has the screenshot code and PHP talking code in it. That would do three things. (1) Load in your current SWF content file (2) Take a screenshot of it (3) Send that data PHP so it can be saved.

    So then when you want people to see the Flash version you just point their browsers towards the normal content clip but when you want to update the static image version then you yourself can manually run the screenshot taking SWF.

    You could look into using a Cron job on Linux or a Task (Task Scheduler) on Windows. That would let you automate running the screenshot taking SWF.

    I've never done this process before, I just made it up but it sounds like it could work. At least it gives you something to tinker with. You might want to have a look at the PHP Ming library. It sounds kinda basic on its own but you could integrate it with other SWFs that you made in the IDE with more advanced features and functionality that you could not implement with Ming.
    Quis custodiet ipsos custodes?
  4. #3
  5. /*
    Devshed Novice (500 - 999 posts)

    Join Date
    Mar 2007
    Location
    Sydney, Australia
    Posts
    729
    Rep Power
    620
    Hi Tan,

    Thanks for your thoughts and comments. I like the idea of using a cron job or scheduled task. I've had a look into AIR 2 and have found that it can act as a socket server.

    I'm thinking of a process similar to this:

    If a website user does not have flash I can not load a swf in their session to generate the screenshot.

    In this case I could capture the relevant data in a web form and store it in a db.

    A cron job on the server could poll the database regularly.

    If new data is found the cron job could send the information to a running air app via a socket connection.

    The AIR app could then generate the jpg and save it in an appropriate location.

    It would be interesting to test this. Too be honest I'm leaning towards either using a static generic image for use cases where the user hasn't got flash installed or presenting them with a message to say that flash needs to be installed in order to use the service.
    */
  6. #4
  7. No Profile Picture
    Gotta get to the next screen..
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2003
    Location
    Legion of Dynamic Discord
    Posts
    6,675
    Rep Power
    3164
    Going with a single default static image would make the whole thing a lot simpler. I use swfobject2 for embedding my SWFs into the HTML pages. That lets you serve up alternative content if they do not have Flash installed. I normally use a static still image, a pure HTML alternative or sometimes just a "Get Flash" link. Depends on what the content it/how lazy I am/how long I have to spend on it.

    Haven't touched Air 2 yet, last time I used it was v1 or v1.1 something like that. I'd be very interested to hear about your progress if you do decide to implement an Air socket server. If it's simple then I would totally make one for some pet projects I have written down. Couldn't be arsed with Red5 or the developer edition of Flash Media Server.
    Quis custodiet ipsos custodes?
  8. #5
  9. /*
    Devshed Novice (500 - 999 posts)

    Join Date
    Mar 2007
    Location
    Sydney, Australia
    Posts
    729
    Rep Power
    620
    I will post back if / when I experiment with an AIR socket server.
    */
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    1
    Rep Power
    0

    any luck


    Hi Benno,

    Did you get this working?

    Thanks
  12. #7
  13. /*
    Devshed Novice (500 - 999 posts)

    Join Date
    Mar 2007
    Location
    Sydney, Australia
    Posts
    729
    Rep Power
    620
    Originally Posted by doogma
    Hi Benno,

    Did you get this working?

    Thanks
    Hi Doogma,

    Sad to say that I did not persue this project any further. I'd still like to try this but have been moving away from flash ever since Adobe stopped supporting it for mobile devices and abandoned Flex.

    regards
    Ben
    */

IMN logo majestic logo threadwatch logo seochat tools logo