[Add to favorites] original-perfect loading-perfect to the end [basic]

Source: Internet
Author: User
This article from: http://www.awflasher.com/blog/article.asp? Id = 444AW's BLOG

If you haven't posted any technical logs for a long time, you will be perfect when you come. Don't be excited. A small loading talk about perfection. I think you will know it when you read it.
I wrote this article as the world's most complete non-Flash beginner loading tutorial. Reprinted, Please retain the original address:
Http://www.awflasher.com/blog? Id = 444

First, I want to explain my motivation for writing this article. I remember a long time ago I said, "The flash without loading is not a complete flash ". I think that sentence may be excited. Because sometimes some flash with less than 10 KB does not need to be loading. But I always think that,Doing a Good loading is a measure of a flasher level or even attitude. You ask me why, I can tell you, Because loading is the only one that you don't want to read but all users and customers will see, so you pay attention to loading, it can even contradict your flasher professional ethics!

Some design-oriented friends, I know a lot about it. They have a bad attitude towards loading. They do loading, and they find a ready-made one, and apply it each time, I personally think it is a bad habit. It doesn't mean that I don't advocate code and Component Reuse, but I think there is a lot of problems with loading. I strongly recommend that the flasher who has reached the loading level to view my things. Of course, if you don't even know where to write the flash as, I suggest you get started first.

Well, let's start with the question: how to make loading.

First of all, we must be grateful to Macromedia for its great wisdom. We have provided two excellent functions to make the perfect loading, namely getBytesLoaded and getBytesTotal. I can't remember how to make it happen again. I just want to say that the concept of Frame will fade in real Interactive-Design. Not to mention Scene, it's the Flash failure!

So how does loading work? How can we use these two functions? An important concept should be mentioned here. It is called at intervals. There are multiple call interval methods. The following lists their position and usage in loading production. You are welcome to add:

· SetInterval
Statement:

Function loadCheck ()
{
Var p = getBytesLoaded ()/getBytesTotal ();
If (p = 1)
{
ClearInterval (intervalID); // call the release Interval
GotoAndPlay (someFrame); // start playing
}
}
Var interval = 30; // The value is the refresh frequency.
Var intervalID = setInterval (loadCheck, interval );

I personally do not recommend this method for beginners. Because clearInterval is easy to ignore, and it is terrible to ignore it! If your setInterval is not promptly removed, it means that you will add an unnecessary burden throughout the swf playing process!
In addition, this method is not suitable for controlling the MoiveClip situation (because beginners will find that the MC path is a big problem, and loadCheck itself is a function and is still called by setInterval, it is troublesome to specify a path in loadCheck. Do not count on _ root, which will make your program nonstandard. Do not count on this, because it does not seem ideal to use this in functions; it is best to do nothing, but you often do not dare not write) to achieve better results.

· OnEnterFrame Method
This is my favorite method. It is convenient and intuitive.
Because we often use a MC to reflect a loading progress, such as a progress bar or something more creative, only you can't think of, and you can't do it without it.
So how to use it. First, set the idea. Then give your MC An Instance name, such as loader_mc. At this time, write code on timeline. Remember, it is timeline rather than MC. This facilitates code unification, path unification, management, and searching. Don't just move the code to the button and mc to save a few letters, and then there's something wrong with on (press. Unless you are perfunctory in your work, or you are trying to hand in your homework.

Reference Loader_mc.onEnterFrame = function ()
{
Var getTar: MovieClip = this. _ parent;
Var p = getTar. getBytesLoaded ()/getTar. getBytesTotal ();
Trace (p );
If (p = 1)
{
// This. onEnterFrame = null)
Delete this. onEnterFrame; // delete
GotoAndPlay (someFrame); // start playing
}

}

It's that simple. Remember, referencing MC inside MC's event function is always a very fast thing. Because this can point to the MC itself, you can find all your MC through methods such as this. _ parent!

· The timeline-based cycle
This is a very, very old method. However, you can ask the flashers who have never liked to do loading by themselves. This may be the version they are changing.

The above is relatively simple. There are two more problems.
1. movi1_loader
2. Loader with multiple V2 Components

I bought a train ticket back to school and wrote it again. Haha
If it is not enough, you can refer to my original loading special effect, which is applied in my portfolio (the work does not look at it, it is very bad, there is no time to do anything good) and see the source code

This series of articles:
1-[technology] originality-perfect loading-perfect in the end [Foundation]
Http://www.awflasher.com/blog/article.asp? Id = 444
This section describes the basics of loading.

2-[technology] originality-perfect loading-perfect final [Weapon]
Http://www.awflasher.com/blog/article.asp? Id = 468
Describes in detail the use of the movi1_loader class and some principles.

3-[technology] originality-perfect loading-perfect in the end [burden reduction]
Http://www.awflasher.com/blog/article.asp? Id = 470
It mainly solves the loading related to v2 components. The original figure is shown. Now, the series of tutorials are over, so there should be no more loading troubles! :)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.