Many people use external swf files these days, because they are a good way to structure a website and manage it, but I also have the advantage of being small in size. These swf files can also divide a site into sections: each external swf file is associated with a section.These files are dynamically read into the movie when we enter a section of the site. When we ask the question that has been asked lately, how to create light and functional transitions between external swf files? We will try to show you the best way to do it, in this tutorial.
swf fileRight-click on the movie to display the options menu
Downloads:Flash Player iconfl filePDF tutorialHere is an example of what we intend to create:our aimEach swf will contain a small animation, a frame it will stop on, and an animation called another. When the main movie is read, the first swf will be played. It will then play the intro animation and stop at a certain frame. When the user presses a button (located on the timeline) for a different section to be read, the swf file will be warned that it needs to read the animation called another. When this animation called another is finished playing, the new swf will likewise read your animation and stop on the frame before the other one. When a user presses another button again, the same process will be repeated. This results in transitions between swf files.How it worksThe system is based on two variables: midframe and _root.currMovie.midframe is the variable at the first frame on the main timeline of each swf file. This variable stores the frame number on which the swf file will stop. Each swf contains its variable, and it can be different for each swf, not being necessarily necessary. This variable will be used with the buttons: when we press a button in another section, it will be checked if the current swf is positioned in the midframe. If so, the current swf will be ordered to trigger the play() function – which means that the other animation will start, because the other animation starts in the frame after the midframe._root.currMovie is a variable that contains the name of the section that is currently being viewed. It is created in the _root, because its variable will have to be accessed by both the swfs and the main movie. This variable is used for 3 reasons:1.The first reason involves buttons: when we press a button on our timeline, that button needs to check when a section is ordered to be read, if it’s not the one currently being viewed, or if no swf is being read automatically in the start of main movie, if _root.currMovie is not set. If not defined, then this means that there is no section read so far, and a corresponding button should be read, so _root.currMovie should be assigned to the name of this section. Firstly it will check if it has been defined or not, and if it has not been defined, then it will check if it is not different from the section that is currently being displayed.two.The second reason is intertwined with the first. When a button is pressed, the code in the button will check if the required swf is different with what is being viewed. If it’s true, we’ll have to check if the current movie is in the correct position or ahead of the midframe. If it is further than the midframe, this allows the user to see which movie is being played when the other movie is being viewed, for example when we accidentally press the wrong button. So if the current frame is in the midframe or somewhere else in the animation (further ahead than the midframe), then _root.currMovie will have to be the name of the new section, and the current swf will have to be sorted equally to be read – if it’s in the midframe, it will start playing the animation elsewhere. If the other animation is already being played, then the play() command will have no effect because it is already being played.3. You must be wondering how the new swf is being read so now. When a button is pressed, _root.currMovie is updated to the new section and the corresponding swf is ordered to be read. Because of this, _root.currMovie will be the name of the new section at the end of the other animation. This is how we will use the swf file to be read in the new section at the end of the other animation. We will read a swf file with the value name _root.currMovie, plus the “.swf”. This means that the values ​​we give to _root.currMovie should be the names of our swfs files, without “.swf”.Example: If we have the swfs, “main.swf, “about.swf”, “work.swf” and “contact.swf”, then the values ​​that will be assigned to _root.currMovie will be “main”, “about”, “ work” and “contact”. Otherwise, the transitions will not is this doneThe following steps will help us to create transition effects for files externally read in Flash.main movieIf you have already created the buttons and a main movie, skip the next 2 steps.1. Create your buttons. Each button is related to each section, for example:“Main”, “About”, “Work”, etc.2. Create a new MovieClip and place it on your stage. This will be the swf that all other swfs will be read from. The top left corner of your swf file will correspond to the MovieClip registration point – the point you can see on the stage.3. Select the MovieClip you just created and assign the name “container” to its <Instance Name>. This is the MovieClip where we will read the swf files.4. Select a button, and copy the following code to the Actions panel:on (release) {
if (_root.currMovie == undefined) {
_root.currMovie = “main”;
} else if (_root.currMovie != “main”) {
if (container._currentframe >= container.midframe) {
_root.currMovie = “main”;;
}This is the code for each button that will check that everything is correct so the other animation can be read and the next swf file can be read. Note that each value that is assigned to currMovie is the name of the swf file, without the “.swf”.5. Repeat each of the previous steps for each button you use in your stage. Remember to change the value assigned to _root.currMovie and the name of the swf file that should be read. To give you an idea, here is an example of how the code will look each time the button reads the swf and makes it work:on (release) {
if (_root.currMovie == undefined) {
_root.currMovie = “work”;
} else if (_root.currMovie != “work”) {
if (container._currentframe >= container.midframe) {
_root.currMovie = “work”;;
}Explanation of this code was described in _root.currMovie 3 main steps explanation.If you want the first section to be read automatically when we enter the site, place the code in the first frame of the main timeline, where we would like the first section to be shown, and rename the “name_of_your_first_section” to the name of your first section:root.currMovie = “your_first_section_name”;
The SWF file1. Create your intro animation, contents (if not already created) and your other animation in your main timeline.2. Select the frame where your content is contained and remember its framenumber.3. With the frame still selected, open your ActionScript window and copy the following code into it:stop();4. Select the first frame of your timeline, and open your ActionScript window once more. Paste in the same, the following code, and replace [ovossonumero] by the number that you remember that you put in step 2.midframe = [yournumber];Now, select the last frame on your timeline and reopen your ActionScript window. Paste the following code into that window. If you have used another name for the <instance name> than container, don’t forget to change the name._root.container.loadMovie(_root.currMovie+”.swf”);Adding Preloaders

A question that may arise is how it will be possible to add a preloader to these swfs, and from there, how to create the transitions between them. This is a very easy step to take. Once you complete this tutorial, you will have 2 extra frames at the beginning of your swf, before your intro animation. What’s left for you to do is add the midframe definition to the preloader code you have in the first frame.

Be careful though – once you’ve added 2 extra frames, your midframe will never be the same again. Don’t forget to update your midframe number.

The preloader code for the first frame will look like this:midframe = [yourupdatednumber];
bytes_loaded = Math.round(this.getBytesLoaded());
bytes_total = Math.round(this.getBytesTotal());
getPercent = bytes_loaded/bytes_total;
this.loadBar._width = getPercent*100;
this.loadText = Math.round(getPercent*100)+”%”;
if (bytes_loaded == bytes_total) {
Leave a Reply

Your email address will not be published. Required fields are marked *

You May Also Like

Safety Measures for Real Estate wordpress Theme

Security plugins Creaig and managing a real estate website using the WordPress platform is the easiest…


HOSTING DEFINITION Short and concise, the hosting definition is as follows: connecting…