A Flash Developer Resource Site














Internet Commerce

Partners & Affiliates














Developer Channel

internet.com


Featured Flash FLA
Gallery Downloads 11336 Flash Movies | 2 New Flash Movies Added
What's New | Top 100

Featured FLA

» Author: Surjit Dhami
» Title: Book
» Description: Book
» More by Surjit Dhami


Random FLAs | Add Flash Movie
Featured Flash Site
Gallery Downloads 5848 Flash Sites | 0 New Flash Links
What's New | Top 100 Flash Site

Featured Site

» Posted in the Flash Kit Links section
» Title: All-American Rejects
» Description: Get to know this great band by exploring their "practice room".


Random Links | Add your own Flash Related Links
Flash Tutorials 1277 Tutorials 7 New Tutorials Added!
What's New | Top100

» Create xml slideshow with free template
» How to Insert a Multilingual Subtitle Into Your Flash Video Studio
» How to Create Cool Halloween Slideshow
» Debugging flash using the Firebug console
» Create Flash Slideshow on Blogger
» FLASH TRICKS IN WEB ADVERTISING: FLASH BANNERS
» HTML Photo Gallery Tutorial
» Create your first flash site – PART 1
» How to Make a Flash Photo Gallery
» Unknown Tag: Title10
Random Tutorial | Add Site

Sr Instructional Designer D2L-Moodle,Clearance
WSI Nationwide, Inc.
US-NJ-Fort Monmouth

Justtechjobs.com Post A Job | Post A Resume


Tutorials Home What's New Top Rated Submit myTutes Random!

Search Tutorials


Tutorials Tutorials » Actionscripting

Categories Creating a preloader for use with the attachSound command
Author: FlashGuru | Website: http://www.flashguru.co.uk |

 
Page 3
«prev 1 2 3 4 next»

Now for the preloader:

Inside of your main movie, create a new movieclip and place it on the frame that you want your sound to start loading,from your library. Select the movieclip on the main timeline and right-click, choose actions, then copy and paste this script into the actions window:


onClipEvent(load){
 loadMovieNum("sound.swf",1)
}
onClipEvent(enterFrame){
 percentloaded=Math.floor(_level1.getBytesLoaded()/_level1.getBytesTotal()*100)
 percentdisplay=percentloaded + "%"
 if(percentloaded == 100 && !initialized){
  _level1.mysound()
  initialized=true
  _visible=false
 }
}

The above movieclip when loaded will now attempt to load the swf file named "sound.swf" into level one(_level1). The movieclip then loops everyframe(onclipEvent(enterFrame)) and checks to see if the sound movie has fully loaded, we do this by using two commands, the first is getBytesLoaded() which returns the number of bytes which have loaded for the specified movieclip and the second is getBytesTotal() which returns the total size of the specified movieclip. We then turn these values into a percentage and check to see if the percentage is equal to one hundered(100). If it is one hundred(100) then we call our function on the main timeline of level one (_level1 the level into which we loaded our movie) ashte movie is fully loaded. This function only wants to be called once when the movie is first found to be fully loaded so we use a simple boolean to determine whether we have already called the function, this is the code that says "!initialized" which basically means in english "if not initialized" then call the function, when the function is called we then set the value of initialized to be true therefore the function will not be called again from this movieclip:

initialized=true

Now inside of this movieclip if you want to display the precentage of the movie loaded simply create a new textfield, right-click choose panels>text options and check the dynamic text box, now in the variablename field enter "percentdisplay". If you dont want to display a petcentage then remove the line which says:

 percentdisplay=percentloaded + "%"

You can obviously display the number of bytes loaded etc.. by adding the correct code inside of the onClipEvent(enterFrame) parantheses. Also inside of this movieclip you should create your loading sound animation which will play only while the sound.swf file is loading, this is easily accomplished by setting the visiblity of the movieclip to zero when the sound.swf file has loaded:

_visible=false
So there it is the sound will now preload as and when you want it to and then play!

«prev 1 2 3 4 next»

» Level Intermediate

Added: : 2001-02-08
Rating: 8.16 Votes: 100
Hits: 2978
» Author
No details available
» Download
Download the files used in this tutorial.
Download (64 kb)
Get conversion and unzipping tools for PC and Mac here!

» Forums
More help? Search our boards for quick answers!

Please rate this tutorial, 10 is the top rating, you can also click the comments link to read/write a review.
10 9 8 7 6 5 4 3 2 1
Read or Post Comments
 
   
 

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs