Preloader in AS3
hi,
Can u give me any idea how to creat preloader in as3..
Plz help me guys m new in as3
Thanks,
JaxNa
on first Key frame the following code
loader is a movie Clip
percent is a text field
stop();
addEventListener(Event.ENTER_FRAME, preloader);
function preloader(evet:Event){
var load_value:Number = this.loaderInfo.bytesLoaded / this.loaderInfo.bytesTotal;
loader.scaleX = load_value;
if (this.loaderInfo.bytesLoaded == this.loaderInfo.bytesTotal){
this.gotoAndStop(2);
removeEventListener(Event.ENTER_FRAME, preloader);
Similar Messages
-
Simple preloader in AS3 - HELP
Hi,
Could anyone please point me in the direction or tell me how
to build a simple preloader in AS3/PlashPlayer 9.
I'd just like to have a movie clip in frame one which
animates until the rest of the timeline has loaded, then once
loaded go to frame 2.
I've had a look in the doucumentation and around the web to
find something but can't find anything that works and I'm finding
it quite hard.
Thanks in advanceThese screen captures show the library of the movie. As you can see I export the most of them. However I have doubts about if I must convert to symbol the graphics. I have the preloader in the "presentación" folder without any exportation.
Please, Could you correct the website?. Please, tell me an e-mail address and I send you the website via WeTransfer. -
Hi, I searched the internet but I couldn't find a solution to skip the preloader in AS3. All I found was for AS2 (Maybe I didn't search well )
When I visit my page again and the flash has already been loaded, I get stuck on frame 1 and the movie does not continue to where it supposed to be. Is there a way to skip the preloader if the swf has already been preloaded or cached?
Here is my actionscript:
//Import the required assets
import flash.display.*;
//Stop the playhead while loading occurs
this.stop();
//Create a listener to call the loading function as the movie loads
this.loaderInfo.addEventListener (ProgressEvent.PROGRESS, PL_LOADING);
/*This is the main function, basically it grabs the total and loaded bytes,
calculates a percentage, and displays it by stretching the bar and adjusting
the textfield display. If your bar/textbox instancenames are NOT lbar/lpc,
you'll need to adjust this code to match your instance names*/
function PL_LOADING(event:ProgressEvent):void {
var pcent:Number=event.bytesLoaded/event.bytesTotal*100;
//Stretch the bar
lbar.scaleX=pcent/100;
//Display the % loaded in textfield
lpc.text=int(pcent)+"%";
//If the movie is fully loaded, kick to the next frame on the main timeline
//You may wish to change the gotoAndStop(2) to a gotoAndPlay(2)
if(pcent==100){
this.gotoAndStop(2);
Thanks to anyone who helps.use:
//Import the required assets
import flash.display.*;
//Stop the playhead while loading occurs
this.stop();
//Create a listener to call the loading function as the movie loads
this.loaderInfo.addEventListener (ProgressEvent.PROGRESS, PL_LOADING);
this.loaderInfo.addEventListener(Event.COMPLETE,loadCompleteF);
function loadCompleteF(e:Event){
this.gotoAndStop(2);
/*This is the main function, basically it grabs the total and loaded bytes,
calculates a percentage, and displays it by stretching the bar and adjusting
the textfield display. If your bar/textbox instancenames are NOT lbar/lpc,
you'll need to adjust this code to match your instance names*/
function PL_LOADING(event:ProgressEvent):void {
var pcent:Number=event.bytesLoaded/event.bytesTotal*100;
//Stretch the bar
lbar.scaleX=pcent/100;
//Display the % loaded in textfield
lpc.text=int(pcent)+"%";
//If the movie is fully loaded, kick to the next frame on the main timeline
//You may wish to change the gotoAndStop(2) to a gotoAndPlay(2)
if(pcent==100){
this.gotoAndStop(2); -
Hi,
I upload a website and I have problems with the preloader did it in AS3. It starts after two or three minutes. I have a MC with an animation of 100 frames and the dynamic text of the percent. The preloader is located in the 1 frame to the 10, I mean, first frame with the actions and the other three layers (text, MC and background) with a lenght of 10. The movie has 525 frames. Here is the code:
stop();
addEventListener(Event.ENTER_FRAME, lodeando);
function lodeando(event:Event):void
var bytesTotales = stage.loaderInfo.bytesTotal;
var bytesCargados = stage.loaderInfo.bytesLoaded;
var porcentaje = Math.round(bytesCargados * 100 / bytesTotales);
textoPorcentaje.text = porcentaje + "% Cargados";
cargaAnimada_mc.gotoAndStop(porcentaje);
if (bytesCargados == bytesTotales)
removeEventListener(Event.ENTER_FRAME, lodeando);
gotoAndPlay(2);
textoPorcentaje.text = "";
removeChild(textoPorcentaje);
removeChild(cargaAnimada_mc);
Please, Could you help me?.These screen captures show the library of the movie. As you can see I export the most of them. However I have doubts about if I must convert to symbol the graphics. I have the preloader in the "presentación" folder without any exportation.
Please, Could you correct the website?. Please, tell me an e-mail address and I send you the website via WeTransfer. -
Hi to everyone ....
I use this preloader in several of my professional works and it's cool ... but in futures works i'll need't in AS23. ¿Is there a way to converted (or make it) in AS3?.
Otherwise is there a web site where i can find cool flash preloaders ???
Thanks ...It's more likely you'll get help when you don't require people to do research. If you can describe how your current preloader is designed and show the code it uses you'll be helping others to help you.
-
Hi,
Is there a surestarter preloader in AS3 with CS4? Meaning here, showing a progress bar or percentage value before loading the main swf, right away at the start of the loading.
I tried 3 different versions:
1- I used the code from a video (and accompanying files), and simply changed the content.swf to my own swf file (rename my swf content.swf), so that the original code would load my swf instead of the original content.swf. (original content.swf was too small to see anything before loading, because my loading speed is too fast).
Here is the code from the original preloader (loads a small swf which then loads the main swf file):
var l:Loader = new Loader();
l.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loop);
l.contentLoaderInfo.addEventListener(Event.COMPLETE, done);
l.load(new URLRequest("content.swf"));
function loop(e:ProgressEvent):void
var perc:Number = e.bytesLoaded / e.bytesTotal;
percent.text = Math.ceil(perc*100).toString();
function done(e:Event):void
removeChildAt(0);
percent = null;
addChild(l);
and here is the link to the file:
http://www.raidcanada.com/preloader-org-test.html
2- used the code suggested, which does the preloading directly in the main swf file:
stop();
//Import the required assets
import flash.display.*;
//Stop the playhead while loading occurs
this.stop();
//Create a listener to call the loading function as the movie loads
this.loaderInfo.addEventListener (ProgressEvent.PROGRESS, PL_LOADING);
/*This is the main function, basically it grabs the total and loaded bytes,
calculates a percentage, and displays it by stretching the bar and adjusting
the textfield display. If your bar/textbox instancenames are NOT lbar/lpc,
you'll need to adjust this code to match your instance names*/
function PL_LOADING(event:ProgressEvent):void {
var pcent:Number=event.bytesLoaded/event.bytesTotal*100;
//Stretch the bar
lbar.scaleX=pcent/100;
//Display the % loaded in textfield
lpc.text=int(pcent)+"%";
//If the movie is fully loaded, kick to the next frame on the main timeline
//You may wish to change the gotoAndStop(2) to a gotoAndPlay(2)
if(pcent==100){
this.gotoAndPlay(2);
This one doesn't work either, and if you refresh the page, you get only the bar, instead of refreshing the main swf.
http://www.raidcanada.com/test/test-2.html
3- use the code suggested to replace the preceding version:
stop();
addEventListener(Event.ENTER_FRAME,checkLoad);
function checkLoad(e:Event):void {
var pcent:Number=this.loaderInfo.bytesLoaded /this.loaderInfo.bytesTotal*100;
lbar.scaleX=pcent/100;
lpc.text=int(pcent)+"%";
if (pcent==100) {
removeEventListener(Event.ENTER_FRAME,checkLoad);
this.gotoAndPlay(2);
This one loads correctly (without the percentage or progress bar) and the refresh is OK.
http://www.raidcanada.com/test/test-1.html
The idea is to have this page load correctly showing a percentage sign and a progress bar until the loading is complete for this page:
http://www.raidcanada.com/entete-multi-hiver-1-test.html
Every time I test the swf directly in Flash CS4 with the simulated download, I get the progress bar and percentage correctly.
I also tried with Firefox and get the same results.
FLAs are at:
http://www.raidcanada.com/test/test-1.fla
http://www.raidcanada.com/test/test-2.fla
and screenshots of FLASH (showing the progress bar in "test movie" with simulated download):
http://www.raidcanada.com/test/screenshot-test-1.jpg
http://www.raidcanada.com/test/screenshot-test-2.jpg
Am I missing something?
THank you in advanceHi,
I am using Internet Explorer 8, version 8.0.7600.16385 with Windows 7 Ultimate or Firefox 3 version 3.5.9
If I flush the cache and load the page:
http://www.raidcanada.com/entete-multi-hiver-1-test.html
It takes about 5 seconds with a blank screen before I get the main swf displayed.
If I load the page: http://www.raidcanada.com/test/test-1.html
It takes about 1 second with a blank screen before I get the main swf displayed. The main swf file is much smaller.
I also did a lot of tests, and still the same problem. Temporarely, on the production site, I ended up installing a static Image saying "Loading", without the code, which then loads the large swf. But some customers are seeing the "Loading" for 14 sec to 24 seconds, depending of the swf file.
I know the code suggested is probably working with CS3 and AS2, but I need to make it work with CS4 and AS3, because my other code is all in AS3, built with CS4. As I said before, if I make a simulation, the simulation is perfect.
Thanks -
AS3 Preloader matching stage.stageWidth (simple)
Hello,
Experimenting with Flash as usual.
Preloader's are always something that have caused me trouble.
Here's what I typically use for a timeline based preloader in AS3:
this.addEventListener(Event.ENTER_FRAME, loading);
function loading(e:Event):void {
var total:Number = this.stage.loaderInfo.bytesTotal;
var loaded:Number = this.stage.loaderInfo.bytesLoaded;
loadBar.scaleX = loaded/total;
loaderText.text = Math.floor((loaded/total)*100)+ "%"; (if percentage text is wanted)
if (total == loaded) {
gotoAndPlay(3);
this.removeEventListener(Event.ENTER_FRAME, loading);
This works perfectly well, but isn't that pleasing aesthetically.
I'm really interested in a preloader that loads right across the stage however - regardless of if the stage is resized.
I should imagine it'll involve implementing = Math.round(stage.stageWidth); at some point?
If anybody knows how this is achieved, through actionscript, in the timeline, I'd really appreciate the support
Thanks a lot!I haven't been able to make this work straight away with this code:
var lbW:Number
var stageW:Number
var ratioNum:Number
resizeF(null);
stage.addEventListener(Event.RESIZE,resizeF);
function resizeF(e:Event){
lbW = loadBar.width
stageW = stage.stageWidth
ratioNum = stageW/lbW;
this.addEventListener(Event.ENTER_FRAME, loading);
function loading(e:Event):void {
var total:Number = this.stage.loaderInfo.bytesTotal;
var loaded:Number = this.stage.loaderInfo.bytesLoaded;
loadBar.scaleX = ratioNum*loaded/total;
if (total == loaded) {
gotoAndPlay(2);
this.removeEventListener(Event.ENTER_FRAME, loading);
But I shall explore and try and fix it.
Thanks so much for your time and expertise!
Really do appreciate it! -
Preloader not working in AS3 when viewing in a browser
Hi there, It's me again Ysong.
I have a problem regarding PRELOADING.
MY TIMELINE:
• First frame -- dynamic text which is my preloader with AS3 in it. NO MORE OBJECT in the frame only text which is dynamic.
stop();
loaderInfo.addEventListener(ProgressEvent.PROGRESS, updatePreloader);
function updatePreloader(evtObj:ProgressEvent):void
var percent:Number = Math.floor((evtObj.bytesLoaded*100)/evtObj.bytesTotal);
myLoadText.text = "Loading..." + percent+"%";
if (percent==100){
nextFrame();
• Second frame -- the whole site in MOVIE CLIP which will be loaded after the preloading ends.
***The whole SWF file is only 600KB when publishing.
***When simulating download the preloader is working.
MY PROBLEM:
Whenever I uploaded these two files: (1) index.swf and (2) index.html, the preloader doesn't work. When viewed in browser it apprears to be white screen. After a couple of minutes, the index.swf appears and the preloader is not appearing as it should be. With (2), I didn't change anything on Dreamweaver just upload the file published by Flash Professional CS4.
WHAT IS THE PROBLEM? Can anyone help me with this. I've uploaded (PUT) the files through Dreamweaver with a testing server configured.
Thank you & Regards,
YSONGhi Ned,
I currently downloading the tutorial link you posted.
Do you have any idea what is really happening? Because I really wanted to have a loading text only before the whole site is loaded. The SIMULATED DOWNLOAD in Flash CS4 is working great but whenever copy it in my hosting server and view it in my browser the preloader is not working.
Thank you for your immediate response.
Regards,
YSONG -
Please help with this script, AS3 to AS2(preloader)
Hi. Ive made a flash banner for my client. It have two scenes, preloader (with percentage and animation (in 100 frame)) and the main scene. Preloader uses AS3. I need this convert to AS2. How to do this? The code:
import flash.events.ProgressEvent;
function update(e:ProgressEvent):void
var percent:Number = Math.floor( (e.bytesLoaded*100)/e.bytesTotal );
if(preloaderMC is MovieClip){
preloaderMC.gotoAndStop(percent);
preload_txt.text = String(percent) + "%";
if(percent == 100){
play();
loaderInfo.addEventListener(ProgressEvent.PROGRESS, update);
// Extra test for IE
var percent:Number = Math.floor( (this.loaderInfo.bytesLoaded*100)/this.loaderInfo.bytesTotal );
if(percent == 100){
nextFrame();
stop();
The full FLA: http://www.agroinvent.eu/briklis.fla, if someone can repair(make) it, pls send me the corrected fla file.
BIG THANKS. BEST REGARDS. Zoleeuse:
var tl:MovieClip=this;
function update():Void
var percent:Number = Math.floor( (tl.getBytesLoaded()*100)/tl.getBytesTotal() );
preloaderMC.gotoAndStop(percent);
preload_txt.text = String(percent) + "%";
if(percent == 100){
clearInterval(preloadI);
tl.play();
clearInterval(preloadI);
preloadI = setInterval(update,100);
stop(); -
Flash CS5 preloading before frame 1
Hi all
Im having a nightmare with a preloader in as3 and cs5. No matter what happens, flash displays its own preloader (ie 5 little circles at centre stage) and loads the whole flash file before it gets to frame 1. does anyone know how to stop flash doing this so i can use my own preloader. Im hoping that its an easy fix
Kind Regards DaveThanks for the quick response, one thing I dont understand though, if I remove all functions with duplicate names, what do I replace them with? or what do I do to get the same results? All I want to do is get 3 contact forms up and running, what other function names could be used? Please help, thanks...
-
When opening the website, the Flash movie is so slow to upload.
Why is it that the flash animation is so slow to upload to the site...Is this something I need to do or something to discuss with the server folks at Godaddy?
If you just have one SWF file, then you might want to try this tutorial http://www.republicofcode.com/tutorials/flash/as3preloader/
Basically, you will be monitoring the bytesLoaded of bytesTotal
var total:Number = this.stage.loaderInfo.bytesTotal;
var loaded:Number = this.stage.loaderInfo.bytesLoaded;
Or try to search other tutorials with keywords "preloader" and "AS3". If you encounter any problems, feel free to ask. -
Flash CS4/AS3 - How to use a preloader with FLVs?
Somehow I've had a really hard time finding a straightforward forum answer or tutorial for this--maybe someone can help?
I have an SWF file that references/loads an external FLV file (www.44designs.com/promo_video.php), but since the FLV file is about 9MB and can take time to load on a slower connection, I think a preloader (something simple like "LOADING...100%") would be a good idea as the FLV loads.
Anyone have a simple way to do this?? I've had no success in finding what I need--just scripts for loading SWFs. You can see an example of this on www.44designs.com where a preloader script I've got seems to be referencing the SWF (thus loading almost immediately) instead of the much larger external FLV. Make sense? I'm not super AS3 savvy, but I can follow logic and cut and pasteGreat info, thanks for the post!
-
Help! - as3 IE preloader issues
Ok,
So, I work for the NPS, and they have an outdated CMS. I have no rights to upload an .html file, or edit one that the CMS makes.
SO, I am forced to use their little deal to display my .swf files.
Problem:
http://www.nps.gov/glca/photosmultimedia/ehikes.htm
I made an eHike in as3 Flash CS4. It has two scenes, the first scene is the preload, second is splash content and ehike content. The problem is I cant get the preloader to display in IE. I have all actionscript content exported to the second frame, as talked about here:
http://www.senocular.com/flash/tutor...preloaderstart
and it works fine in firefox.......
GRRRR....
I have tried many different ways to load the preloader..... Here is what I'm currently using....
there is a simple text field for the percentage, and a simple 100 frame animation. preloader_mc
stop();
var preLoaderPercent:Number = 0;
addEventListener(Event.ENTER_FRAME, loadComplete);
function loadComplete(e:Event):void {
if (this.loaderInfo.bytesLoaded == this.loaderInfo.bytesTotal) {
removeEventListener(Event.ENTER_FRAME, loadComplete);
this.loaderInfo.removeEventListener(Event.COMPLETE, loadComplete);
this.loaderInfo.removeEventListener(ProgressEvent.PROGRESS, loadProgress);
gotoAndPlay("splash", "content");
}//loadComplete
this.loaderInfo.addEventListener(Event.COMPLETE, loadComplete);
this.loaderInfo.addEventListener(ProgressEvent.PROGRESS, loadProgress);
function loadProgress(e:ProgressEvent):void {
preLoaderPercent = e.bytesLoaded / e.bytesTotal;
load_txt.text = Math.ceil(preLoaderPercent * 100) + "%";
var animstop:Number = Math.floor(preLoaderPercent*100);
preloader_mc.gotoAndStop(animstop);
The CMS lets you decide in the popup window if it is resizeable or not. This works in IE (stopping people from resizing), but not in firefox, people can resize it. Is there any way to disable the resize in AS3? Again, I understand that your supposed to export the .html file with these settings, but I have no permissions to upload or create new .html files.
Anyone who will help me with this - Thanks
DavidThe problem is talked about here:
http://stackoverflow.com/questions/460677/serving-raw-swf-files-displays-in-firefox-but-no t-in-ie
Solution was to preload with an external .swf
Cheers -
Flash CS5 AS3 Preloader Issues
Hi.
I'm a complete novice with Flash and at risk at looking like 'Dumbest Poster of the Year', I'm requesting help/advic over a couple of issues.
My first concern is with a very simple preloader I've made for a movie. Here is the code (posted in first frame of movie; nothing else is in the frame except for the preloader itself):
import flash.events.Event;
stop();
addEventListener(Event.ENTER_FRAME, loaderF);
function loaderF(e:Event):void{
var toLoad:Number = loaderInfo.bytesTotal;
var loaded:Number = loaderInfo.bytesLoaded;
var total:Number = loaded/toLoad;
if(loaded == toLoad) {
removeEventListener(Event.ENTER_FRAME, loaderF);
gotoAndPlay(2);
} else {
PreLoader.PreLoaderFill.scaleX = total;
PreLoader.PercentLoaded.text = Math.floor(total*100) + "%";
When I simulate a download, the preloader works fine in all the settings except for 'T1'. On this setting, the movie loads to about 20% then the preloader stops, the movie begins and I receive the following error message in the output panel:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at FlashFront1_fla::MainTimeline/loaderF() .
The movie itself plays fine on all settings, including 'T1'. Debug doesn't report any issues on preloader or movie.
Can anybody give me any idea what the source of the issue is? Should I even be concerned about it givne that the movie plays without a problem?
My second question relates to the 'Simulate Download' pre-settings in Flash. I know their are people out there still on 56K dial-up, or with 'broadband' running at 500 KBS (in the UK at least), but nevertheless, the download simulation settings seem like they are all geared to internet as it was in 1997 and are hardly reflective of the capacity of modern connections. Why is this?
My movie is not large (about 320KB). Should I even be bothering with a preloader or am I wasting my time for a small minority audience (much like the web designers who still produce sites for the 12 people in the world still browsing in 800 x 600 res)?
Thanks for any help/advice.Flash movies stream down and finish "loading" when the first frame and content that loads on the first frame is available, though frame 1001 might not be downloaded yet. You would think you'd be kinda safe with frame 2 on a T1, but I think the issue is things aren't updating in the right order rather than things not really being downloaded. Heck, it could even just be the T1 simulation that's causing problems.
Debug Movie probably isn't showing issues because it slows the timing enough to make everything ok. You could try trace statements too to see how far the code gets.
Also, you might try a full scale AS3 loader like this one http://www.republicofcode.com/tutorials/flash/as3loader/
I've found the Event.COMPLETE listener for the loader like this:
my_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, finishLoading);
to be pretty accurate so far in regards to content truly being loaded where as previous methods gave false positives for loading. -
My project originally had everything on the timeline, but I have since moved all the code to the document class, but some of my assets are still in the library and some of them are embedded. I'm trying to make a self-preloader that doesn't use any external files, but I can't seem to find a good tutorial that doesn't involve using the timeline. Can anyone point me to a pure AS3 self-preloader tutorial or tell me where I'm supposed to put everything?
If you mean by "self-preloader" a pure Standalone as3 preloader:
var l:Loader = new Loader();
l.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loop);
l.contentLoaderInfo.addEventListener(Event.COMPLETE, done);
//this line has to be adapted to the name of your document class
l.load(new URLRequest("main.swf"));
function loop(e:ProgressEvent):void
var kBytesLoaded:int = Math.round(e.bytesLoaded/1024);
var kBytesTotal:int = Math.round(e.bytesTotal/1024);
var perc:Number = kBytesLoaded / kBytesTotal;
trace("PERCENT:"+perc);
function done(e:Event):void
//this line for the stuff you might need to visually communicate the loading process and want to remove when loading is done
removeChildAt(0);
addChild(l);
Maybe you are looking for
-
Adding a new value to messagechoice field.
I have a field called messagechoice type . I have 4 drop down list values in messagechoice type , my requirement is , I have to delete existing one and need to add a new value in drop down list. how to achieve this . please do the needful help. thank
-
I have been trying to make room on my C drive and have been removing stuff I don't use. I have version 3.6 Firefox but my settings show I also have 3.5 which shows over 2,000 megabytes of disc space being used. I try to remove it but nothing happens,
-
no details to add
-
HI, I am getting an error in my out bound message. When i checked in IDX5 ,I am Geeting the Outbound messages displayed there with same error" In SXMB_MONI the error is in "Out bound status "there it shows a red flag. over all sucess flag is shown. "
-
ArchWiki Atom/Rss feeds in specific language
ArchWiki has atom/RSS "Recent changes" feeds. How can I get feed of recent changes made in specific languages only? For example feed of recent changes in English topics and another feed of recent changes in Russian topics. Without changes in Italian,