Preload external swf before play

i have a project i am working on...but for some reason the solution i went with is not satisfying my instructor......
so....here is my new code ( which is incorrect but i cant figure out how to arrange the preloader at the end )
var Xpos:Number=0;
var Ypos:Number=0;
var swf:MovieClip;
var bgloader:Loader = new Loader();
var bgURL
if(page==1){
bgURL=new URLRequest("pages/home.swf");
else if(page==2){
bgURL=new URLRequest("pages/about.swf");
else if(page==3){
bgURL=new URLRequest("pages/projects.swf");
else if(page==4){
bgURL=new URLRequest("pages/experimental.swf");
else if(page==5){
bgURL=new URLRequest("pages/contact.swf");
bgloader.load(bgURL);
bgloader.x=Xpos;
bgloader.y=Ypos;
bg.addChild(bgloader);
stop();
var percent:Number = bgURL.bytesTotal;
if(percent==100){
gotoAndPlay("start");
first off, i dont even know if what i am being asked to do is possible...but, what i am being requested to do is obviously load in the external swf BUT, the external swf cannot play until the MAIN swf is directed to "start"......
i have done this numerous times in as1 and 2....but back then things were totally written different and if you do it the same way you run into migration issues....
i thought this was solved already, but my instructor will not accept the method of using an event to be dispatched in the external SWF to tell the main swf when to play "start"....im not sure if there is any other way to do this?
he wants the external swf to contain NO code other than what is necessary for its internal functions....
everything is to be coded in the MAIN swf.....
so im trying to use bytesTotal, and the percent==100 is just a number i threw in for example purposes.....i am just not figuring this out....
any help is greatly appreciated

From what I could gather based on your description, your instructor wants you to start playing when external swf is loaded completely.
If my understanding is correct, what you need to do conceptually is:
1. Instantiate Loader
2. Add event listeners that you are interested in.
3. Execute code corresponding to these listeners in their corresponding handler functions.
As for No 2 - Usually there are at least 3 events that are of interest when dealing with Loaders:
1. Event.COMPLETE - dispatched when entire target is loaded
2. ProgressEvent.PROGRESS - dispatched when a new bytes packet arrives.
3. IOErrorEvent.IO_ERROR - dispatched when something goes wrong with loading (say, wrong url, etc.)
In your particular case it is supposed to be something like this (may not work because you did not describe what is the point of different swfs loading and how it affects entire application). SEE COMMENTS:
stop();
var swf:MovieClip;
// always specify datatype
var bgURL:URLRequest;
if(page == 1) {
     bgURL = new URLRequest("pages/home.swf");
else if (page == 2) {
     bgURL = new URLRequest("pages/about.swf");
else if (page == 3) {
     bgURL = new URLRequest("pages/projects.swf");
else if (page == 4) {
     bgURL = new URLRequest("pages/experimental.swf");
else if (page == 5) {
     bgURL = new URLRequest("pages/contact.swf");
var bgloader:Loader = new Loader();
configureListeners();
// now you are ready to load
bgloader.load(bgURL);
* Adds listeners.
function configureListeners():void {
     // NOTE!!! Listeners are added to contentLoaderInfo - not Loader itself
     bgloader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoadComplete);
     bgloader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgress);
     bgloader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, onLoadError);
* Removes listeners.
function removeListeners():void {
     bgloader.contentLoaderInfo.removeEventListener(Event.COMPLETE, onLoadComplete);
     bgloader.contentLoaderInfo.removeEventListener(ProgressEvent.PROGRESS, onProgress);
     bgloader.contentLoaderInfo.removeEventListener(IOErrorEvent.IO_ERROR, onLoadError);
function onLoadComplete(e:Event):void
     // depeneding on the situation
     // you may want to add loaded swf
     // but before if swf exists - you need to remove it
     if (swf && this.contains(swf)) {
          removeChild(swf);
          swf = null;
     swf = bgloader.content as MovieClip;
     addChild(swf);
     // now play
     this.gotToAndPlay("start");
     // dont't forget to remove listeners
     removeListeners();
function onLoadError(e:IOErrorEvent):void
     // deal with the error
function onProgress(e:ProgressEvent):void
     // here you update preloader if you have one
     trace("Progress", e.bytesLoaded, e.bytesTotal);
On a side note, the way you deal with instnatiating URLRequests is not the most efficient or scalable. A better approach would be to keep them in an array and call by index. Note, conditionals are gone.
var bgList:Array = [
          "pages/home.swf",
          "pages/about.swf",
          "pages/projects.swf",
          "pages/experimental.swf",
          "pages/contact.swf"];
var bgURL:URLRequest = new URLRequest(bgList[page]);

Similar Messages

  • Preload extern swf results in weid behavior. It this normal?

    Hello,
    I tried to load an external swf file. In this swf file i have an embeded movie so that i see the preloader in action.
    What happens is, that while preloading i hear the movie playing in the background.
    So when the external swf is at for example 20% preloading the timeline is already playing in the external swf.
    Isn't that weird?
    I also noticed that the Event.INIT get's executed sooner for example at 17%  progress.  This should be at 100% is it not?
    And in CS3 i get the error while previewing the bandwidth profiler:
    Error #2044: Unhandled IOErrorEvent:. text=Error #2036: Load Never Completed.
    Does anyone know what is going wrong?
    Regards,
    Chris
    This is the code i use:
    package {
    import flash.display.LineScaleMode;
    import flash.display.DisplayObject;
    import flash.net.URLRequest;
    import flash.display.Loader;
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.events.ProgressEvent;
    import flash.display.MovieClip;
    * @author chris
    public class PreloadMain extends MovieClip {
    private var _loaderSprite:Sprite;
    private var _request : URLRequest;
    private var _loader : Loader;
    private var _myMovie:Sprite;
    public function PreloadMain() {
    addEventListener(Event.ADDED_TO_STAGE, init);
    private function init(event:Event):void {
    _request = new URLRequest("../swf/main.swf");
    _loader = new Loader();
    _loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loadProgress, false, 0, true);
    _loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadingComplete, false, 0, true);
    _loader.contentLoaderInfo.addEventListener(Event.INIT, loadInit)
    _loader.load(_request);
    drawLoader();
    private function drawLoader():void {
    trace("draw");
    _loaderSprite = new Sprite();
    _loaderSprite.graphics.lineStyle(1, 0x000000,1,false, LineScaleMode.NORMAL );
    _loaderSprite.graphics.beginFill(0x0000FF, 1);
    _loaderSprite.graphics.drawRect(0, 0, 150, 20);
    _loaderSprite.graphics.endFill();
    _loaderSprite.x = stage.stageWidth/2 -_loaderSprite.width/2 ;
    _loaderSprite.y = stage.stageHeight/2 - _loaderSprite.height/2;
    addChild(_loaderSprite);
    function loadProgress(event:ProgressEvent):void
        var percentLoaded:Number = event.bytesLoaded / event.bytesTotal;
        percentLoaded = Math.round(percentLoaded * 100);
      _loaderSprite.scaleX = percentLoaded/100;
       trace("loaded " +String(uint(percentLoaded)) + "%" );
        //this.percentLoaded.text = String(uint(percentLoaded)) + "%";
    function loadingComplete(event:Event):void
      removeChild(_loaderSprite);
      _myMovie = Sprite(_loader.content);
      addChild(_myMovie);
    _loader.contentLoaderInfo.removeEventListener( ProgressEvent.PROGRESS, loadProgress);
    _loader.contentLoaderInfo.removeEventListener(Event.COMPLETE, loadingComplete);
    _loader = null;
       trace("Load Complete");
    function loadInit(event:Event):void {
    trace("load Init");

    It is normal to receive Event.INIT before Event.Complete because on Init event you may access as3 on loaded swf, but the symbols of library may still downloading.

  • Preload external swf's

    Hi,
    Every time I have asked this question, people say , just go
    online you'll find lots of preloaders out there. Or, its documented
    really well in flash help. BUt I still dont get it. Im sure that
    anyone who knows actionscript moderately well can figure it out no
    prob.
    All I want to do is preload 3 external swf's into my main
    movie - and I want to include the preloading script in the
    preloading script I already have for my main movie. This is the
    script Im using (it has a loader bar etc,..).
    onClipEvent (load) {
    if (_parent.getBytesTotal() == _parent.getBytesLoaded()) {
    quickPlay = true;
    } else {
    preLoad = (_parent.getBytesTotal() * 0.75); //percent to
    preload
    _parent.stop();
    onClipEvent (enterFrame) {
    gotoAndStop(loadedIndicatorFrame());
    if (quickPlay == true) { //quickly play the anim
    if (_currentframe == _totalframes) {
    _parent.play();
    } else { //wait for the preload
    if (_parent.getBytesLoaded() >= preLoad) {
    _parent.play();
    Can someone help me out here?
    Also, if I preload it right at the beginning, do I need to
    additionally specify the place (empty mc) that I want to eventually
    run it in?
    Thanks a million for anyone who can help with this. Please
    dont tell me its well document\ed, because although it may, Its
    just as hard to figure it out with the documentation, Im not great
    at action script.

    I'm having a similar issue!
    I am currently building a web gallery that loads external
    .swfs (of each gallery) into movie clip containers within seperate
    frames.
    Is there any way to preload those .swfs in the background
    before they are called upon by going to those frames?
    An example of a site I built in this manner can be found
    here:
    http://gillestoucas.com/
    Help! Thanks a bunch!

  • Preload External swf files

    I am trying to create a website that has a main swf file that
    loads several external swf files into itself.
    I would like the preloader not only to preload all of the
    "main" content, but also the content that exists inside the
    external swf files before proceeding to the main user interface.
    Any help that you could give, addresses to a tutorial would
    be much appreciated.
    Thanks in advance.

    You could load each movie using movieClip.loadClip(); and
    check it has been loaded by using a listener and the
    "myListener.onLoadInit" script to write your own function to begin
    the playhead for that movie.

  • External SWF only plays first few frames then loops

    Help!  I've been working on this for the past few weeks.  Have read everything I can read.  Have tried everything I that has been posted.  And still I can seem to get a simple external swf to load and play using AS3.  I have tried numerous ways with the same results everytime.  Here are a few of the scripts I have tried.  What I would like to have happen is to have one main timeline where I load sequentially external SWF files - there is no interaction required - it is a presentation that includes video and other Flash SWF files that I have created.  Now I just want them all in one flash file.  I had no problems with AS2 doing this, but I'm sure having fits with AS3!  please HELP - my deadline is this week and I'm not even close to being ready.  THANKS!
    var myLoader:Loader = new Loader();                   
    var url:URLRequest = new URLRequest("script1_3.swf");                                  
    addChild(myLoader);
    //var begin:MovieClip;
    //var beginLoader:Loader = new Loader();
    //beginLoader.contentLoaderInfo.addEventListener(Event.INIT, beginLoading);
    //beginLoader.load( new URLRequest("start1_3.swf") );
    //function beginLoading(evt:Event):void {
    //thisMovieClip = MovieClip(beginLoader.content);
    //stage.addChild(thisMovieClip);
    //thisMovieClip.play();
    //import flash.display.*;
    //import flash.net.URLRequest;
    //import flash.events.Event;
    //var _swfLoader1:Loader;
    //var _swfContent1:MovieClip;
    //loadSWF1("script1_3.swf");
    //play();
    //function loadSWF1(path:String):void {
    //   var _req1:URLRequest = new URLRequest();
    //   _req1.url = path;
    //  _swfLoader1 = new Loader();
    // setupListeners1(_swfLoader1.contentLoaderInfo);
    //  _swfLoader1.load(_req1);
    //function setupListeners1(dispatcher1:IEventDispatcher):void {
    //  dispatcher1.addEventListener(Event.COMPLETE, addSWF1);
      // dispatcher1.addEventListener(ProgressEvent.PROGRESS, preloadSWF1);
    //function preloadSWF1(event:ProgressEvent):void {
    //   var _perc:int = (event.bytesLoaded / event.bytesTotal) * 100;
    //swfPreloader1.percentTF.text = _perc + "%";
    //function addSWF1(event:Event):void {
    /// event.target.removeEventListener(Event.COMPLETE, addSWF1);
    //  event.target.removeEventListener(ProgressEvent.PROGRESS, preloadSWF1);
    //  _swfContent1 = event.target.content;
    // _swfContent1.addEventListener("close", unloadSWF1);
    // addChild(_swfContent1);
    //function unloadSWF1(event:Event):void {
    //  _swfLoader1.unloadAndStop();
    //removeChild(_swfContent1);
    //  _swfContent1 = null;
    Best Wishes
    Deborah

    Believe me, I'm feeling the pressure!!!  I sent a screen shot and it got kicked back!!!! 
    here is the code I'm using in the main time line:
    var myLoader:Loader = new Loader();                    
    var url:URLRequest = new URLRequest("script1_3.swf");  // THIS can be any SWF file - same results
    myLoader.load(url);                                    
    addChild(myLoader);  
    The only thing that is in the main time line before this is a page roll over effect component - and if I remove that I have the same problem!  I'm sorry, I don't know what else to provide you without giving you my fla files which I tried to send and they were kicked back!!!
    HELP!

  • Button from External SWF to Play Movie in Main SWF

    Hi Guys,
    Ok I'm working in Flash 8, Action Script 2;
    I'm building a website, in which the 'Gallery Page' has a link to an external swf file, which is a scrolling clip of thumbnails.
    What I want to do, is create each thumbnail into a button, which will then play a Movie Clip from a frame located in the Main swf file.
    (So basically, each thumbnail button is a small photo, will play that photo in a large scale as a movie)
    eg.
    thumbnail1_btn  needs to go to main swf and play movieclip1.mc, frame 1
    thumbnail2_btn nends to go to main swf and play movieclip1.mc, frame 2
    I'm unsure of the code for this? Or if I've built this up wrong?
    If someone could help me out, that would be great!

    If you haven't set _lockroot on the loaded SWF, than a simple _root call from the loaded SWF will talk to the main SWF.
    IE:
    on(release){
    _root.gotoAndPlay(1);
    If you did set the lockroot, then call the level directly, via:
    on(release){
    _level0.gotoAndPlay(1);
    Once on the root level, you can access a movie clip as normal.
    So:
    on(release){
    _level0.movieClip1.gotoAndPlay(1);
    will call the movie clip "movieClip1" which resides on the timeline of _level0 (which is main.swf in your instance), and tell it to jump to the first frame and start playing.

  • External SWF sounds playing over each other

    Hello all,
    Does anyone have any clue on how to unload an external swf with all its sounds?

    if you're using cs4 publishing for fp10 you can use unloadAndStop().  otherwise, you must explicity stop the swf's sounds (or more crudely stop all sounds using SoundMixer.stopAll() ) and then apply the loader's unload() method.

  • Preload external content before its time

    Is it possible to preload content before a person looking at your site requests it, for instance when your website loads and is displayed other content and pages will start preloading in a certain order with out the website user knowing?

    I created a movie clip set the alpha to 0 and used this code in the
    first frame of the movie clip, the movie showed up when it wasn't
    supposed to
    loadMovieNum("movie1.swf", 1);
    stop();
    I also tried the code
    loadMovie("movie1.swf")
    stop()
    that didn't work, and flash didn't like the code

  • How can I stop timeline sounds in external swf files from playing during loading?

    I am having a problem with timeline sounds in external swf files playing during loading in a main swf. Can anyone help me?
    Here is some of the code from the main swf. I hope I have included enough.
    Thanks.
    import flash.events.MouseEvent;
    import flash.display.MovieClip;
    import flash.display.Loader;
    import flash.events.ProgressEvent;
    import flash.events.Event;
    import flash.net.URLRequest;
    import fl.events.SliderEvent;
    import flash.media.SoundTransform;
    preloader_mc.fill_mc.scaleX = 0;
    var swfA:Array = ["part1.swf","part2.swf"];
    var frameA:Array = [];
    var currentLoader:Loader;
    var swfTotalFrames:int;
    var tl:MovieClip = this;
    var st:SoundTransform = new SoundTransform()
    var index:int = 0;
    loadNextF();
    play_slider.enabled = false;
    function loadNextF():void{
                    tl["loader_"+index] = new Loader();
                    tl["loader_"+index].name = index.toString();
                    tl["loader_"+index].contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,progressF);
                    tl["loader_"+index].contentLoaderInfo.addEventListener(Event.COMPLETE,completeF);
                    tl["loader_"+index].load(new URLRequest(swfA[index]));
    function progressF(e:ProgressEvent):void{
                    var fractionLoaded:Number = index/swfA.length+e.bytesLoaded/(e.bytesTotal*swfA.length);
                    preloader_mc.fill_mc.scaleX = fractionLoaded;
                    preloader_mc.tf.text = (100*fractionLoaded)+"% Loaded";
    function completeF(e:Event):void{
                    tl["loader_"+index].contentLoaderInfo.removeEventListener(ProgressEvent.PROGRESS,progress F);
                    tl["loader_"+index].contentLoaderInfo.removeEventListener(Event.COMPLETE,completeF);
                    SoundMixer.stopAll();
                    var mc:MovieClip = MovieClip(tl["loader_"+index].content);
                    mc.gotoAndStop(1);
                    frameA.push(mc.totalFrames);
                    index++;
                    if(index<swfA.length){
                                    loadNextF();
                    } else {
                                    // all loads complete.  start play.
                                    restart_mc.buttonMode = true;
                                    restart_mc.alpha = 1;
                                    tl.addEventListener(Event.ENTER_FRAME,playUpdateF);
                                    tl.removeChild(preloader_mc);
                                    preloader_mc = null;
                                    play_slider.enabled = true;
                                    playpause_mc.alpha = 1;
                                    currentLoader = tl["loader_0"];
                                    tl.addChild(currentLoader);
                                    MovieClip(currentLoader.content).play();
                                    sliderParamsF();

    import flash.events.MouseEvent;
    import flash.display.MovieClip;
    import flash.display.Loader;
    import flash.events.ProgressEvent;
    import flash.events.Event;
    import flash.net.URLRequest;
    import fl.events.SliderEvent;
    import flash.media.SoundTransform;
    preloader_mc.fill_mc.scaleX = 0;
    var swfA:Array = ["part1.swf","part2.swf"];
    var frameA:Array = [];
    var currentLoader:Loader;
    var swfTotalFrames:int;
    var tl:MovieClip = this;
    var st:SoundTransform = new SoundTransform()
    var index:int = 0;
    loadNextF();
    play_slider.enabled = false;
    function loadNextF():void{
        tl["loader_"+index] = new Loader();
        tl["loader_"+index].name = index.toString();
        tl["loader_"+index].contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,progressF);
        tl["loader_"+index].contentLoaderInfo.addEventListener(Event.COMPLETE,completeF);
        tl["loader_"+index].load(new URLRequest(swfA[index]));
    function progressF(e:ProgressEvent):void{
        var fractionLoaded:Number = index/swfA.length+e.bytesLoaded/(e.bytesTotal*swfA.length);
        preloader_mc.fill_mc.scaleX = fractionLoaded;
        preloader_mc.tf.text = (100*fractionLoaded)+"% Loaded";
    function completeF(e:Event):void{
        tl["loader_"+index].contentLoaderInfo.removeEventListener(ProgressEvent.PROGRESS,progress F);
        tl["loader_"+index].contentLoaderInfo.removeEventListener(Event.COMPLETE,completeF);
        SoundMixer.stopAll();
        var mc:MovieClip = MovieClip(tl["loader_"+index].content);
        mc.gotoAndStop(1);
        frameA.push(mc.totalFrames);
        index++;
        if(index<swfA.length){
            loadNextF();
        } else {
            // all loads complete.  start play.
            restart_mc.buttonMode = true;
            restart_mc.alpha = 1;
            tl.addEventListener(Event.ENTER_FRAME,playUpdateF);
            tl.removeChild(preloader_mc);
            preloader_mc = null;
            play_slider.enabled = true;
            playpause_mc.alpha = 1;
            currentLoader = tl["loader_0"];
            tl.addChild(currentLoader);
            MovieClip(currentLoader.content).play();
            sliderParamsF();
    ///////////////// start sliders /////////////////////////////////
    sound_slider.addEventListener(SliderEvent.CHANGE,soundSliderF);
    function soundSliderF(e:SliderEvent):void{
        st.volume = e.value/100;
        tl.soundTransform = st;
    play_slider.addEventListener(SliderEvent.CHANGE,playSliderF);
    play_slider.addEventListener(MouseEvent.MOUSE_DOWN,playSliderDownF);
    //play_slider.addEventListener(MouseEvent.MOUSE_UP,playSliderUpF);
    function playSliderDownF(e:MouseEvent):void{
        tl.removeEventListener(Event.ENTER_FRAME,playUpdateF);
        stage.addEventListener(MouseEvent.MOUSE_UP,playSliderUpF);
    function playSliderUpF(e:MouseEvent):void{
        tl.addEventListener(Event.ENTER_FRAME,playUpdateF);
    function playSliderF(e:SliderEvent):void{
        SoundMixer.stopAll();
        var frameNum:int = Math.ceil(swfTotalFrames*e.value/100);
        var partialTotalFrames:int = 0;
        for(var i:int=0;i<frameA.length;i++){
            partialTotalFrames += frameA[i];
            if(partialTotalFrames>=frameNum){
                break;
        partialTotalFrames -= frameA[i];
        //trace(i,frameNum,frameNum-partialTotalFrames);
        if(currentLoader!=tl["loader_"+(i)]){
            tl.removeChild(currentLoader);
            MovieClip(currentLoader.content).stop();
            currentLoader = tl["loader_"+(i)];
            tl.addChild(currentLoader);
        if(playpause_mc.currentFrame==1){
            MovieClip(currentLoader.content).gotoAndPlay(frameNum-partialTotalFrames);
        } else {
            MovieClip(currentLoader.content).gotoAndStop(frameNum-partialTotalFrames);
    function sliderUpdateF(e:Event):void{
        var playedFrames:int = 0;
        for(var i:int=0;i<Number(currentLoader.name);i++){
            playedFrames += frameA[i];
        playedFrames += MovieClip(currentLoader.content).currentFrame;
        play_slider.value = Math.round(100*playedFrames/swfTotalFrames);
    function sliderParamsF():void{
        swfTotalFrames = 0;
        for(var i:int=0;i<swfA.length;i++){
            swfTotalFrames += MovieClip(tl["loader_"+i].content).totalFrames;
    ///////////////// end  sliders //////////////////////////////////
    ///////////////// start playpause restart ///////////////////////
    playpause_mc.addEventListener(MouseEvent.CLICK,playpauseF);
    playpause_mc.alpha = .2;
    restart_mc.addEventListener(MouseEvent.CLICK,restartF);
    restart_mc.buttonMode = false;
    restart_mc.alpha = .2;
    function playpauseF(e:MouseEvent):void{
        if(!e.currentTarget.toggle){
            MovieClip(currentLoader.content).stop();
            tl.removeEventListener(Event.ENTER_FRAME,playUpdateF);
            e.currentTarget.gotoAndStop(2);
        } else {
            MovieClip(currentLoader.content).play();
            tl.addEventListener(Event.ENTER_FRAME,playUpdateF);
            e.currentTarget.gotoAndStop(1);
        e.currentTarget.toggle = !e.currentTarget.toggle;
    ///////////////// end playpause //////////////////////////////
    function playUpdateF(e:Event):void{
        sliderUpdateF(e);
        var playingFrame:int = MovieClip(currentLoader.content).currentFrame;
        if(playingFrame==frameA[Number(currentLoader.name)]){
            // next loader
            MovieClip(currentLoader.content).stop();
            SoundMixer.stopAll();
            MovieClip(currentLoader.content).mute();
            var nextIndex:int = Number(currentLoader.name)+1;
            if(nextIndex<swfA.length){
                tl.removeChild(currentLoader);
                currentLoader = tl["loader_"+nextIndex];
                tl.addChild(currentLoader);
                MovieClip(currentLoader.content).gotoAndPlay(1);
            } else {
                tl.removeEventListener(Event.ENTER_FRAME,playUpdateF);
                playpause_mc.gotoAndStop(2);
                playpause_mc.toggle = !playpause_mc.toggle;
                //playpause_mc.alpha = .2;
                // all swfs have completed play
    function restartF(e:MouseEvent):void{
        MovieClip(currentLoader.content).stop();
        tl.removeChild(currentLoader);
        SoundMixer.stopAll();
        MovieClip(currentLoader.content).mute();
        currentLoader = tl["loader_"+0];
        tl.addChild(currentLoader);
        if(playpause_mc.currentFrame==1){
            MovieClip(currentLoader.content).gotoAndPlay(1);
        } else {
            MovieClip(currentLoader.content).gotoAndStop(1);

  • When removing an external swf, the sound still plays

    Any idea how to get the sound to stop once an external swf has been removed from the stage?  Thanks!

    The video is embedded because I want it to loop as the background of my site.  I have been able to get everything to work with embedded video, however the file size is too large.  I did have buttons controlling the background video when it was embedded.  The issue I am having is I would like to have a foward button and replay button.  The foward button would take me to the portion of the site with the embedded video, and the replay would take me back to play the external swf, basically playing everything from the beginning, without reloading the whole site.  I know this is confusing and I may be in over my head.  Any help would be greatly appreciated.  Thanks

  • Unloading external swf file keeps memory usage growing up

    Hello everybody,
    The idea is very simple: I have a submain.swf with 5 buttons. Each button loads an external .swf file.
    com_loader.load(URLRequest);
    After playing first external swf, before I go to next one, I try to unload it:
    1. remove all its associated listeners:
    com_loader.contentLoaderInfo.removeEventListener(Event.INIT-PROGRESS-COMPLETE, idFunction);
    2. unload it:
    com_loader.unload();
    3. set to null:
    com_loader = null;
    and load next external swf file and so on.
    The problem is that the FireFox/IE8.0 Memory Usage in Task Manager is going up and I see no sign of GC activity even after 5 mins of playing. Can anyone light me up pls? This is the second week working around and no good news until now.
    Thanks in advance.
    P.S.
    If I try com_loader.unloadAndStop(); it gives me the error: Error #2044: Unhandled IOErrorEvent:. text=Error #2036: Load Never Completed.
    Vince.

    Hi Ice,
    The loaded swf file contains only a small photo, just for testing, with no listeners or other stuff in it.
    Vic.

  • How to load and unload Multiple External SWF

    hello there,
    i need help to figuring out how to load and also unload(removing) multiple external SWF.
    so here is what i;m trying to do,
    i want to load multiple external SWF and play it on my main SWF now i hove no problem with just loading multiple SWF and placing it in the display list .The problem came up when i tried removing those loaded SWF from the display list ,The problem exist because i have no way to refer to what i have loaded and placed on the display list,
    i used a single loader instance to load all that external swf,
    i do know that we have to remove all the event listener related to the external SWF that we want to remove and for this purpose i have crated a function called destroy which the main objective for this function is to remove all event listener inside the swf and also isolating all variable so it would be eligible for garbage collecting, here is what the code look like:
    // Create this in every object you use
    public function destroy():void
         // Remove event listeners
         // Remove anything in the display list
         // Clear the references to other objects, so it gets totally isolated
    sorry it just a kind of pseudocode cause this function will customize with it's own property i did this just for the purpose of simplicity and easy understanding..,
    so now back to main problem how should i solve this problem??
    i tried used an arraf to save all the loaded swf
         the array is just used to save the what the loader is loading but the adding to display method is using
    movieClipActAsContainer.addChild(e.target.content); //the event is from the Event.COMPLETE
    but i have a hard time using that arrya back and matching it to the one i got from the display list.
    please do help me,
    any suggestion would be greatly appreciated,
    and if can pleas show me a source code or pseudocode of what you're suggesting to me cause my english is not so fluent yet,
    thanks before.

    Hey EI,
    I had done this kind of project recently and for loading and unloading different swfs. I had used loaders specific to that filename and for removing I had used a single movieclip instance name and on clicking that specific loader request name that needs to be removed will be requested from the specific function. As mentioned below
    Loading SWF:
    ===============================
    swfLoaderIndia.load(swfRequestIndia);//This will load the request
    If you are inside a movieclip while requesting use below code
    MovieClip(this.root).addChild(swfLoaderIndia);//This will load swf on stage
    or else
    Stage.addChild(swfLoaderIndia);
    Unloading SWF
    =====================================
    If you are inside a movieclip while requesting use below code
    MovieClip(this.root).removeChild(swfLoaderIndia);//This will unload swf on stage
    or else
    Stage.removeChild(swfLoaderIndia);
    Above code will be in specific function which will be requested when the loading and unloading is required.
    I hope this helps you in your project.
    With Regards,
    Sagar S. Ranpise

  • External swf question...

    Hey all
    I found this code for loading external swfs and playing them in succession.
    It works when I use the external swfs that come with the code, but not when I try to use any other external swfs.
    I can't figure out why - does anything seem obvious (the clip swfs are here http://www.flashandmath.com/intermediate/externalclips/clip0.swf http://www.flashandmath.com/intermediate/externalclips/clip1.swf http://www.flashandmath.com/intermediate/externalclips/clip2.swf ):
    // Array of external clips to use. Variable index refers to next clip to be displayed.
    var clips:Array = ["clip0.swf", "clip1.swf", "clip2.swf"];
    var index:int = 0;
    // Stuff to load swf files
    var thisLoader:Loader = new Loader();
    thisLoader.contentLoaderInfo.addEventListener(Event.INIT, doneLoading);
    //loader.contentLoaderInfo.addEventListener(Event.COMPLETE, dataOnLoad);
    var thisMC:MovieClip = new MovieClip();
    stage.addChild(thisMC);            // Add empty MC initially so the nextClip function can be generic
    // Removes old MC and gets the next one, waiting until when it has initialized beore adding it to the stage
    function nextClip():void {
        thisLoader.load(new URLRequest(clips[index]));
    // Tell AS that the loaded file is a movie clip and add it to the stage.
    function doneLoading(e:Event):void {
    stage.removeChild(thisMC);
    thisMC = MovieClip(thisLoader.content);
    thisLoader.unload();
    thisMC.addEventListener(Event.ENTER_FRAME, runOnce);
    stage.addChild(thisMC);
    thisMC.gotoAndPlay(1);
    // When thisMC has finished, play the next clip.
    function runOnce(e:Event):void {
    if (thisMC.currentFrame == thisMC.totalFrames) {
    thisMC.removeEventListener(Event.ENTER_FRAME, runOnce);
    index = (index + 1)%(clips.length);
    nextClip();
    // Call the nextClip function initially to get the ball rolling
    nextClip();
    Thanks for taking a look guys.
    Shaun

    One of the swfs returns:
    TypeError: Error #1034: Type Coercion failed: cannot convert flash.display::AVM1Movie@26f9b3a1 to flash.display.MovieClip.
        at alt2_fla::MainTimeline/doneLoading()
    (I'm pretty sure it's an AS3 swf)
    The other, which I had just built using AS3, returns:
    TypeError: Error #1009: Cannot access a property or method of a null object reference.
        at fl.rsl::RSLPreloader/loadContent()
        at _001_fla::MainTimeline__Preloader__/frame2()
    Error: Error #2099: The loading object is not sufficiently loaded to provide this information.
        at flash.display::LoaderInfo/get width()
        at loader_animation_fla::MainTimeline/frame1()
    Error: Error #2099: The loading object is not sufficiently loaded to provide this information.
        at flash.display::LoaderInfo/get width()
        at loader_animation_fla::MainTimeline/frame1()
    TypeError: Error #1009: Cannot access a property or method of a null object reference.
        at fl.rsl::RSLPreloader/loadContent()
        at _001_fla::MainTimeline__Preloader__/frame2()

  • HELP ASAP - external swf's

    HI, we have a situation which has done our heads in for two
    days non-stop,
    We have a pre-loader loading the area's and then have the
    loadmovienum to load in additional swf's now when we use the nav
    bar at the top of the page, it opens the right file but when it
    loads the page it moves onto the next load movie for some reason
    with out stopping, even though the stop command is in place....
    We have uploaded the dodgy version which you can test and see
    what problems we are having, the contact page is the same as the
    service page for the moment, but you will see the contact page
    display the "cloned" service page then it restarts the whole movie
    Here are the URL's to the zip file with all the swf's and
    fla's including the live what we have done so far online version.
    http://www.drsolutions.co.uk/premiere/wwwroot/
    http://www.drsolutions.co.uk/premiere/fla/premiere.zip
    Please reply asap thanks
    PS WE ARE USING FLASH 8

    Just to clarify,
    I am the author of the above flash project / files.. Travman
    is my collegue.
    Although this is not your style of flash shyaway, you did get
    my noodle ticking over the interval script,
    example:
    var id = setInterval(function(){play();clearInterval(id);},
    8000);
    this was to make a movie clip pause for 8000 miliseconds,
    then play the continued sequence to form a rotation of images, this
    code was used on 4 frames in the sequence..
    Following a closer look and removal of the code, the main
    flash movie with loaded external swf's plays fine.. the reason, i
    can only assume this code was causing an issue is due to the
    play(); command, making the whole main movie play instead of just
    the movie clip..
    Scene names do not usually cause and issue, however, keeping
    seperate names is always good from a logical sense
    I have now resolved the issue, but for any other readers with
    a similar problem, try searching for all play/stop commands that
    run sub to the main timeline.
    Andy - Web Designer/Developer /Programmer

  • Looping external swf which has no .fla

    Hi!
    What I have is a sliding menu with buttons - each button calls an external swf - which plays in an empty movie clip.
    Now, I want the current loaded swf to loop till the time the user clicks on another button. The problem is, I do not have the fla files for any of the external swfs (these are screencam recordings using a software that does not publish .fla) - so I can't put a code at the end of each external swf asking it to not stop.
    Any suggestions on how I might be able to have the external swf loop?
    Thanks & Regards,
    ~ Raven

    Thanks for your help Ned. Actually, I did manage to decompile the swf (using a 3rd party software) - yes, it is a movieclip on frame 1. I could even go inside it and place the loop code. But decompiling meant loss of the control bar that the screen capture software put in it and I can't compromise on that. I guess the screen capture guys should've chosen another softwares that publishes the .fla.
    Thanks again and regards,
    ~ Raven

Maybe you are looking for

  • Po number

    by which t.code i can get purchase order no...i know material document number regards Rekha

  • Policy agent fot apache tomcat opensso

    Hi, I am looking for policy agent fot apache tomcat opensso 8 u2. Can anyone post the url for the same

  • Auto specified any value after ran RECOVER STANDBY DATABASE;

    Dear all, When i ran the RECOVER STANDBY DATABASE command.It 's will prompt as below : SQL> RECOVER STANDBY DATABASE; ORA-00279: change 302927 generated at 09/10/2007 14:08:24 needed for thread 1 ORA-00289: suggestion : D:\ORACLE\ORADATA\DB817\ARCHIV

  • Photoshop and iPhoto will not open with Leopard

    I can not open Photoshop or iPhoto with Leopard. I have Photoshop 7, this is a huge problem, need Photoshop ASAP, can anyone help?

  • Increasing font size when resizing JFrame

    Hello, I am writing a calculator program, and therefore have a JLabel to display the numbers and multiple buttons. The JLabel and JButton components are added to a panel with a GridBagLayout, which is then added to the content pane of a JFrame. When