You are a as3 Old bird ? If the following is of great help to you , Please top down !

One : load swf Pictures in the library

new The process of image decompression is the process of image decompression . be in Class In the state of , The memory and SWF This image in the file takes up the same disk space , And once it's passed new Decompress into uncompressed BitmapData after , The amount of memory used will increase dramatically .

Whether it's PNG、JPG, Or vector animation ,new After that, the volume will be much larger than before , So don't instantiate and temporarily store resources . Of course, the instantiation process is time-consuming , There may be a card phenomenon , But pre instantiation , There is a big difference in memory usage .

Besides , If you choose settings LoaderContext If all resources are loaded into the same domain , Conflicting link names are handled on a first come first served basis , That is, if two resources have the same link name , Subject to the object loaded first .

Two : Package the material image into a SWF benefits

Pack it up SWF There is an advantage ,SWF It can make JPEG Support transparent channels . Generally speaking ,JPEG High compression rate without transparent channel support ,PNG Low compression rate, support transparent channel . take PNG Import FLA Then set it to JPEG After the compression , You can compress and keep the transparent channel at the same time , It can greatly reduce the size of images that support transparent channels .

Pack it up SWF after , Load fast and easy to manage , It's the way of recommendation . But this way you have to load all the resources at once , Can't load on demand , There are certain limitations . More suitable for loading UI The skin , And the icons that need to be displayed immediately .

There's one more thing to note :SWF The content on stage , Even if it doesn't show up, it will consume resources , So please make sure the stage is empty when you release it .

3、 ... and : Don't use it directly Loader Load the file

Different files have different ways of loading , Text and binaries can only be accessed through URLLoader load , and PNG、JPG、SWF And so on Loader and URLLoader Two ways to load . If resources need long-term preservation , It is suggested to use all URLLoader Mode load , When resources are needed , Re pass Loader Of loadBytes Method to parse the loaded binary data , And then it shows .

The goal is to save memory , because Loader The loaded resources are automatically instantiated ( decode ),PNG、JPG The exhibition will open without compression BitmapData,SWF The content of the stage will be all instantiated , They take up a lot of memory . First use URLLoader Load them as binary data , Decode and instantiate when needed , That's not going to happen .

Four : Concurrent loading There is another problem with multi file loading : Browsers have limits on the number of concurrent downloads , And this limitation and Flash Player There's a conflict of mechanisms , So in general Flash Player The number of loading requests initiated at the same time should not exceed 5 individual , Otherwise, the load event may fail . To solve this problem , Most people's solution is to take queue loading , Load only one file at a time . This is when the number of files is small 、 When a single file is large, there is no problem , But when the number of files is large 、 The volume of a single file is small , Because after loading a file each time , When you re request the next file, you need to wait for the server to respond for a while before loading , This wastes a lot of bandwidth , When the number of files is large, this defect cannot be ignored , At most, it can consume 2 to 3 Times the loading time . To solve this problem , We need a special queue loading module , It can be loaded at the same time , But the number of files loaded at the same time cannot exceed a certain value . The basic idea is after loading a file , Check the number of files being loaded , If it is less than the fixed value, the next address in the queue will be taken to create a new load , Otherwise, we will do nothing .

 

5、 ... and : Hash table cache When the number of files loaded is particularly large ( Like hundreds of ), Be careful not to just use arrays to save . You can create a Dictionary, Then load the name as the key and the content as the value , Make a hash table , In the future, the value will be directly obtained from this hash table by name , It's much faster than traversing arrays to find names .

 

 

6、 ... and : Lord SWF Loading problem SWF You have to load all the classes before you can start running and display the image , thus , The first one is SWF When you load yourself, you can't show the loading progress . There are two ways to solve this problem : One way is old but practical , It's about creating a little SWF Show it first , Dedicated to loading the main SWF, Lord SWF After loading, it completes its mission . In fact, it's not troublesome and the most stable solution . Another way is to use Frame Meta tags . In the main SWF Add... To the class name

[Frame(factoryClass=" Load class name ")]

You can specify a class as the loading class , It will be in the main SWF Show before loading . This class is a two frame MovieClip, When it loads itself , Then you can reflect the Lord SWF And instantiate .

Reprinted from :http://bbs.9ria.com/thread-243034-1-1.html

[ turn ] You are a as3 Old bird ? But there are more articles about things you may not know right now

  1. Talk about programmers ( 11、 ... and ) One of the tricks that old programmers know but novices don't know Web Front end

    Tips that old programmers know but novices don't know Web  Front end Constant charge ! There is only one way for programmers to die : Earthy . Don't exceed 50 That's ok . Don't write too much code too late to test at once , But to write a debugging paragraph . UI And code to be done simultaneously . Write more comments ...

  2. 【 repair 】 English to IT The importance of workers

    On the English learning of programmers   As a programmer working in China , Not knowing English doesn't seem to hinder getting a good job , A promotion and pay increase . But the job of programmer is slightly different , Because the program , Especially high-level languages , It's basically made up of English and numerical expressions . English is very important for programmers ...

  3. [ turn ] About AS3 Socket and TCP I have to say three or two things

    Sharpening a knife never misses a woodcutter , Let's start with the concept , Step by step . So-called socket It's also called " Socket ", Used to describe IP Address and port , Is a handle to a communication chain . Applications usually go through " Socket " To the Internet ...

  4. [ turn ]as3 A thorough understanding of the event flow mechanism

    . : I've seen some on the Internet as3 A tutorial on event flow , I think most of them are not very clear , People can't understand the flow of events intuitively . This tutorial compares the event flow process to the fishing process , The image is simple . On this basis, for as3 The flow of events is finally fully understood . The event flow mechanism says ...

  5. post Contents<1-- To 200—>

    ====================-------------- Preface : Essays in blogs . Not all of them are my original articles . Some are listening to others . Some of them are excerpts from books . Some of them are from Baidu . Some of them are from other people's blogs . Some of them are themselves ...

  6. Fully understand Context

    Source :http://blog.csdn.net/lmj623565791/article/details/40481055, This article from the :[ Zhang Hongyang's blog ] Most of this article is translated from :http://www.do ...

  7. Router WDS Bridging tutorial

    Because you have bought this route and you can't bridge it , So do this tutorial . The old bird passed by automatically , I don't say much nonsense , Let's start with . 1.wifi Password cracking and router user name and password, please solve by yourself , I'll just talk about the bridge part . First , Type in the browser 192.168. ...

  8. from IEnumerable and IEnumerator Extension of

    I believe you are learning c# When , I often see IEnumerable.IEnumerator Such an interface or return type , When you write code, you often write to arrays or List Set to traverse . that IEnumerable and IEnumerator yes ...

  9. PowerShell Pipe entry , See if you don't ( Pipeline examples )

    PowerShell One of the most important functions of is pipeline (pipeline), This article from shallow to deep , Step by step, explain the usage and examples of the pipeline , Let's see if there's anything you don't know , If you know all about it , Congratulations, you're great -- For all Power ...

Random recommendation

  1. DIP The principle of Dependence Inversion

    One . Definition 1. High level modules should not rely on low level modules , Both should rely on abstraction 2. Abstractions should not depend on details . Details should depend on abstractions Two . hierarchical 1. Brief introduction Well structured object-oriented architectures have clear hierarchical definitions , Each level is defined by a definition ...

  2. Android Learning the second 2 course , download eclipse Tools

    You can go to http://www.ddooo.com/softdown/61745.htm The download is 32 Bit and 64 There are all of them And it's Chinese , Tested successfully , just so so , Pretty good !

  3. A custom HBase Filter -“ adopt RowKeys To get data with high performance ”

    Abstract : We are using HBase and Solr A common problem in building a system is :“ I passed SOLR Got it RowKeys after , How to go HBase Pick up the data ”. Use the existing Filter Poor performance , There is no ready-made customization on the Internet Fi ...

  4. gpus_ReturnGuiltyForHardwareRestart error

    It turns out that glScissor The length and width cannot be 0, There are problems with some devices

  5. Mac Develop common directory under

    1:Snippets    Xcode The file representation of the code segment ~/Library/Developer/Xcode/UserData/CodeSnippets/ 2: Services   You can add workf ...

  6. Study with me PCL Print language ( One )

    introduction I am engaged in printer development and print driver development related work , We are deeply aware of the lack and unsystematization of information, especially in Chinese , For newcomers to the industry , The threshold is very high . Here, on the one hand is to sort out the relevant knowledge points encountered in the development , On the other hand, it can promote itself ...

  7. JDBC Connect to the database and add, delete, change and query operations

    What is? JDBC?Java Language access to a database specification , It's a set APIJDBC (Java Database Connectivity) API, namely Java Database programming interface , It's a standard set of Java Interfaces and classes in languages ...

  8. [http service ]

    [http service ] CentOS 6 httpd Program environment Recorded httpd The main process number of : v Main program file : /usr/sbin/httpd /usr/sbin/httpd.worker /usr/sb ...

  9. ccf Buy more vegetables Search for dfs

    // Recurrence relation :(b[n-1]+b[n]+b[n+1])/3=a[n] // therefore b[n+1]=3*a[n]-b[n-1]-b[n], or b[n+1]=3*a[n]-b[n-1]-b[n]+1, or b[n+ ...

  10. C Language implementation string IP And integer type IP Mutual conversion of

    #include <stdio.h> #include <stdlib.h> #include <string.h> #include <malloc.h&g ...