Load swf into RAM via an asset manager

Hi.
I have an AS3 virtual world and we are continually loading external resources such as swfs and sounds.
A few of my menu screens that take a damn long time to load. Read a tut that said we should load them into RAM using an asset manager.
I'm assuning the asset manager is simply a Class used specifically for loading and unloading graphics, swfs and sounds. So the important part to ask is:
What do they mean by loading into RAM.
I thought all swfs were automatically loaded into RAM ie: cached or in the flash player cache or the browser cache. Or do I have to do it specifically myself with some code. We are importing external files so we thought that was a great idea as they are shared by many games.
btw: RSLs I have read about but I don't understand. I thought my externally loaded files were RSLs (runtime shared libraries) or would I have to do some physical coding do convert them into RSLs.
This is so important because I am not very experienced but I am getting a lot better due to help receied in this forum and my current programmer is leaving me. I have been studying up on As3 and design patterns and I understand basic coding a lot better now.
CHEERS
EDIT: Just read that I am using a http call. - I use urlloader - well that's what you use isn't it or how would you load an external swf. Just read that you can hold the swf as a variable which loads it in RAM and therefore will be available immediately. Know I don't understand anything as I have never read that anywhere.

Hi Andrei, nice to see you around here.
Well, somebody helping me says that normally we make a http request with urlLoader to the server and that is what was happening each time. We weren't getting the cached swf. (that bit I don't understand and doesn't sound right - anyway...)
So he says if we create a dictionary class to hold that swf then the next time we make a request we will get the movie from there and not from the server.
I have highlighted the main parts of code below.
What I don't understand about all this is that I have never seen anything like this in my life. I have read extensively and read all about loading external files and using this type of asset manager with the dictionary class does not ring a bell and goole comes up with nothing.
I hunch is that as you say, we are doing something wrong somewhere because the only way to get an external file is via urlLoader to the server the first time and then the second time it should look for it cached on our computer is that right? Or when we make the urlLoader request how does it know to look on our computer first before going to the server or are these innner workings of the flash player I know nothing about. This is so important as when I get 10 kids on the computers they wait for as long as 5 minutes for movies that have already been downloaded many times before.
Cheers in advance.
package com.Gerry.managers.assetManager
    import flash.display.Loader;
    public class AssetLoader extends Loader
        private var _assetName:String;
        public function AssetLoader()
            super();
        public function get assetName():String
            return _assetName;
        public function set assetName(value:String):void
            _assetName = value;
The asset manager loading class
package com.Gerry.managers.assetManager
    import flash.display.Loader;
    import flash.display.LoaderInfo;
    import flash.display.MovieClip;
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.net.URLRequest;
    import flash.utils.Dictionary;
    public class AssetManager extends Sprite
        public static const ASSET_LOADED:String = "assetLoaded";
        private static var _instance:AssetManager;
        private var _assetsLoaded:Dictionary = new Dictionary();
        private var _assetsBeingLoaded:Dictionary = new Dictionary();
        public function AssetManager(pvt:SingletonEnforcer)
         * loads and asset and keeps a reference to the loaded content
         * @param name
         * @return null if the asset is not loaded yet
       public function loadAsset(name:String):MovieClip
            var asset:MovieClip;
            if (_assetsLoaded[name])
                asset = _assetsLoaded[name];
            else if (_assetsBeingLoaded[name] == null)
                var skinloader:AssetLoader = new AssetLoader();
                skinloader.assetName = name;
                skinloader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadCompleteF);
                skinloader.load(new URLRequest(name));
                _assetsBeingLoaded[name] = true;
            return asset;
        protected function loadCompleteF(e:Event):void
            var skin:MovieClip = e.target.content as MovieClip;
            var name:String = ((e.target as LoaderInfo).loader as AssetLoader).assetName;
            _assetsLoaded[name] = skin;
            delete _assetsBeingLoaded[name];
            dispatchEvent(new Event(ASSET_LOADED));
         * gets an instance of the class
         * @return
        public static function get instance():AssetManager
            if (_instance == null)
                _instance = new AssetManager(new SingletonEnforcer());
            return _instance;
internal class SingletonEnforcer
The function inside a class called Screen which is used by menus classes to load their swf menus.
protected function loadSkin(path:String = null):void
            trace("skin to load: " + path);
            Home.instance.addPreloaderF();
            _path = path + Home.instance.cacheString;
            if (_usingAssetManager)
                loadSkinFromAssetManager();
            else
                if (_skinloader.content)
                    _skinloader.unloadAndStop(true);
                _skinloader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadCompleteF);
                _skinloader.load(new URLRequest(_path));
        protected function loadSkinFromAssetManager(e:Event = null):void
            _skin = AssetManager.instance.loadAsset(_path);
            //if no skin we have to wait to be loaded it
            if (_skin == null)
                AssetManager.instance.addEventListener(AssetManager.ASSET_LOADED, loadSkinFromAssetManager);
            else
                AssetManager.instance.removeEventListener(AssetManager.ASSET_LOADED, loadSkinFromAssetManager);
                loadCompleteF(null);

Similar Messages

  • Loading swf into SWFLoader before it is added to a container

    I want to dynamically load a SWF file, before a particular view is created in a Flex 4.5 mobile app. Is it possible to load a SWF file into a SWFLoader before the SWFLoader is added to a container? I tried this but it didn't work.
    I tried doing this using the AS3 Loader class and movieclips, but when I compile for iOS this method does not work for me. Is there a way to do what I want?

    Hello,
    Firstly, why do you want to do this?
    Secondly, you cannot run runtime-loaded SWF files on iOS devices.
    By that I mean you can probably only use static SWF files like assets, but code inside them will not work.
    If you still want to load it, try inside the initialize event handler.

  • When time line reaches a certain frame load swf into movieclip.

    Hi,
    I need some help with some actionsscript. When the timeline reaches a certain frame, I want an swf to load into a movieclip in that particular frame. I need this to occur on level 1 as the root of the site is pre loader. Any help would be much appreciated. Cheers

    In that frame, on an actions layer, use either the loadMovie method or the MovieClipLoader.loadClip method to load the swf into the movieclip.  There should be examples of using either in the help documents and via Google.

  • Load SWF into empty movieClip?

    Hello,
    Could anyone please point me in the right direction to find
    out how to load an external SWF into an already existing movieClip
    instance that is already placed on the stage? This is the way I've
    always worked in AS2, but I can't find how to do it in AS3. Can
    anyone point me to an example where URLRequest works with a
    specified movieClip instance?
    Thank you!

    I understand why you might think I was ignoring your advice,
    but this isn't the case. You're expertise is much valued and
    respected.
    My purpose for continuing to experiment with loading into a
    movieClip was an attempt to find an easy way to layer the SWF
    behind other elements, but as you know, although it works for this
    purpose, it doesn't allow control of the loaded SWF from the main
    timeline. For others struggling to learn as I am, here's a link
    where I found the answer to my question above:
    http://www.hostingforum.ca/776586-as3-controlling-loaded-swf.html
    The transition to AS3 is not as easy for some as for others,
    and there are new concepts to understand.
    Don't know what "nvm" means... curious, but might be better
    off not knowing ;) Thanks again for all the help you offer to all
    of us who are struggling.

  • Can't load swf into editable region

    Am using DW CS4 in W7 64.
    Have designed an html site with one page that has a swf to control dynamic content with php.
    All the pages are created based on one template and al is fine until I try to place the flash file in the editable area of the html page. It seems that no swf files can me placed in this or any other editable area of the page.
    When the swf is put in the follwoing error comes up "While executing object Tag in Flash htm, a JavaScript error occurred"
    Any one else had this issue? More to the point anyone found a work around?

    Cevema wrote:
    To test the theory, as I had previously loaded CS4 onto my old XP pro machine, following a fresh install of XP Pro, and as Dreamweaver had never been started on the is machine before, I then created a brand new page from the template and tried to load in a swf file, but got the same error message. For a fresh install this couldn't be a corrupt file. A friend also tried this on his machine and had the same result.
    I don't normally use either templates or SWFs, but I have just done a quick test in Dreamweaver CS4 on Windows Vista 32-bit. Dreamweaver inserted the SWF into an editable region without demur. It's definitely not a Dreamweaver bug.
    Did your friend use the same template?
    Since a JavaScript error is being generated, I suspect you have invalid code somewhere in your template, or perhaps you have given more than one element the same ID. Validate your page with the W3C validator (http://validator.w3.org/), and eliminate any errors it finds.

  • Loading swf into movieclip object

    I am trying to load a swf file into a movieclip object on the
    stage. The movieclip object is sized smaller than the screen, and
    placed in the middle. I have defined a loader with:
    var myMovieClipLoader:MovieClipLoader = new
    MovieClipLoader();
    then use it like this:
    _level0.myMovieClipLoader.loadClip("moviename.swf",
    _level5.movieclipinstancename);
    (the movieclip object is used in a swf loaded in level5)
    When I load the swf like this, the swf loads at the correct
    location according to where I have placed the movieclip object,
    however it "blows up" to fill the screen from that point down and
    across, ignoring the size of the movie clip object (the loading swf
    actually expands beyond it's created size to fill the screen,
    making all the graphics and text much larger than intended). The
    actual pixel size of the swf I'm trying to load matches the size of
    the movieclip object (1024x350 in a 1280x1024 screen).
    What is the magic setting or property that will tell the
    loading swf to honor the size of the movieclip object I'm loading
    into?
    Thanks for your help!
    Barb

    Something I've been working on:
    Place the following code in a new file <your project
    folder>\as\MovieContainer.as
    Then open the properties for the symbol you want to be your
    movie container
    Set the AS 2.0 Class to as.MovieContainer and give it a name
    (I named mine 'loader').
    To load the movie, simply call:
    loader.queueSWF('my.swf');
    Hope that makes sense. Basically, it's just a self contained
    class for loading into an object on the scene. It draws a simple
    progress bar on the center of the symbol when it's loading and it
    resizes the loaded object on init to conform to the size of the
    object on the stage. Why queueSWF? Well, if it's currently loading
    a SWF, it will wait till it's finished and load a new one. The
    biggest problem right now is the progress bar, but it's fairly easy
    to remove if you don't like it. Hopefully it helps.
    If anyone else is reading this. I'm trying to figure out if I
    can load these movies into an array of movieclips. So far I've had
    no luck. If you know of a way, feel free to drop some input.

  • Loading SWF into level and setting height/width/location?

    Hi folks, I am an old AS2 guy who gave up on Flash heavy coding when it switched to AS3. Always thought it was less intuitive, longer, and a brand new language and I got tired of trying to keep up when most of my clients did not want to pay for a full flash site. But I got this client...
    Here's the problem, I can load a swf into my main stage or into an MC , but I cannot find out anywhere how to set parameters or load into a level so it doesn't replace the current material or fix to a size that doesn't block my other material.
    I've gotten this far:
    import flash.net.URLLoader;
    import flash.net.URLRequest;
    loadGallery();
    function loadGallery():void
    var l:Loader = new Loader();
    var req:URLRequest = new URLRequest("shortstack.swf");
    l.load(req);
    l.contentLoaderInfo.addEventListener(Event.INIT, galleryLoaded);
    function galleryLoaded(e:Event):void
    addChild(e.target.loader);
    What i want to do is load shortstack.swf into level 5, say, and fix it to the bottom left corner of the stage, and set its height to 400px and width to 980. 
    I have a an MC on the stage at those exact dimensions called placeholderMC, but I cannot figure out a way to target it, and the tutorials I've read have to do with loading on CLICK (I want it to load on enterFrame), and none of them tell me how to set parameters, as I could in old AS2.
    FWIW, AS3 may be more powerful, but AS2 was easier to understand.
    TIA,
    Jeff

    http://www.adobe.com/devnet/flash/quickstart/display_list_programming_as3.html

  • How to load swf into a movie clip?

    i have an swf file i want to load into a movie clip within my
    flash file, i think im supposed to use loadmovie () instead of
    loadmovienum, can anyone help me out? thanks

    loadMovie("X",Y);
    Where x is: the url of the swf file you want to load.
    Where y is: the name of the movieclip you want to load it
    into. You must give the movieclip an instance name.
    For example, if I wanted to load '1.swf' into a movieclip
    with an instance name of "loaderclip," my code would be:
    loadMovie("1.swf", loaderclip);

  • Loading swf into swf in exact position

    It's very simple to load an external swf into a main swf with
    loadMovieNum("name.swf", 50);
    But how do I control the position of the loaded swf?
    Currently it just pops in the top left.

    Try loading your external .swf into a pre-positioned
    movieClip, for example myMovie.loadMovie("name.swf). If you do not
    want to do this you can position the loaded movie later in your
    application or onload by setting the x and y pos with some
    AS.

  • Load .swf into .swf with linked .flv

    Hi all,
    I'm trying to load swf-2 into swf-1, with swf-2 externally
    loading an .flv.
    When I go straight to swf-2, it works fine. And when I embed
    the flv in swf-2, and open swf-1, it works fine.
    It's only an issue when swf-2 is pulling the EXTERNAL flv.
    Any ideas?
    Thank you,
    Tracy

    are the files all in the same directory? if you load a swf 2
    in a swf 1, then the code used by swf2 to load the flv file would
    be executed as if the code was executed from swf 1 location. is swf
    2 and the flv in a different folder from swf 1?

  • Load swf into movieclip // play pause buttons

    I am going out of my mind trying to get this to work. I can do it in AS2 without a hitch - but not AS3.
    I just need to load an external swf file into an empty movieclip. Then I have 2 buttons play and pause that need to be on the top layer of the new movie and they need to play and pause the loaded swf file.
    I have tried a number of things and nothing is working. Please help.
    Thank you in advance.
    Shawna

    you can use:
    var ldr:Loader=new Loader();
    addChild(ldr);
    ldr.load(new URLRequest("yourswfthatyouwanttoload.swf"));
    addChild(yourplaybtn);
    addChild(yourpausebtn);
    yourplaybtn.addEventListener(MouseEvent.CLICK,playF);
    yourpausebtn.addEventListener(MouseEvent.CLICK.pauseF);
    function playF(e:Event){
    MovieClip(ldr.content).play();
    function pauseF(e:Event){
    MovieClip(ldr.content).stop();

  • Load swf into an instance

    In the first frame of my movie, I want to load a swf into
    'cwgmap' mc instance, which is inside 'thumbs' mc instance. I am
    attempting (with no joy!)
    thumbs.cwgmap.loadMovie("2014_map/thumbs.swf");
    Any ideas how I can achieve this? The action must be in the
    first frame of the movie - not attached to the mc itself. Driving
    me mad!
    many thanks

    Managed to fix the issue - the scripting was correct but in
    the wrong frame.
    Cheers!

  • Loading swf into container

    I have created a movie that loads several swfs through an
    empty container. I have tried changing file paths numerous times
    and I can't get the movies to play correctly. Actually, they did on
    our local testing server, but after uploading to the clients
    server, the problems began.
    My test page is:
    http://www.sumnerhomemortgage.com/test/index.html
    loader.swf initially plays part1.swf. Here is the code for
    that:
    loadMovie("
    http://www.sumnerhomemortgage.com/test/flash/part1.swf",
    container);

    Did you upload the FLV to the correct place?
    I downloaded part1.swf, opened it in Flash, and got the
    following error:
    Error opening URL '
    http://www.sumnerhomemortgage.com/test/flash/part1.flv'
    If I paste that URL into the browser I get a 404. I also
    tried it in:
    http://www.sumnerhomemortgage.com/test/part1.flv
    http://www.sumnerhomemortgage.com/part1.flv
    and got a 404 for all of them

  • Controling a loaded swf into movieClip

    help!!
    i have loaded a {slide swf} into a movieClip .. on stage ..
    using the
    var loader:MovieClipLoader();
    using a button movie clip the is embeded into a seperate swf
    file that is loaded in at run time
    but the {slide swf} is runing a Interval that i need to clare
    ... so is there a way to talk to swf file after you load it into a
    movie Clip how do you address that

    var kglad : Master = new Master();
    Kglad .onReply=function(){
    " you are on to somthing big [ only the second picture fade
    in and thats where it stop ] it deos not seem to bee loading any
    more ... but when you click the next _btn.
    the caption keep changing ... but pictures don't change
    "........ i am sending you a better view of what ihave
    done<<<<<<<<<<start... // create
    variables
    var x:XML = new XML();
    x.ignoreWhite = true;
    var urls:Array = new Array();
    var captions:Array = new Array();
    var captions2:Array = new Array();
    var whoIsOn:Number;
    //XMl function
    x.onLoad = function() {
    var photos:Array = this.firstChild.childNodes;
    for (i=0; i<photos.length; i++) {
    urls.push(photos
    .attributes.url);
    captions.push(photos.attributes.caption);
    captions2.push(photos
    .attributes.caption2);
    holder.loadMovie(urls[0]);
    caption.text = captions[0];
    caption2.text = captions2[0];
    whoIsOn = 0;
    //Load XML
    x.load("pics/kingslandMarks/lmlist.xml");
    // The Button envents
    previous.onRelease = function() {
    clearInterval(nInterval);
    if (whoIsOn>0) {
    whoIsOn--;
    holder.loadMovie(urls[whoIsOn]);
    caption.text = captions[whoIsOn];
    caption2.text = captions2[whoIsOn];
    next.onRelease = function() {
    if (whoIsOn<urls.length-1) {
    whoIsOn++;
    clearInterval(transitionI);
    transitionI = setInterval(transitionF, 50, wholsOn);
    caption.text = captions[whoIsOn];
    caption2.text = captions2[whoIsOn];
    function transitionF(index) {
    if (!fadedOut) {
    holder._alpha -= 4;
    if (holder._alpha<0) {
    fadedOut = 1;
    holder._visible = 0;
    } else {
    if (!loadStart) {
    holder.loadMovie(urls[whoIsOn]);
    loadStart = 1;
    if (!loadComplete) {
    if (holder.getBytesLoaded()>0 &&
    holder.getBytesLoaded()>=holder.getBytesTotal()) {
    holder._visible = true;
    loadComplete = 1;
    holder._alpha = 0;
    } else {
    holder._alpha += 4;
    if (holder._alpha>=100) {
    clearInterval(transitionI);
    /*next.onRelease = function() {
    clearInterval(nInterval);
    if (whoIsOn<urls.length-1) {
    whoIsOn++;
    holder.loadMovie(urls[whoIsOn]);
    caption.text = captions[whoIsOn];
    caption2.text = captions2[whoIsOn];
    var s;
    //Experimenting with auto play slide show
    var nInterval:Number;
    autoPlay();
    function autoPlay() {
    function neXt():Void {
    if (whoIsOn<urls.length-1) {
    whoIsOn++;
    holder.loadMovie(urls[whoIsOn]);
    caption.text = captions[whoIsOn];
    caption2.text = captions2[whoIsOn];
    if (whoIsOn == urls.length) {
    clearInterval(nInterval);
    whoIsOn = 1;
    function prEv() {
    if (whoIsOn>0) {
    whoIsOn--;
    holder.loadMovie(urls[whoIsOn]);
    caption.text = captions[whoIsOn];
    caption2.text = captions2[whoIsOn];
    auto.onRelease = function() {
    nInterval = setInterval(neXt, 2000);
    this._visible = false;
    sTop._visible = true;
    if (whoIsOn<urls.length-1) {
    whoIsOn++;
    holder.loadMovie(urls[whoIsOn]);
    caption.text = captions[whoIsOn];
    caption2.text = captions2[whoIsOn];
    sTop.onRelease = function() {
    clearInterval(nInterval);
    this._visible = false;
    auto._visible = true;
    //try to fade the movieClip holder
    function fade():Void {
    holder._alpha -= 5;
    if (holder._alpha == 20) {
    holder._alpha = 100;

  • Loading swf into empty mc in a html page

    Hello Flashers,
    I've set up a html page that contains a swf file with an
    empty movie clip in which I wish to load another swf.
    However I trie to do it, it just won't listen.
    Can anybody help me with this.
    Situation:
    html page (complete one, with tables etc.) contains main swf
    file (in a table) which contains an empty movie clip.
    Within the main swf there is a button which should load
    another swf file into the empty movie clip.
    What happens is that the external movie clip is loaded into
    level 0 of the main movie.
    It usualy works fine just with flash site but within the html
    page it results differently.
    Is it possible to get it right.
    Thanks
    Justin Time

    Urami, thanks for your interest for helping me ( and others,
    as far as I know )
    I'll try to explain it in more details ( although english is
    not my language)
    I've made a html page which contains a swf file ( theMAIN )
    in one table, other tables are filled with gif's, jpeg's etc.
    In the main movie - theMAIN - there is a empty movie clip
    with instance name "deder_mc" which is ment to accept loaded swf's.
    There is also a button with action ---- on release :
    _global.theMAIN.loadMovie("./swf_s/000_studioG.swf", "deder_mc");
    That means, when user click this button movie
    000_studioG.swf should be loaded into deder_mc empty movie
    clip.
    The movie 000_studioG.swf is located in swf_s folder in site
    root.
    _global.theMAIN = this;
    is a action script in a first frame of the main movie so it
    build a reference to it.
    I've done it before but site was built complete in Flash and
    I did not had any problems with loading external movies into empty
    movie clips. Not long before I've red somewhere(don't remember
    where) that this don't work in swf in a html page.
    But I live in a hope that I would be able to build a html
    site which contains swf which can load external movies into empty
    movie clips. So I am looking for solution.
    I hope it's enough information for you to tell me a solution
    if you know the right answer.
    Thank you.

Maybe you are looking for

  • How to count no of records returned from a query?

    Hello, I need to find out how many records displayed from a query without writing any other queries. i mean that. I have a query such as: query = "select * from users"; and the resultset for it is rs. and i need to display how many records fetched fr

  • New AIR game - Saturate: A bullet-storm survival shooter

    Hi all, I've been working for over a year on game with a publisher (not this game!), and it is still many months away from release.  In the meantime I was anxious to get something released to the public in the short term, so two weeks ago I started S

  • Unable to import or export ratings & labels from PC to MAC...HELP PLEASE!

    I want to copy my cache files from a PC with windows OS to a mac in order to keep labels, ratings etc visible in my mac. But, I can't manage this transfer successfully even though i've tried through tools>build and export cache. Can anyone tell me ho

  • I can't load an icon to my application running in my webserver

    why I cannot load an icon to my java application (jar application) that is running in my webserver. but the application is running just fine in my desktop. Need help on this. tnx in advance Nashstanley

  • Error:C+ 131 (Error message) material price will be negative

    Dear Team, While cancellation of GRN document system is showing the message like C+ 131 (Error message) material price will be negative. As per the analysis the concern Po was belongs to 2008 the material price was 85 MAP.Gooda receipt completed on 2