Flash CS3 - Flash CS4

Free tutorials and scripts for all.
Actionscript 3.0

SWF to PNG with Actionscript 3.0 - ByteArray class

This is a discussion on SWF to PNG with Actionscript 3.0 - ByteArray class within the Tutorials forums, part of the English Forums category; Greetings to all! Today, I am proud of this very interesting article. Not that the other ones are not interesting ...


Go Back   Forum Flash CS3 Flash CS4 > English Forums > Tutorials

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  60 links from elsewhere to this Post. Click to view. #1 (permalink)  
Old 28-09-07, 06:58
Administrator
 
Join Date: Jul 2007
Location: Cesena
Posts: 4,446
Rep Power: 6
Flep is on a distinguished road
SWF to PNG with Actionscript 3.0 - ByteArray class

Greetings to all!

Today, I am proud of this very interesting article.
Not that the other ones are not interesting but this one beats them all from my point of view.

Have you ever thought on how to extract an image of format .png from a SWF?

With Actionscript 2.0, I personally had done it for an application using the BitmapData class and the library GD of PHP. It was certainly not very performing but it was the only way to do it at the time.

With Actionscript 3.0, we have the ByteArray class available that allows us to script a BitmapData into a ByteArray.
As my knowledge of binary programming are not sufficient to realise all of it on my own, I found on the web a script from Adobe, which scripts a BitmapData and returns a ByteArray.
I then realised that the ByteArray was not ready to be passed to a server side script and so I asked help to a friend of mine, an engineer named Daniele Lazzara of OrigamiStudio.it with a real virtue in informatics and a big passion for Flash. He used a codification created by Steve Webster & dynamicflash.com to convert the ByteArray to a String and implemented a PHP script to complete the job.
Finally, I implemented a call to the PHP script from Flash and?it works wonderfully!

Read more

The result:






The main steps of Main.as, the Document Class of this project are as follow:

Properties
a BitmapData
private var bitmap_data:BitmapData;
a ByteArray
private var byte_array:ByteArray;
I instance the Adobe PNGEncoder class
var encoding:PNGEncoder;
I create a new BitmapData
bitmap_data=new BitmapData(stage.stageWidth,stage.stageHeight,fals e,0xDEDEDE);
Using the method ?draw? of the BitmapData, I take a ?screenshot? of the MovieClip that realise the drawing
bitmap_data.draw(clip);
I assign to my ByteArray a value returned by the method ?encode? of the Adobe PNGEncoder class, passing to it the BitmapData
byte_array=PNGEncoder.encode(bitmap_data);
I create a String variable and assign to it the value returned by the static method ?encodeByteArray? of the Base64 class by Steve Webster, passing to it the ByteArray
var encoded:String=Base64.encodeByteArray(byte_array);
By now, you should understand easily the rest as I send the data to the PHP script
var variables:URLVariables=new URLVariables();
variables.png=encoded;
var richiesta:URLRequest=new URLRequest();
richiesta.url='http://www.flepstudio.org/swf/mix/SWF_to_PNG/prova2.php';
richiesta.method=URLRequestMethod.POST;
richiesta.data=variables;
var loader:URLLoader=new URLLoader();
loader.dataFormat=URLLoaderDataFormat.BINARY;

Source files:
Attached Files
File Type: zip SWF_to_PNG_eng.zip (662.1 KB, 299 views)

__________________

 


I recommend: Essential Actionscript 3.0

- Non rispondo ai messaggi privati con domande tecniche. Apri una discussione sul forum !
- I do not reply technicians pvt messages. Open a thread !

Last edited by Flep; 05-06-08 at 17:37..
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

  #2 (permalink)  
Old 14-10-07, 04:29
Junior Member
 
Join Date: Oct 2007
Posts: 15
Rep Power: 0
darylmata is on a distinguished road
Re: SWF to PNG with Actionscript 3.0 - ByteArray class

I upload the files just like they came on the folder and i doesn't work, I'd already try with others tutorials and it's the same result, I just want to know what am I missing?


It's really important for me to get this done, I have Flash CS3, I changed the links that came on the main.as, don't know what else to do.

daryl.mat@hotmail.com

Last edited by darylmata; 14-10-07 at 04:29.. Reason: http://www.paginasprodigy.com/darylmata/SWF_to_PNG_eng/main_eng.swf
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

  #3 (permalink)  
Old 14-10-07, 06:41
Administrator
 
Join Date: Jul 2007
Location: Cesena
Posts: 4,446
Rep Power: 6
Flep is on a distinguished road
Re: SWF to PNG with Actionscript 3.0 - ByteArray class

Hi,
did you chmod to 777 the php script ?
__________________

 


I recommend: Essential Actionscript 3.0

- Non rispondo ai messaggi privati con domande tecniche. Apri una discussione sul forum !
- I do not reply technicians pvt messages. Open a thread !
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

  #4 (permalink)  
Old 14-10-07, 18:39
Junior Member
 
Join Date: Oct 2007
Posts: 15
Rep Power: 0
darylmata is on a distinguished road
Re: SWF to PNG with Actionscript 3.0 - ByteArray class

I appreciate your time... I'm very frustrated...

uhmm.. no I din't move anything on the php..

I've been working on flash for almost 6 years on my own or by tutorials.

This is my first time with php.

Well actually my third, the first one was for the Flash MP3 Playlist and the second one was for the Send an eMail on Flash.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

  #5 (permalink)  
Old 14-10-07, 19:32
Administrator
 
Join Date: Jul 2007
Location: Cesena
Posts: 4,446
Rep Power: 6
Flep is on a distinguished road
Re: SWF to PNG with Actionscript 3.0 - ByteArray class

Hi
I meant if you set to 777 the permissions of sendMail.php
__________________

 


I recommend: Essential Actionscript 3.0

- Non rispondo ai messaggi privati con domande tecniche. Apri una discussione sul forum !
- I do not reply technicians pvt messages. Open a thread !
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Flash Multi Gallery
  #6 (permalink)  
Old 14-10-07, 19:59
Junior Member
 
Join Date: Oct 2007
Posts: 15
Rep Power: 0
darylmata is on a distinguished road
Re: SWF to PNG with Actionscript 3.0 - ByteArray class

yes.. sorry

I've change the mode to 777 on the php from the ftp, still it's not working

i tryed on Html kit and on Flash FXP

i was working on it right now
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

  #7 (permalink)  
Old 14-10-07, 20:11
Junior Member
 
Join Date: Oct 2007
Posts: 15
Rep Power: 0
darylmata is on a distinguished road
Re: SWF to PNG with Actionscript 3.0 - ByteArray class

i'm worried that the files aren't well linked, do I place them exactly just how are on the compress folder?

Do I need a folder named "images" or is the same that is on the adobe folder?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

  #8 (permalink)  
Old 14-10-07, 20:22
Junior Member
 
Join Date: Oct 2007
Posts: 15
Rep Power: 0
darylmata is on a distinguished road
Re: SWF to PNG with Actionscript 3.0 - ByteArray class

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

  #9 (permalink)  
Old 15-10-07, 06:51
Administrator
 
Join Date: Jul 2007
Location: Cesena
Posts: 4,446
Rep Power: 6
Flep is on a distinguished road
Re: SWF to PNG with Actionscript 3.0 - ByteArray class

Ok,
now you need a folder with name ' images ' ( into SWF_to_PNG_eng ) and chmod 777 it.

PS: you don't need to upload the ' com ' folder '.
__________________

 


I recommend: Essential Actionscript 3.0

- Non rispondo ai messaggi privati con domande tecniche. Apri una discussione sul forum !
- I do not reply technicians pvt messages. Open a thread !
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

  #10 (permalink)  
Old 15-10-07, 15:55
Junior Member
 
Join Date: Oct 2007
Posts: 15
Rep Power: 0
darylmata is on a distinguished road
Re: SWF to PNG with Actionscript 3.0 - ByteArray class

got it... I've created the folder and set the properties and erased the "com" folder
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads

Thread Thread Starter Forum Replies Last Post
Slicing an image with the Matrix Class of Actionscript 3.0 Flep Tutorials 7 17-11-08 01:48
Actionscript calls Javascript - ExternalInterface class of Flash CS3 Flep Tutorials 1 21-10-08 16:30
CheckEmail Class - Actionscript 3.0 Flep Tutorials 9 19-12-07 08:03
Timer class of Actionscript 3.0 Flep Tutorials 0 08-10-07 16:34
ByteArray Flep Articoli e tutorials 0 19-09-07 17:10


All times are GMT. The time now is 19:11.


Powered by vBulletin versione 3.7.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0 RC4
Forum SiteMap


FlepStudio
by Filippo Lughi
P.IVA 03605860406