Making a preloader in AS 3.0
I'm trying to make a preloader in Actionscript 3.0 that shows
a increasing status bar as the main swf is loaded. Unfortunately,
when I try and do so, the swf loads all of the fla's sound files
that are linked to external .as class files BEFORE my preloader. If
I uncheck "Export in first frame" in the sound's linkage options, I
get hit with 'Invalid Sound' errors every time I try and
dynamically load the sound.
How am I supposed to get this working correctly? All sounds
must come from within the FLA. I cannot load external sounds or
external swfs with sounds in them. In actionscript 2.0, I had to
use a little cheat which involved putting all sounds inside of a
movieclip and placing it on frame 2. This doesn't seem to work in
AS 3.0.
I've stopped using document classes. A document class has to
load on the first frame, and anything it references will also load
on the first frame, and anything they reference will load on the
first frame, even if you set your linked library items and classes
to load on a different frame. For me, that makes document classes
useless. I have built pre-loaders that are separate .swf that load
and monitor the main .swf. A good reason to build a pre-loader
within the main .swf is reusing library art. Using another .swf
just for preloading is not always the best solution. I hope Adobe
and users don't forget that Flash is a multimedia application, and
maintaining file size/download times is very important. I'm hoping
in Flash 10 a document class can be set to load on a different
frame, until then I only use them during testing and alpha
builds.
Similar Messages
-
I've been following tutorials on how to put a preloader
before a Flash movie, but it's not working for me and I think I
know why, just not how to fix it.
My scene is already built, so I'm suppose to add another
scene and add that whole "ifFrameLoaded ("movie", 100)" thing. My
problem (I think) is that the movie scene is just one frame with a
movie symbol in that frame. So basically, my actionscript would be
("movie",1), but that doesn't work. So is there a way to tell it to
load the symbol instead of the scene? Or is there a way to "step
backwards" so that my movie symbol becomes a scene.
Please help! (Or let me know if this makes no sense).If I'm following the goal, I would think that the following line would be all you need, making use of the percentDone variable already available...
Preloader_MC.gotoAndStop(Math.round(percentDone*Preloader_MC._totalframes/100)); -
Preloader for a scrollPane?
hey all,
i'm loading a large (250k) movie into a scrollPane, and am
having serious issues trying to get a preloader to work in any
fashion. i've tried placing the preloader in the root level, but
the scrollpane forces the 250k to export on first frame to be
functional, thus making the preloader useless. i tries also to put
a preloader into the loaded 250k movie, but that made no
difference. is there a way around this, or are users just going to
have to wait on faith for the blank scrollpane to populate itself?
thanks,
morganonce again, i answer my own question. i found out that the
preloader wasn't working because the inherent nature of "Export for
ActionScript" necessary for amking a movie loadable into a
ScrollPane loads that content at the very beginning. if you go into
the publish settings for the Flash output and click on the Settings
button next to the ActionScript Version selector, you can set which
frame of the movie you want to expert frames for classes to. set
this to frame 3 (most preloaders take up the first two frames), and
suddenly the preloader functions fine. -
I've been searching for guides/tutorials, basically any sort of help in making a preloader for a game. Also looked through previous posts on this forum.
Whenever I have a preloader made without any errors and I click test movie (ctrl-enter), it skips the preloader and goes straight to my game's menuscreen. Fair enough, so I click simulate download, the window turns white, after that it turns grey with 3 or 4 dots blinking, as if it were a preloader, except not mine, after a while it goes into my games menuscreen again, completely bypassing the preloader.
A walkthrough for a simple preloader (just a percentage going from 0 to 100), some code I can copy-paste, anything to make it work, I've tried all I can think of.
/beg for help.that code's in frame 1 of your main timeline, correct? if yes, copy the trace output using the following and paste it here:
stop();
trace(this.currentFrame,this);
import flash.events.ProgressEvent;
import flash.events.Event;
this.loaderInfo.addEventListener(ProgressEvent.PROGRESS, onLoading);
this.loaderInfo.addEventListener(Event.COMPLETE, onComplete);
function onLoading(evt:ProgressEvent):void {
var loaded:Number = evt.bytesLoaded / evt.bytesTotal;
loadbarText.text = "LOADING: " + (loaded*100).toFixed(0) + "%";
trace(loadbarText.text);
function onComplete(event:Event):void {
this.loaderInfo.removeEventListener(ProgressEvent.PROGRESS, onLoading);
this.loaderInfo.removeEventListener(Event.COMPLETE, onComplete);
loadbarText.visible = false;
gotoAndPlay(2); -
Discuss: Preloading, How & When
This is a discussion about preloading with flash, not just
making a preloader that waits for the movie to load and then plays
it. This is about loading stuff behind the curtains and then using
it later, so the user doesn't even have to wait when they click
something.
Here is an article that talks about this, but from a slightly
different view than most of us are interested in, I think:
http://www.jonathanboutelle.com/mt/archives/2004/08/latency_must_di.html
From a technical perspective how do you actually preload
images/xml/swf/movies without using them directly? What is a good
way to plan, what and when to preload?
Only help I've found from adobe is this method of "parking"
swf:s
http://www.adobe.com/cfusion/knowledgebase/index.cfm?id=tn_15737
Got any better ideas than that?
Have you tried any solutions for this and how did it work
out?
Let's get some answers, experiences and opinions in
here!On my 55sl417u, you can just plug an optical cable from a port on the back of the TV into the receiver. The TV sends all of the sound down the optical cable. Then you just have to turn the volume on the TV all the way down. Pretty easy.
-
Preloading multiple dynamic images
I've searched this topic for hours with no luck. Basically I
have an XML file with a description and the url of multiple images.
When I play the flash movie the nodes of the XML are loaded into an
array and then each jpg is then loaded and attached to a movie clip
along with the description using a for loop. The problem I'm having
is that when making a preloader it only preloads one of the images.
OR if I use an external preloader, the swf file is preloaded but
none of the images are. Is there a way that I can preload all of
the images or preload each movie (with the image and description
attached) in the for loop? Thanks!How odd is that. The createEmptyMovieClip() method of the
MovieClip class was available in Flash 6 (Also known as Flash MX).
It is true that the MovieClipLoader class was not available until
MX04.
And as Kglad said, there is no way to load things without
loading them into some kind of target. So you can load into
movieclips that are hidden or something, but cannot load into
movieclips that don't yet exist.
I tend to think of this classic problem in a slightly
different way. To my mind the preloader isn't there to necessarily
show how many bytes have been loaded and how many remain. I tend to
think it is communicating that progress is being made –
variable internet traffic, server load, etc. can mean that the
datarate will fluctuate. So if you are loading several files that
are roughly the same size (say within an order or magnitude) just
advance the preloader for each file loaded.
Say you were loading 9 files total, then each file loaded
would be about 11 percent (file percent = 1 / total number of
files).
Just a different way of thinking about it. Maybe it will give
you some ideas. -
I get the RSL error everytime I try to export my .fla file. Is there ANY way I can fix this? I got quite alot textwindows, so I could really need help on making a preloader or find another way of fixing this?...
don't use tlf textfields unless you need them. if you do need them and you don't want to use a runtime shared library, click file/publish settings/flash/actionscript 3.0 settings/library path and select merged into code for your default linkage.
-
Revision: 4939
Author: [email protected]
Date: 2009-02-12 10:07:37 -0800 (Thu, 12 Feb 2009)
Log Message:
* Some changes necessary to get the improved SWC cache working in Flex
Builder 4 and some potential bug fixes.
tests Passed: checkintests
Needs QA: YES
Needs DOC: NO
Bug fixes: SDK-18905
API Change: NO
Reviewer: Pete F.
Code-level description of changes:
tools/oem/Library.java
Modified link() to pass the file name into SwcDynamicArchive's
constructor even when using an OuputStream, so the file name can
be used as a cache key.
Added refreshLastModified() so Flex Builder can update the
timestamp in the SWC cache after writing it's OutputStream to the
SWC file.
tools/oem/Builder.java
Added setSwcCache().
tools/PreLink.java
Modified postRun() to use the value returned from
ResourceContainer.addResource() instead of the value passed in,
because it could be different. This might fix SDK-18493 and
SDK-17840.
compiler/PersistenceStore.java
Modified readCompilationUnit() to also use the value returned from
ResourceContainer.addResource().
compiler/CompilerAPI.java
Modified updateDependentLastModifiedTimes() to check for a null
CompilationUnit.
compiler/swc/SwcDynamicArchive.java
Added path param to OutputStream based constructor to be used as a
cache key.
Ticket Links:
http://bugs.adobe.com/jira/browse/SDK-18905
http://bugs.adobe.com/jira/browse/SDK-18493
http://bugs.adobe.com/jira/browse/SDK-17840
Modified Paths:
flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/CompilerAPI.java
flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/PersistenceStore.java
flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/swc/SwcDynamicArchive.java
flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/swc/SwcGroup.java
flex/sdk/trunk/modules/compiler/src/java/flex2/tools/PreLink.java
flex/sdk/trunk/modules/compiler/src/java/flex2/tools/oem/Builder.java
flex/sdk/trunk/modules/compiler/src/java/flex2/tools/oem/Library.java
flex/sdk/trunk/modules/compiler/src/java/flex2/tools/oem/LibraryCache.javaI figured out what was going here. When I was statically linking my copy of textLayout.swc, it wasn't being loaded soon enough and the other parts of the framework were barfing because they couldn't get at the TextContainerManager class when they expected to find it. What I have done to solve the issue is created a custom SystemManager which forces the TextContainerManager class to be loaded sooner. This does increase my file size a bit, but not nearly as much as having to statically link all of the framework's libraries! Here is a short example app of what I did for anyone curious:
main.Main.as :
package main {
import spark.components.Application;
[Frame(factoryClass="main.CustomSystemManager")]
public class Main extends Application {
public function Main() {
super();
MainApplication.mxml :
<?xml version="1.0" encoding="utf-8"?>
<main:Main xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:main="main.*">
</main:Main>
main.CustomSystemManager.as :
package main {
import mx.managers.SystemManager;
import flashx.textLayout.container.TextContainerManager;
public class CustomSystemManager extends SystemManager {
public function Custom Manager() {
var c:Class = TextContainerManager; // force the inclusion of this class
super();
I found a lot of good information for using a custom system manager (in the context of making your preloader a bit shinier here: http://custardbelly.com/blog/?p=211 -
Problem with preloader and sounds
Hello everyone,
I am making a movie that has 12 sound files in it. I am
having trouble getting this to work with a preloader. I was using a
seperate flash movie and using the movieClipLoader to load in the
movie that has the sounds in it. However my employer wishes to have
everything in a single swf file. I know the concept, that the
sounds in the movie using attachSound need to be loaded before
first frame... but I need the preloader to take them into
account... how do I do that? I tried putting my preloader on frame
one, then had 12 keyframes in a row and just dragged the sounds
onto the stage (one for each keyframe there), and then the main
movie starts on frame 14... but that stil doesnt work... how can i
do this?Just to let anyone know... I did figure this out on my own...
it makes it messy though and I dont like it... buuuuut what are you
going to do... I had to set the linkage in each sound in the
library to export and then uncheck the export in first frame...
then i had to create keyframes for each sound and put it on the
stage in frames 2-13. Preloader on frame 1 and main movie on frame
14... it works now. -
Preloader Freezes, then 'Unresponsive Script' Warning
Hi folks-
This is my first Edge Animate project.
I have created a simple cross-fading 'slide show' with moving text overlays using the most recent upgrade of Edge Animate 3.0.0. 8 slides. The stage isn't that huge: 748x334 pixels. There is one .png overlay with a transparent interior to create the framing; the 8 slides revealed underneath are all Q50 'saved for web' jpgs averaging under 40kB each. I have used one of the simple preloaders in the included library and published for web.
My problem presents regardless of which browser I use (tried the latest versions of Firefox, IE, Safari, Chrome and Opera), and whether I run the published .html solo (hosted on my server), or embedded in the final web page it's destined for. Also, I get the same result when I use Ctrl-Enter from within Edge Animate to preview in my default browser (Firefox).
The problem is that the preloader gif only runs briefly, then freezes, followed by up to a minute of waiting (sometimes even more) before the first slide appears and the animation begins. Solo'd, it's just the frozen animated gif during the wait. Embedded in the final web page, the whole page, including navigation, is unresponsive until after the wait is over.
Depending on the browser, I will get various warnings. In Firefox I get the 'Unresponsive Script' warning and it identifies the unresponsive scripts as:
http://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js:4
Or
http://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js:5
Or
http://animate.adobe.com/runtime/3.0.0/edge.3.0.0.min.js:166
Or
http://animate.adobe.com/runtime/3.0.0/edge.3.0.0.min.js:45
Sometimes I've selected 'cancel script'; sometimes I've selected 'wait for script to finish'; it doesn't seem to matter which one I select. Sometimes it works immediately after making either selection; In some cases I get the warning message 2-3 times before it finally works.
I've tried both hosting the runtime files myself and on Adobe CDN. I've also tried 'Immediate' and 'Polite' for the preloader. It makes no difference.
I've also disabled all add-ons in Firefox and the result is the same, though it may take less time to recover from the freeze.
I ran a speed test and my current download speed is 13mbps, so I can't believe my paltry image files are taking this long to load...and even if they were, shouldn't the preloader continue to animate during the load?
Has anyone else seen this behavior? I sure am hoping for a solution~!
When I created something similar to this in Flash a couple years ago, it didn't even need a preloader it loaded up and ran so fast...
Quite Puzzled,
bOBhi bOB,
I know your post has been long time ago, however recently I'm having the same issue you had, except the errors messages you're getting, my preloader stays at the same point unless I hit reload page on the browser and finally loads it. Are you still having the preloader issue even with the most recent Edge Animate version?
Thanks,
Paco -
Sup buddies,
How can I control what images load on my project to save preload time and avoid loading all images, elements, divs not yet visible?
As the project grows in size the load time increases. How does one control not loading all images ,divs,elements etc. until they're
needed on the timeline? For example some sections are off and only become visible when recalled. My projects slowly grow in size so loading
all images , is counter productive . My other option would be to create separate htmls but that breaks the seamless user experience .
TY...Over N Out...hello, kiwi
quote: "Is there an easy way to burn a completed project to DVD, but keep only the (lo res, lo size) previews on my hard drive?"
yes.
maybe,...
1. you might think of making DVD backups first prior to importing the photos into Aperture. "Store Files: In their current location" once in Aperture make low rez Previews, and export finished Project.
or,
2. bring in the photographs to hard drive first prior to importing the photos into Aperture. "Store Files: In their current location" once in Aperture make low rez Previews, and export finished Project.
the low rez Previews will stay in Aperture but the high quality Versions will be exported onto DVDs and gone from the hard drive (if you delete the originals).
another way would be to export small about 50-70 pixel wide high quality jpegs to a folder on your Desktop and import & keep these in Aperture Library as a reference. make metadata to show where the original Project DVDs are stored and DVD filing system used.
victor -
Add An Enter Button To a Preloader
On my site I have 2 scenes and I'd like to add an 'Enter' button for moving from the preloader to the main site. How would I do that in this code?
stop();
preloader._width = 0;
preloader._visible = preloader_bg._visible = true;
preloader.onEnterFrame = function()
filesize_total = _root.getBytesTotal();
if( filesize_total == 0 ) filesize_total = 1;
percent = Math.round( _root.getBytesLoaded() / filesize_total * 100 );
txt = percent + "%";
preloader._width = percent * 3;
if( percent == 99 )
delete this.onEnterFrame;}
enter_btn.onPress
gotoAndPlay("flashmo_dream", "start");I don't know where you are getting these tutorials, but they sound like they are very, very old. Along with not using AS2, you shouldn't be using scenes. Scenes are a left over method from the very earliest versions of Flash.
The objective in preloading content is that you are loading in new content before the user needs it. If you are doing this loading well, the user will not know that the operation went on. Any sort of loading screen should only be seen if the user calls for content that has not loaded yet. Your design objective should be to show something to the user as quickly as possible when the user hits your site. Load in your additional content and then let the user experience your site.
If you create a button on the stage in the same frame as your preloader object and name that button "enter_btn", then the code that you've shown above should do what you want.
I haven't used AS2 in many years. I don't remember a lot about its syntax, but from what I read of your code, it looks like you are measuring the loading of the file that contains the preloader object. This methodology can lead to a problem. When Flash begins working, a certain amount of the movie has to load before anything is seen on the screen. This means that the loading telltale that you have set up in your code will never show "0%", and probably not even "50%".
Here's a good tutorial that uses AS3 and fully explains the code and how the loader operates: http://flashexplained.com/preloaders/basic-loading-bar-preloader/
Here's another: http://www.republicofcode.com/tutorials/flash/as3preloader/
And here's a third: http://flashexplained.com/preloaders/making-the-complete-internal-preloader-in-flash-8-wit h-a-loading-bar-and-mathematical-preloaders/
Take a look at those examples and compare and contrast their methods. -
Hi there,
I will first admit that I use director mostly for moving
sprites and playing sounds, but when it comes to the script, I
suck. I am good at other types of scripting, and I have the general
idea of how to get the formula of a script to fuction, but I can
never get it going 100%. I am in desperate need of a preload
script, I know It's a hassle to see these n00b requests all the
time, but if someone could look at my script and tell me where I am
going wrong, it would be a big help. I only need this script to
work then I can apply it to all my work. Thanks in advance! :)
Movie has 1900 frames.
Here is my script, in frame 1:
on exitFrame
preLoad 0, 1900
if preLoad(0, 1900) = true then
go to "a"
end if
end
It accepts the script, but when it runs it comes back with:
Script Error: Function not defined
if preLoad(0, 1900) = true then
All i want to do is have this preload set up in frame 1, to
load the total frames, then advance to frame 2 (with the marker "a"
is) where a "play" button is on the stage.
Regards,
TMK.Total-MK wrote:
> I just asumed this was the most lingo-basic way of
making a "loading"
> type preloader to load my full movie.
That isn't usually necessary as Director is usually good at
loading assets
as needed, and it isn't usually desirable to potentially fill
up the RAM on
the user's computer - indeed, unloading members when they're
finished with
can be very helpful.
If you're doing a Shockwave movie, google for "lingo
preloader". In
particular, the articles at lingoworkshop.com are useful.
Then in the google
results page click on "Groups" up near the top and have a
browser through
what's been written before in this ng.
HTH
Andrew -
Hello,
Basically I am creating a small image gallery which allows
the user to flick through images.
The images i have are orientated in different ways, some are
landscape and some are portrait. Some are larger or smaller than
others as well. Because of the differences in the size and layout i
am wanting to be able to handle each size differently, depending on
its "_height" and "_width" properties.
At the moment when i detect the height or width properties of
the image_mc movieclip using either:
trace(image_mc._height);
or
trace(image_mc._width);
I am not getting any properties for the first image and when
the second image loads the properties from the first image are fed
back to me.
I understand that the properties are probably not going to be
available as the code moves on quicker than the image loads.
What i am wondering is, is there a way of preloading an image
into a movie clip using the loadMovie function and then making the
code hang up until the image has loaded into the movie clip which i
have named "image_mc"? so that i can get the height and width
properties, so i can position and display the currently loaded
image correctly.
If this cannot be done with loadMovie, would it be possible
for you to suggest a better alternative for me please?
There is only one thing i need to keep. the images must be
loaded from an external file.
Thanks, i have attached my current code, its very basic but
it might help you understand what i have tried to explain.
thank you and any help will be greatly appreciated
thank you
Lee
PS. I am using AS2.0you can use listeners instead. For example:
-
Flash preloader freezes when refreshed in IE7
Ok, I know there are a lot of known issues with IE7 and
active content, but this is a new one to me, and I am really,
really hoping someone may know what is causing this...
I have a small online web site set up in HTML, but I have the
portfolio section set up in flash .swf, and naturally, there is a
preloader for this .swf file.
I already have a java script code to override the "click to
activate" issue with IE7, so that issue is taken care of. The
preloader works fine initially in all browsers and that includes
IE7, BUT if the user navigates away from the portfolio using the
top nav bar, and returns to the portfolio, the preloader freezes at
what looks like 99% as the image i used is completely colored in.
In order to advance, the user must then right click on the flash
movie and select "forward" to get to the frame containing the
content. This only happens in IE7, clicking links back and forth
does not create adverse effects in any other browsing setup.
I have the preloader set up on frame 1 of Scene 1 in multiple
layers, and i have the bottom layer labeled "content" where on
frame one, it is an empty keyframe, and then on frame 2 of that
layer I have the main_mc movie clip with all navigation and content
placed, and all layers above that have been converted to empty
keyframes on frame 2.
Here is the AS3 code I am using for the preloader on frame
one of the main stage:
stop();
this.loaderInfo.addEventListener(ProgressEvent.PROGRESS,
onProgress);
this.loaderInfo.addEventListener(Event.COMPLETE, onComplete);
function onProgress(e:ProgressEvent):void
var loaded:Number = e.target.bytesLoaded;
var total:Number = e.target.bytesTotal;
var pct:Number = loaded/total;
loader_mc.scaleX = pct;
loaded_txt.text = "loading portfolio..." + (Math.round(pct *
100)) + "%";
function onComplete(e:Event):void
gotoAndStop(2);
I have also tried:
function onComplete(e:Event):void
nextFrame();
but that has caused no difference with the issue.
Any Ideas, tips or tricks?? I am a recent graduate looking
for a job, and I feel like this issue has potential to hold me
back...thank you to anyone in advance.If your using javascript to ebmed the movie, try this
yourswfName.swf?t= new Date().getTime()
if php
yourswfName.swf?t= php echo date("Y-m-d H:i:s")
I call it a cache buster, you can make a function and have it
append to the swf file name. it is some caching issue with ie7 and
flash player 9 so your adding a timestamp to the end of the file
name, making the browser reload the video.
also if the video is already loaded, and the user comes back
to the page. It could be already loaded. Then there is no need for
the preloader. Mabey put something in your code that says if bytes
loaded == bytes total skip preloader and just play.
hope that helps ya
Maybe you are looking for
-
Problems setting up hotmail email account on Blackberry Pearl
I have had difficulty setting up my hotmail account on my pearl. whenever i enter my username and password (which i have checked millions of times to ensure that it is correct) and hit log in i get the message "please check your information and try a
-
ITunes store not loading with iOS 7 on iPhone 4S
iTunes store not loading with iOS 7 on iPhone 4S. I have tried reset network connections I have restored I have backuped I have erased all content I have rebooted I have DFUed. I have also the same issue with iTunes on pc, with -50 error. Is this an
-
Report on infoobject and infocube
hi, I need your suggestions in this scenario: There is a cube on which i have built a report showing characteristics A and sales amount.But if the characteristic A is not sold, then it doesn't have the sales amount.So, My report shows only the info
-
Moving BT Infinity modem and HH3 router to another...
Typically my master socket is in the dining room and all my IT kit is two floors up. Was using HH3 as Total Broadband in my loft with ethernet connection out to my Apple Airport Extreme which ran the network - everything hunky dory but I wanted fast
-
How do I change the language in Pages from American English to Finnish?
How do I change the language in Pages from American English to Finnish? I know there's a bunch of languages behind Inspector, but no Finnish there. Can I download it from somewhere? This is an American machine and an American OS X Mountain Lion.