开发者

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

开发者 https://www.devze.com 2023-02-25 22:48 出处:网络
Ask a question .. images resources of the flash game , How should I load? I use the Loader class,开发者_C百科 but some people use the embedded resources.Can you tell me in which case use \"Loader\" cl

Ask a question .. images resources of the flash game , How should I load? I use the Loader class,开发者_C百科 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消