Announcement Announcement Module
Collapse
No announcement yet.
Loading and Unloading an SWF file Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Loading and Unloading an SWF file

    Loading and Unloading an SWF file
    I'm currently working on a educational project for e-learning. This project has multiple buttons for opening several specific SWF files. What I want to accomplish is to be able to use my container file with 3 primary buttons for the named SWF files and have them load in a specific location in the container SWF. Then I have a separate button that just needs to close the loaded SWF file. FYI, the 3 primary buttons will be covered by the loaded swf file. I'm including my AS3 code for review. I can load a SWF and close it once. After that, it doesn't work. I would appreciate any assistance.

    Code:

    stop();
    sub1.about_btn.addEventListener(MouseEvent.CLICK, aboutLoad);
    sub1.pdf_btn.addEventListener(MouseEvent.CLICK, pdfLoad);
    sub1.myvideo_btn.addEventListener(MouseEvent.CLICK , videoLoad);
    sub1.quiz_btn.addEventListener(MouseEvent.CLICK, quizLoad);

    function aboutLoad(e:MouseEvent):void {
    loadClip("about.swf");
    }
    function pdfLoad(e:MouseEvent):void {
    loadClip("pdf.swf");
    }

    function videoLoad(e:MouseEvent):void {
    loadClip("myvideo.swf");
    }

    function quizLoad(e:MouseEvent):void {
    loadClip("quiz.swf");
    }

    var theLoader = new Loader();

    theLoader.contentLoaderInfo.addEventListener(Progr essEvent.PROGRESS, progHandler);
    theLoader.contentLoaderInfo.addEventListener(Event .COMPLETE, loadedHandler);

    addChild(theLoader);
    theLoader.x=102;
    theLoader.y=85;
    back1_btn.addEventListener(MouseEvent.CLICK, backClick);

    function backClick(event:MouseEvent):void {
    removeChild(theLoader);

    }

    function loadClip(t:String):void {
    SoundMixer.stopAll();
    var myUrl:URLRequest=new URLRequest(t);
    theLoader.load(myUrl);
    }

    preText.visible=false;

    function progHandler(e:ProgressEvent):void {
    preText.visible=true;
    var myPercent = Math.floor((e.bytesLoaded/e.bytesTotal)*100);
    preText.text="loading: "+myPercent+"%";
    }

    function loadedHandler(e:Event):void {
    preText.visible=false;
    }
    Best,

    Monte Darland
Working...
X