Forum ActionScript 3.0 Dynamic creation of cached bitmaps

Problems and discussions relating to ActionScript 3.0 here.

Dynamic creation of cached bitmaps

Postby default0 » October 1st, 2010, 5:30 pm

Yo,

I'm having a problem in the terms of optimization. This is pretty much non-API-related but I guess this forum isn't only for questions regarding the API is it?

Anyways, my problem is the following:
I have a flash-drawing inside my FLA and am applying filters to it. Now this is, when it comes to rendering, pretty slow.
After reading some stuff about optimization using cached bitmaps (cacheAsBitmap thingy) I came up with an idea that might work.
However, I have no clue on how to do this:
What I want to do is, Apply filters to my flash drawing and then cache the flash drawing with applied filters in a bitmap and render that to the screen instead of making the flash player redraw and rerender the drawing + filters each frame (because the object is updated each frame).

So, is there any way to accomplish this?

Best regards
Try to play my Game: -->BlackGalaxy<--
User avatar
default0
 
Posts: 115
Joined: February 2nd, 2010, 6:46 pm
Location: Germany

Re: Dynamic creation of cached bitmaps

Postby fox1980 » October 1st, 2010, 6:25 pm

What if you convert the images you want to cache to a bytearray, and then pass that bytearray to a PHP script that will save them on your webserver ?
fox1980
 
Posts: 206
Joined: April 1st, 2010, 10:39 pm

Re: Dynamic creation of cached bitmaps

Postby default0 » October 1st, 2010, 6:34 pm

fox1980 wrote:What if you convert the images you want to cache to a bytearray, and then pass that bytearray to a PHP script that will save them on your webserver ?


Thanks for the answer, but I only need the Bitmap Image on the flash side, not server side, I guess I explained something wrong or not good enough.
What I want to do is not to actually SAVE the image as a file somewhere, but save it as a temporary variable on the players machine so that rendering is being ways faster (since Bitmap images render lots faster than Flash drawings).

Best regards
Try to play my Game: -->BlackGalaxy<--
User avatar
default0
 
Posts: 115
Joined: February 2nd, 2010, 6:46 pm
Location: Germany

Re: Dynamic creation of cached bitmaps

Postby fox1980 » October 1st, 2010, 6:53 pm

My suggestion still stands. You can check your webserver to see if an image exists and load it from there, if not you create it and then load it from there. Your webbrowser should then do the caching automatically. If you don't need the keep the images for another game session you can just clear the folder where you keep them.

Another way i can think of is creating an array of images in AS3 and use it to store what you want, but that may be very demanding memory wise.
fox1980
 
Posts: 206
Joined: April 1st, 2010, 10:39 pm

Re: Dynamic creation of cached bitmaps

Postby default0 » October 1st, 2010, 6:58 pm

fox1980 wrote:My suggestion still stands. You can check your webserver to see if an image exists and load it from there, if not you create it and then load it from there. Your webbrowser should then do the caching automatically. If you don't need the keep the images for another game session you can just clear the folder where you keep them.

Another way i can think of is creating an array of images in AS3 and use it to store what you want, but that may be very demanding memory wise.


Yeah, but the game I'm coding is Singleplayer not Multiplayer, so building the enitre backend for communication with a webserver for parsing/getting images would be pretty much of work ;)

Your second suggestion seems more fitting for what I'm trying to do.
How about the memory? I need to store about 50-100 images that are sized from 50x50 up to 150x150, I guess this shouldn't take too much memory, or?

Best regards
Try to play my Game: -->BlackGalaxy<--
User avatar
default0
 
Posts: 115
Joined: February 2nd, 2010, 6:46 pm
Location: Germany

Re: Dynamic creation of cached bitmaps

Postby fox1980 » October 1st, 2010, 7:09 pm

Regardless of being singleplayer or multiplayer as long as you have a webserver with php installed you would only need a software like amfphp to communicate between AS3 and php.

This solution would be very slow the first time the images were being saved, but would be quite fast after the browser cached them. I believe it would take less memory too.

For the second option i don't think it would take that much memory for the image sizes you were talking about. I figure around 2MB, memory is abundant in client machines these days so this may be your best bet.
fox1980
 
Posts: 206
Joined: April 1st, 2010, 10:39 pm

Re: Dynamic creation of cached bitmaps

Postby default0 » October 1st, 2010, 7:27 pm

fox1980 wrote:Regardless of being singleplayer or multiplayer as long as you have a webserver with php installed you would only need a software like amfphp to communicate between AS3 and php.

This solution would be very slow the first time the images were being saved, but would be quite fast after the browser cached them. I believe it would take less memory too.

For the second option i don't think it would take that much memory for the image sizes you were talking about. I figure around 2MB, memory is abundant in client machines these days so this may be your best bet.


Thanks for helping out.
Great to hear that I don't have to care about Memory :)
I guess I will try that solution.

Best regards
Try to play my Game: -->BlackGalaxy<--
User avatar
default0
 
Posts: 115
Joined: February 2nd, 2010, 6:46 pm
Location: Germany


Return to ActionScript 3.0



cron