how big is too big for a swf file - actionscript-3

I am making a flash game. And I want to know how big is too big for a swf file. Also, Ive been looking at my swf file and right now its at 38.2k. Is the swf file that gets created during debugging, is this the correct size for the file that will eventually be placed on the web.
thanks

Kilobytes is small stuff.
Anything less than a couple of megabytes is fine - once you get above that you might start worrying about loading times and keeping users interested during the preloader, but most portals accept files up to 10MB or so.

Yes, the file is the same. A game of 38.2 kb is pretty small, if you go on Flash game sites they regularly run in the multiple of megabytes.

The SWF is slightly smaller in release mode. The size difference is essentially nothing.
As for a guideline size, this depends on who you are expecting to play your game.

if you want your game to reach a very wide audience keep it as small as you possibly can.
a game without any heavy animation , embedded assets like png files or sound will usually be small.
a good discussion regarding Optimal swf size for flash games here at
http://board.flashkit.com/board/showthread.php?t=788271

The difference between debug and release builds is, according to my experience, some 30-40% in file size (debug version being bigger, of course), which is not insignificant.
Anyways, I think you're safe to assume that anything below 100kb is small enough to be considered an instant download, with no need to use preloaders. However, adding graphical and sound assets to the game will quickly push it up in size, at which point the preloader will probably be a good idea.

Related

Speeding up the image loading process

How can we speed up the process of loading hundred's of images in as3? it seams to be taking a very long time to load 100's of images.
If you don't have the ability to change the image quality or sizes, then there isn't a lot you can do to speed up such a large load, as you are limited by connection speed and simultaneous browser connections.
You may be benefitted by using a loading manager, like Greensock's LoaderMax. LoaderMax will help make sure you are loading several assets simultaneously - check out the maxConnections parameter.
Also, I suggest not loading everything up front with one preloader. Instead, have placeholders with a spinning loader for each image that then gets replaced by the final image once loaded. This will provide a much smoother user experience and create the illusion of the overall load taking less time.
100s of requests can take quite a long time even if the total size of the images isn't prohibitively large. If you know which images you need in advance, you could embed the images in another swf which you load at runtime.
By the way, what is the reason that you need to load 100s of images right away. Is there any reason you can't load them in the background a little more slowly?
A few suggestions:
Reduce the filesize of your images (obvious but most important).
Don't run all the requests at once - queue the images and load them one at a time (most relevant to least relevant).
There were lots of good advices already. But here a re my 2 cents. One day I had to load about 1000 of really small images. It was taking too long so I used FZip AS3 library. Worked like a charm.
The question does not provide a lot of specifics, so here are some general guidelines.
If the images are large JPEGs, you might be able to sacrifice some quality and recompress the images to make them smaller.
If the images are PNGs and represent, e.g., lots of small, individual tiles for a game, you could try combining many of them into a single image and then parsing them out into images on the client side after loading the image over the network.
Implement download queue, for example simple loader
https://github.com/hydrotik/QueueLoader
Do not load images that
currently out of stage (you can load them in background)
Use texture packer if you have plenty of small images
Optimize pics
quality (i.e. size, type)
Use cache, for instance Local Shared
Object, so for next time you'll get your pics ultimately fast from
LSO.
Is there any way to get thumbnails of the images made? If so, you could use the thumbnails while the larger versions load. Load all the thumbnails first (since they'd load really fast), then load the larger versions in prioritized order.
It sounds like you don't have a lot of control over the images, though. If you don't have any control there, there's very little you can do to speed up the process besides using a loading optimizer as others have suggested.

How to handle resources for as3 web game? (Embed/Loader)

Ask a question .. images resources of the flash game , How should I load? I use the Loader class, but some people use the embedded resources.Can you tell me in which case use "Loader" class and in which case use "[Embed]"?
It all depends on the game requirements. You have to have in mind that if you use Loaders your game will not work in offline mode (without internet access), which in some cases is critical (i.e. a flash game for a mobile device).
If the final file size isn't a problem, then you should always embed your assets and load only dynamic resources (i.e. ads). You can always use assets libraries to store the resources and to reduce the initial loading time for the application.
Using the embed tag literally compiles that resource into the final SWF output. So it's a matter of how much preloading you want to do and how big you want your initial swf to be. If you are embedding some small thumbnail images or sound files, this may be okay to an extent. But if you embed all of your assets or large assets, well you can figure it out from there, you're going to merge that file size + the size of any other files into 1 file, which is also meant to be your user interface. Keep assets external (for the most part) and dynamically load them in. There might be specific cases as mentioned here in other answers where it is required but unless otherwise dictated, organize your assets and simply load/unload them as needed. The other nice thing about using the Loader class is that is gives you more control over destroying the object from memory than anything else. You can call the unloadAndStop(Boolean CallGarbageCollector) method and directly request the VM to forcefully stop, delete and clean that object up. Anyway hope this clarifies things.
If you would submit your game to Kongregate or Newgrounds, they have strict rules - game should consist of one file. If you host game yourself, you may do as you wish, but take into account that loading needs time and your game find that some resource needed and not yet loaded.
As a rule of thumb, if your game is small, embed everything. If resources are vast and not used simultaneously, think about loading dynamically - this is much harder but allows for faster game start.

Flash .exe projector on a cd, memory issues

I'm working with a project where we are running a projector from/on a CD, and this can't be changed, to run an e-learning program of sorts. Everything is included on the CD and it doesn't need anything else to run, ie all imgs and xml and whatnot is on the CD.
The problem is that on some computers, assumedly less powerful ones, the entire process clogs up and instead of showing the images just white blank areas appear. The imgs used have been downgraded to a lower resolution, from 1333x1000 to 800x600, and this has solved the problem from what we've found so far.
My question is, does anyone know of any other way to solve this without cutting down the img quality?
As it is right now all the pics (about 180 i think) are being loaded right when the process starts and one idea i have is that you load the pics gradually as needed, 2-3 in advance back and forward or maybe an entire chapter even (7 chapters with imgs are used), to always ensure smooth tweens without having to wait for loading.
But as I've read that there seems to be some memory issue when using a flash projector on a CD/DVD, I'd also like to get more details on what the actual problem is and if possible to find more solutions to it.
I found some links that were supposed to target Adobes own views on the problem, but these links were obsolete. (links found here http://www.flashjester.com/?section=faq&cPath=14_23#394).
Any ideas, help, links, tutorials and what not are welcome.
Yeah, you need to load your assets on-demand and be careful about references so unused things are really garbage collected when they aren't needed anymore.
If you are really running from a projector, then load times aren't totally a concern. Assets form the local filesystem are always available the next frame; they aren't streamed from the disk like from the network. However, bigs file or ones with lots of exports may end up with a longer frame time, or a noticeable delay.
You also need profile things to see if your changes are actually doing anything. Poke through the flash.system.System class to see how you can get info, or take a look at SWFProfiler.

Multiple Flash objects on a single web page?

Is there any significant performance/load time impact if single web page will load, say, 10 identical flash objects? 20? 30?.. any evidential data on sustainability of such kind of setup?
This would be the same flash app, each instance serving its own stream.
There's definitely going to be some overhead in size as there is a certain amount of code that is contained in every swf regardless of it's developer created content.
I'm almost certain there would be speed issues as well, which would see frame rates drop right down the more swfs you add to the page.
To be honest the concept smells a little fishy and i would think there must be a better solution to your problem.
EDIT
Also there is a restriction on having two steams coming over http per domain. Sure you could get around this but it will definitely be an issue.
I found this post which might help. The trick is to use SWFObject to embed your swf files.
I ran into a strange problem today. On the music charts page on Muziboo, I was displaying a list of songs and a playlist on the right. Each song has a small button player done in OpenLaszlo. In firefox everything was fine and in IE (not unusually), the page would freeze for sometime. This would happen once and repeat only if I delete cache and try again. I googled a bit and learnt that it's a good idea to embed give each swf a unique id otherwise the browser misbehaves. I then went ahead and used swfobject to embed the swf files and everything started working great!
Yes, it'll likely nuke the browser if you go too far down that road.
If you want to deal in multiple streams, perhaps combining all your would-be applets into one giant one might work better. It'll certainly offset the serious overhead you'd have with 10-40 of the little blighters.
If this is a music player, you want to have a serious look at doing some JavaScript remoting. It's fairly trivial to control a flash app via JS so you could have standard HTML/CSS controls without having to load up a billion flash instances.
Design-wise this just sounds like a bad idea. You'd be running multiple instances of the Flash player inside a browser, each of which has an individual cost, and the host (in this case the browser) will run all of them on the same thread (with the exception of certain elective asynchronous processes), so you're almost surely going to run into problems of various kinds -- jittery playback, UI blocking, processor burden, memory bloat, consequent instability of the host, etc.
Unless the SWFs are very tiny, and doing very little work, it seems like a design that's just asking for trouble. Indeed you could test such a thing fairly easily; have you run any tests yet? Just curious.
Also curious as to the requirements; we might be able to offer more constructive alternatives if we knew a little more about what you were aiming for. Have you considered simply loading all the SWFs into a single container SWF requiring only a single browser-hosted instance of the Flash player?

simple music or tunes via HTML?

I'm looking for a simple way to put up musical "tunes" on a website.
So here's an analogy to explain my question:
Let's say I want to put up a couple of big triangles as a picture on my web page. I can either draw a bitmap and save as GIF/JPG/PNG, put it up somewhere on the internet, and link to it with an element. That works but the larger the picture the more space my image file takes up.
Alternatively, I can use SVG (even though Internet Explorer support is lacking, grr) and use vector graphics which uses very little bandwidth regardless of image size.
In the music world, I can use WAV or MP3 files. Works great -- but if I just want to publish a 1-minute song of simple notes, by knowing the durations & pitches, & don't care that it sounds 100% exactly like a piano or accordion, is there a way to (a) create a file with the song, and (b) put it online in a format that is space-efficient? 1 minute of MP3 usually takes up hundreds of kilobytes.
You could use a MIDI file, this stores durations/pitches etc. as you suggest. You should be able to easily find software to create this type of file. However you will probably find the results sound terrible, as it is very dependent on the synthesiser hardware/software that is available on the end-user's machine.
For what you need this might be reasonable though.
Look into playing music files on websites using Flash.
You can control the Flash through JavaScript calls.
This is currently the "recommended" way to play small audio clips in a website.
For larger media files, look into streaming FLV files using a Flash player.
Hope this helps :)
Check out the MIDI format for instruments.
http://en.wikipedia.org/wiki/MIDI