How can I create a preloader which does this? I have seen many examples of code to load an external swf, but never something that loads itself.
Thanks for the help, this is driving me crazy...
It's really simple. First you need to move everything except the preloader off the first frame.
Everything else is basically the same as an external preloader - the only difference is that you're checking the current and total size of the current movie, rather than a separate one.
alternatively ...
You can try FlashDevelop's Preloader template, makes it really easy
Related
I have an external SWF file loading perfectly fine to my Flash site. However, once the frame has been viewed, it carries on running in other frames when I only want it to play on frame 6. Any suggestions would be great. Thanks in advance.
Are you using a ViewStack? Make sure everything's embedded specifically into the right child of the ViewStack. If that's not the problem, edit your answer (don't just comment) so as to take the code you mentioned in your comment, and not only show that, but also the code whose greater context it falls under (like the scope of the URLRequest).
I have two external .swf's. I need to have the first one played on load and then the second swf needs to be played over the first one after a timer.
If someone could help me out with a code I would greatly appreciate it!
(note: I'm not that good with actionscript, so bear with me)
Set up a timer, on timer event create a Loader object with the URL of the second SWF (it can only be loaded from the same server the parent SWF gets loaded) and add it as a child of the parent SWF.
The code examples are easily found on google, like this one:
http://kb2.adobe.com/cps/141/tn_14190.html
I am Working on a cs5 as3 project and in that project i have writen all code in the frame1 of main timeline (there is no package/class in the code)
The code in the main timeline is very complex in which i am loading external images and xml's and many more things .
i have not written any code in the action layer.
Now i want to add Preloader .
how can i add Preloader in this situation ?
here is a snapshot of the timeline :
Move everything to the second frame, and add your preloader code/content on the first frame
http://www.google.ca/search?q=preloader+code+as3
The real issue here is the number and size of external assets you're loading, it may have been worth considering loading some of these assets separately. In this way, your preloader would have been more accurate. However complex your code is , the loading of the assets is the main element to delay the start of your application.
With your current configuration , if you'd encapsulate the loading of some of the assets (as you may not need all of them right from the start) , you would have been able to directly create a preloader within the code as is , without a DocumentClass, simply by loading assets as your first function and calling an init() method after the loading is complete.
I'm having some difficulties with preloader and assets.
I'm working with FlashDevelop so pure AS3/Flex, no FLASH IDE
The thing is : when I try to addChild() something like a swf or event a simple png/jpg it kills the preloader completly (blanck screen until the game is fully loaded, then the preloader is launch (but the game is already loaded) so one frame later I'm after the preloader.
I think I missed something in the logic behind the management of the famous "first frame" and the loader progress event.
If someone have any idea about what I'm talking about. I'd like some light about the subject ^^
Thx !
-UPDATE-
I re-searched for more informations and found this post :
How does the preloader work in as3?
MichaelJW points my problem but doesn't answer it :
"You can do whatever you like in a preloader, but it won't run any of its code until everything needed by the preloader has downloaded. So if you make a preloader with a 3MB image file and a progress bar, the progress bar won't do anything until the entire image has downloaded!"
So how do you get to use some image to build a preloader ?
I have encountered this before and my "work around" was to build 2 separate loaders. The first is VERY light weight and loads all initial assets (like a rotating 5k png), the second if the "bulk load" of assets etc..
when the first is done loading it triggers the load of the second round of assets. You are right tho, you CANNOT use assets till they are loaded completely..
I'm loading some swf files at 0 on my stage. They are the pages of my site.
To change from page to page I use removeChildAt(0) and then I addChildAt("page_title", 0).
The problem is that removeChild dont delete the functions from the first swf file loaded (before unloaded).
How can I stop then?
Do I have to use other way to removeChild?
Thanx!
It sounds to me like you aren't actually removing them. First things first, removing something from the display list is only a visual/interactive change. It is still running until you remove any references to it, being event listeners or w/e, and then you must set it to null so that garbage collection will grab it on the next cycle.
If you are using Flash Player 10, spender is correct that unloadAndStop will work for you as they just recently created it to fix your very problem.
I just thought I should explain what is going on, because people should not only know about the fix, but why things happen.
One other suggestion, I wouldn't load these movies to stage, I would create a container Sprite/MovieClip to hold them, that way even if you add other things later, they are separated, clean, and easy to access through their parent (imageContainer_mc for instance).
Assuming you are loading with a Loader you can use the unloadAndStop method.
More info here:
http://www.gskinner.com/blog/archives/2008/07/additional_info.html
Alternatively, you can load the submovie into a different ApplicationDomain to insulate the loaded code from your main app. Take a look at the flash.system.ApplicationDomain class (it's a parameter to the Loader.load() method).