Loading class from an external .swf file

Hi,
My flash application has lots of resources which will change all the time. In order to keep the the user from having to download my main .swf file over and over again, and in order to keep the main file's size low, I would like to put the resources into separate .swf files and load them dynamically from a url using a Loader.
Once downloaded I would like to extract the classes that are in the resource swf and use them in the main swf. Can anyone share some code for doing this? Note that I am not just interested in using a symbol from the resource swf. I would like to use a class, with all of its methods and everything, and my main swf does not contain the class definition. Only the resource swf does.
Thanks!!

This is a great question for flash programming.
And when you know the answer to this, you are likely to use it on daily basis like the top level programmers  of an agency.
ApplicationDomain is your answer and the adobe docs has a chapter on this.
ApplicationDomain is where all of your classes will be loaded into and when you use a loader you have the ability to target this with the laoderContext.
AplicationDomain.currentDomain loads all classes into the main app and if your main app already has these classes, then the app uses the parents classes
new Application.Domain() specifies a seperate repo of classes that are loaded in so that classes in the main app will not be confused by the classes in a loaded swf. that refer to the same names.
this locks down the communication between the swfs but will use the newer updated classes on the child when a child is loaded in with the same class names as the parents.
new ApplicationDomain(currentDomain)  will enclose a new repo with the parent repo of the class definitions.

Similar Messages

  • Load and unload the external swf file using AS3(for window, IOS and android)

    For the external swf file loading, I use this code
    load2.addEventListener(MouseEvent.MOUSE_DOWN, newvid);
    function newvid(event:MouseEvent) {
              trace("you clicked me");
              var loadit = new Loader();
              addChild(loadit);
        var _lc:LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain, null);
        loadit.load(new URLRequest("scene02.swf"), _lc);
    its working great but I don’t know how to unload the loaded swf files (looking: unload one by one and unload all)
    in AS2 we have
    on (release) {
              loadMovieNum("scene2.swf", 1);
              unloadMovieNum(2);
              unloadMovieNum(3);
    but i need in AS3

    Now I use this code and this time I got these compiler errors
    package {
                    import flash.display.SimpleButton;
                    import flash.display.MovieClip;
                    import flash.events.MouseEvent;
                    //import flash.display.URLRequest;
                    //import flash.display.Loader;
                    import flash.events.Event;
                    import flash.system.ApplicationDomain;
                    import flash.net.URLRequest;
                    import flash.system.LoaderContext;            
                                    public class load1 extends SimpleButton {
                                                    var loadit:Loader;              
                                                    public function load1() {
                                                                    this.addEventListener(MouseEvent.MOUSE_DOWN, loadfile);
                                                    private function loadfile(event:MouseEvent):void {
                                                                    trace("you clicked me");
                                                                    loadit = new Loader();
                                                                    this.parent.addChild(loadit);
                                                                    var _lc:LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain, null);
                                                                    loadit.load(new URLRequest("s01.swf"), _lc);
                                                    private function unloadfile(event:MouseEvent):void {
                                                                    loadit.unloadAndStop();

  • How to import classes from an external actionscript file

    This is driving me crazy, I've been trying to resolve this on my own for ages, and I've reviewed a lot of different materials, but I still can't seem to just import some external actionscript classes correctly.
    I'm using Flash Builder 4 with the Flex 4 SDK on mac osx 10.6
    the class I'm trying to import (I'll call it DesiredClass) is in a folder like this
    /libraries/com/foreignproject/com/foreignproject/DesiredClass.as
    within the class itself, the package declaration looks like this (I left all the guts out for clarity):
    package com.foreignproject
        import flash.display.Sprite;
        public class DesiredClass extends Sprite
            public function DesiredClass()
    I'm working on a totally different actionscript file at
    /Users/username/Documents/Adobe Flash Builder 4/TestProject/src/TestProject.as
    in this file I try to import the DesiredClass:
    package
         import com.foreignproject.DesiredClass;
         import flash.display.Sprite;
         public class TestProject extends Sprite
              public function TestProject()
              var neatClass:DesiredClass = new DesiredClass();
    And then I try to add the class I want to the source path.
    I've tried adding each folder to the source path separately:
    /libraries/com/foreignproject/com/foreignproject/DesiredClass.as
    /libraries/com/foreignproject/com/foreignproject/DesiredClass.as
    /libraries/com/foreignproject/com/foreignproject/DesiredClass.as
    /libraries/com/foreignproject/com/foreignproject/DesiredClass.as
    /libraries/com/foreignproject/com/foreignproject/DesiredClass.as
    If I choose the libraries folder or either of the com folders then an error shows up in theTestProject.as file, saying:
    Definition com.foreignproject:DesiredClass could not be found.
    But f I choose either of the foreignproject folders then an error shows up in theDesiredClass.as file saying:
    a file found in a source-path must have the same package structure 'com.foreignproject', as the definition's package, ".
    What am I doing wrong? Please help. I bought a book on actionscript, started doing the flex-in-a-week series, read numerous online discussion boards, and I still can't import these classes.
    Thanks in advance.

    I don't know if this method is supported anymore but you can give it a try.
    If you backed up bookmarks in IE using the following directions, you should be good!
    *In IE, "File -> Import and Export -> Export Cookies".
    *Open newly exported "cookies.txt" in a text editor and put a period before every line that starts with a domain. So a line starting with <b>altavista.com TRUE / FALSE 1388491200 AV_ALL 1</b> will become <b>.altavista.com TRUE / FALSE 1388491200 AV_ALL 1</b>
    *Then, move the "cookies.txt" file to your profile folder.
    You can get to the Profile folder two ways
    *Help > Troubleshooting Information > Profile Directory > Show Folder
    or
    *Go to '''about:support''' and click Show Folder next to Profile Directory.

  • Remove / unload external swf file(s) from the main flash file and load a new swf file and garbage collection from memory.

    I can't seem to remove / unload the external swf files e.g when the carousel.swf (portfolio) is displayed and I press the about button the about content is overlapping the carousel (portfolio) . How can I remove / unload an external swf file from the main flash file and load a new swf file, while at the same time removing garbage collection from memory?
    This is the error message(s) I am receiving: "TypeError: Error #2007: Parameter child must be non-null.
    at flash.display::DisplayObjectContainer/removeChild()
    at index_fla::MainTimeline/Down3()"
    import nl.demonsters.debugger.MonsterDebugger;
    var d:MonsterDebugger=new MonsterDebugger(this);
    stage.scaleMode=StageScaleMode.NO_SCALE;
    stage.align=StageAlign.TOP_LEFT;
    stage.addEventListener(Event.RESIZE, resizeHandler);
    // loader is the loader for portfolio page swf
    var loader:Loader;
    var loader2:Loader;
    var loader3:Loader;
    var loader1:Loader;
    //  resize content
    function resizeHandler(event:Event):void {
        // resizes portfolio page to center
    loader.x = (stage.stageWidth - loader.width) * .5;
    loader.y = (stage.stageHeight - loader.height) * .5;
    // resizes about page to center
    loader3.x = (stage.stageWidth - 482) * .5 - 260;
    loader3.y = (stage.stageHeight - 492) * .5 - 140;
    /*loader2.x = (stage.stageWidth - 658.65) * .5;
    loader2.y = (stage.stageHeight - 551.45) * .5;*/
    addEventListener(Event.ENTER_FRAME, onEnterFrame,false, 0, true);
    function onEnterFrame(ev:Event):void {
    var requesterb:URLRequest=new URLRequest("carouselLoader.swf");
    loader = null;
    loader = new Loader();
    loader.name ="carousel1"
    //adds gallery.swf to stage at begining of movie
    loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioError);
    function ioError(event:IOErrorEvent):void {
    trace(event);
    try {
    loader.load(requesterb);
    } catch (error:SecurityError) {
    trace(error);
    addChild(loader);
    loader.x = (stage.stageWidth - 739) * .5;
    loader.y = (stage.stageHeight - 500) * .5;
    // stop gallery.swf from duplication over and over again on enter frame
    removeEventListener(Event.ENTER_FRAME, onEnterFrame);
    //PORTFOLIO BUTTON
    //adds eventlistner so that gallery.swf can be loaded
    MovieClip(root).nav.portfolio.addEventListener(MouseEvent.MOUSE_DOWN, Down, false, 0, true);
    function Down(event:MouseEvent):void {
    // re adds listener for contact.swf and about.swf
    MovieClip(root).nav.info.addEventListener(MouseEvent.MOUSE_DOWN, Down1, false, 0, true);
    MovieClip(root).nav.about.addEventListener(MouseEvent.MOUSE_DOWN, Down3, false, 0, true);
    //unloads gallery.swf from enter frame if users presses portfolio button in nav
    var requester:URLRequest=new URLRequest("carouselLoader.swf");
        loader = null;
    loader = new Loader();
    loader.name ="carousel"
    loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioError);
    function ioError(event:IOErrorEvent):void {
    trace(event);
    try {
    loader.load(requester);
    } catch (error:SecurityError) {
    trace(error);
    addChild(loader);
    loader.x = (stage.stageWidth - 739) * .5;
    loader.y = (stage.stageHeight - 500) * .5;
    removeChild( getChildByName("about") );
    removeChild( getChildByName("carousel1") );
    // remove eventlistner and prevents duplication of gallery.swf
    MovieClip(root).nav.portfolio.removeEventListener(MouseEvent.MOUSE_DOWN, Down);
    //INFORMATION BUTTON
    //adds eventlistner so that info.swf can be loaded
    MovieClip(root).nav.info.addEventListener(MouseEvent.MOUSE_DOWN, Down1, false, 0, true);
    function Down1(event:MouseEvent):void {
    //this re-adds the EventListener for portfolio so that end user can view again if they wish.
    MovieClip(root).nav.portfolio.addEventListener(MouseEvent.MOUSE_DOWN, Down, false, 0, true);
    MovieClip(root).nav.about.addEventListener(MouseEvent.MOUSE_DOWN, Down3, false, 0, true);
    var requester:URLRequest=new URLRequest("contactLoader.swf");
    loader2 = null;
    loader2 = new Loader();
    loader2.name ="contact"
    loader2.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioError);
    function ioError(event:IOErrorEvent):void {
    trace(event);
    try {
    loader2.load(requester);
    } catch (error:SecurityError) {
    trace(error);
    addChild(loader2);
    loader2.x = (stage.stageWidth - 658.65) * .5;
    loader2.y = (stage.stageHeight - 551.45) * .5;
    // remove eventlistner and prevents duplication of info.swf
    MovieClip(root).nav.info.removeEventListener(MouseEvent.MOUSE_DOWN, Down1);
    //ABOUT BUTTON
    //adds eventlistner so that info.swf can be loaded
    MovieClip(root).nav.about.addEventListener(MouseEvent.MOUSE_DOWN, Down3, false, 0, true);
    function Down3(event:MouseEvent):void {
    //this re-adds the EventListener for portfolio so that end user can view again if they wish.
    MovieClip(root).nav.portfolio.addEventListener(MouseEvent.MOUSE_DOWN, Down, false, 0, true);
    MovieClip(root).nav.info.addEventListener(MouseEvent.MOUSE_DOWN, Down1, false, 0, true);
    var requester:URLRequest=new URLRequest("aboutLoader.swf");
    loader3 = null;
    loader3 = new Loader();
    loader3.name ="about"
    loader3.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioError);
    function ioError(event:IOErrorEvent):void {
    trace(event);
    try {
    loader3.load(requester);
    } catch (error:SecurityError) {
    trace(error);
    addChild(loader3);
    loader3.x = (stage.stageWidth - 482) * .5 - 260;
    loader3.y = (stage.stageHeight - 492) * .5 - 140;
    removeChild( getChildByName("carousel") );
    removeChild( getChildByName("carousel1") );
    // remove eventlistner and prevents duplication of info.swf
    MovieClip(root).nav.about.removeEventListener(MouseEvent.MOUSE_DOWN, Down3);
    stop();

    Andrei1,
    Thank you for the helpful advice. I made the changes as you suggested but I am receiving a #1009 error message even though my site is working the way I wan it to work. I would still like to fix the errors so that my site runs and error free. This is the error I am receiving:
    "TypeError: Error #1009: Cannot access a property or method of a null object reference."
    I'm sure this is not the best method to unload loaders and I am guessing this is why I am receiving the following error message.
         loader.unload();
         loader2.unload();
         loader3.unload();
    I also tried creating a function to unload the loader but received the same error message and my portfolio swf was not showing at all.
         function killLoad():void{
         try { loader.close(); loader2.close; loader3.close;} catch (e:*) {}
         loader.unload(); loader2.unload(); loader3.unload();
    I have a question regarding suggestion you made to set Mouse Event to "null". What does this do setting the MouseEvent do exactly?  Also, since I've set the MouseEvent to null do I also have to set the loader to null? e.g.
    ---- Here is my updated code ----
    // variable for external loaders
    var loader:Loader;
    var loader1:Loader;
    var loader2:Loader;
    var loader3:Loader;
    // makes borders resize with browser size
    function resizeHandler(event:Event):void {
    // resizes portfolio page to center
         loader.x = (stage.stageWidth - loader.width) * .5;
         loader.y = (stage.stageHeight - loader.height) * .5;
    // resizes about page to center
         loader3.x = (stage.stageWidth - 482) * .5 - 260;
         loader3.y = (stage.stageHeight - 492) * .5 - 140;
    //adds gallery.swf to stage at begining of moviie
         Down();
    //PORTFOLIO BUTTON
    //adds eventlistner so that gallery.swf can be loaded
         MovieClip(root).nav.portfolio.addEventListener(MouseEvent.MOUSE_DOWN, Down, false, 0, true);
    function Down(event:MouseEvent = null):void {
    // re adds listener for contact.swf and about.swf
         MovieClip(root).nav.info.addEventListener(MouseEvent.MOUSE_DOWN, Down1, false, 0, true);
         MovieClip(root).nav.about.addEventListener(MouseEvent.MOUSE_DOWN, Down3, false, 0, true);
    //unloads gallery.swf from enter frame if users presses portfolio button in nav
         var requester:URLRequest=new URLRequest("carouselLoader.swf");
         loader = new Loader();
         loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioError);
         function ioError(event:IOErrorEvent):void {
         trace(event);
         try {
         loader.load(requester);
         } catch (error:SecurityError) {
         trace(error);
         this.addChild(loader);
         loader.x = (stage.stageWidth - 739) * .5;
         loader.y = (stage.stageHeight - 500) * .5;
    // sure this is not the best way to do this - but it is unload external swfs
         loader.unload();
         loader2.unload();
         loader3.unload();
    // remove eventlistner and prevents duplication of gallery.swf
         MovieClip(root).nav.portfolio.removeEventListener(MouseEvent.MOUSE_DOWN, Down);
    //INFORMATION BUTTON
         //adds eventlistner so that info.swf can be loaded
         MovieClip(root).nav.info.addEventListener(MouseEvent.MOUSE_DOWN, Down1, false, 0, true);
         function Down1(event:MouseEvent = null):void {
         //this re-adds the EventListener for portfolio so that end user can view again if they wish.
         MovieClip(root).nav.portfolio.addEventListener(MouseEvent.MOUSE_DOWN, Down, false, 0, true);
         MovieClip(root).nav.about.addEventListener(MouseEvent.MOUSE_DOWN, Down3, false, 0, true);
         var requester:URLRequest=new URLRequest("contactLoader.swf");
         loader2 = null;
         loader2 = new Loader();
         loader2.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioError);    
         function ioError(event:IOErrorEvent):void {
         trace(event);
         try {
         loader2.load(requester);
    }      catch (error:SecurityError) {
         trace(error);
         addChild(loader2);
         loader2.x = (stage.stageWidth - 658.65) * .5;
         loader2.y = (stage.stageHeight - 551.45) * .5;
    loader.unload();
    loader2.unload();
    loader3.unload();
         // remove eventlistner and prevents duplication of info.swf
         MovieClip(root).nav.info.removeEventListener(MouseEvent.MOUSE_DOWN, Down1);
    //ABOUT BUTTON
         //adds eventlistner so that info.swf can be loaded
         MovieClip(root).nav.about.addEventListener(MouseEvent.MOUSE_DOWN, Down3, false, 0, true);
         function Down3(event:MouseEvent = null):void {
         //this re-adds the EventListener for portfolio so that end user can view again if they wish.
         MovieClip(root).nav.portfolio.addEventListener(MouseEvent.MOUSE_DOWN, Down, false, 0, true);
         MovieClip(root).nav.info.addEventListener(MouseEvent.MOUSE_DOWN, Down1, false, 0, true);
         var requester:URLRequest=new URLRequest("aboutLoader.swf");
         loader3 = null;
         loader3 = new Loader();
         loader3.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioError);
         function ioError(event:IOErrorEvent):void {
         trace(event);
         try {
         loader3.load(requester);
    }      catch (error:SecurityError) {
         trace(error);
         addChild(loader3);
         loader3.x = (stage.stageWidth - 482) * .5 - 260;
         loader3.y = (stage.stageHeight - 492) * .5 - 140;
         loader.unload();
         loader2.unload();
         loader3.unload();
         // remove eventlistner and prevents duplication of info.swf
         MovieClip(root).nav.about.removeEventListener(MouseEvent.MOUSE_DOWN, Down3);
         stop();

  • Can not load an external swf file from my site

    Hi ...
    I have a fla file which is loading external swf files from my local folders.
    I inserted some of the swf files to a web site and tried to load them from the site, not from my local folder...
    So it gave me a security error like below:
    *** Güvenlik Sanal Alanı İhlali ***security domain-area violation
    http://www.celiktek.com.tr/KIRIL.swf' SecurityDomain öğesi -- security domain element, 'file:///C|/Users/Acer/AppData/Local/Temp/Untitled%2D1.swf' uyumsuz bağlamına erişmeye çalıştı - tried to reach this incompatible url
    SecurityError: Error #2070: Güvenlik sanal alan ihlali -- security area violation: http://www.celiktek.com.tr/KIRIL.swf arayanı - searcher of this can not reach stage in file:///C|/Users/Acer/AppData/Local/Temp/Untitled%2D1.swf içindeki Stage'e erişemiyor. -
    at flash.display::Stage/requireOwnerPermissions()
    at flash.display::Stage/get numChildren()
    at KIRIL_fla::MainTimeline/frame1()
    so in my computer, I can load this swf , but how from a website ?
    thnx ...

    Thnaks ...
    I tried to use the securiyt panel that is openede and I added there my site
    www.celiktek.com.tr/KIRIL.swf
    but I still take the error
    *** Güvenlik Sanal Alanı İhlali ***
    http://www.celiktek.com.tr/KIRIL.swf' SecurityDomain öğesi, 'file:///C|/Users/Acer/AppData/Local/Temp/Untitled%2D1.swf' uyumsuz bağlamına erişmeye çalıştı
    SecurityError: Error #2070: Güvenlik sanal alan ihlali: http://www.celiktek.com.tr/KIRIL.swf arayanı file:///C|/Users/Acer/AppData/Local/Temp/Untitled%2D1.swf içindeki Stage'e erişemiyor.
    at flash.display::Stage/requireOwnerPermissions()
    at flash.display::Stage/get numChildren()
    at KIRIL_fla::MainTimeline/frame1()
    from my code
    var req:URLRequest=new URLRequest("http://www.celiktek.com.tr/KIRIL.swf");
    var lod:Loader=new Loader();
    lod.load(req);
    addChild(lod);
    lod.x=0;
    does this code works on your computer ... I know it is a weird question ... you dont have to try ...

  • 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);

  • Loading external swf files in a swf - Error#1009

    I have been having trouble using a swf file within a swf file.   The external swf files all work as expected.  However when used within another swf file I get the standard TypeError #1009 for some of my swfs.   The external swf files are mainly actionscript 3 files.  A typical swf file will have an object (or objects) in the library which has an export for ActionScipt property enabled and an addEventListener(Event.ENTERFRAME, somefunction).   About four years ago when I had to do some work with AS2 I seemed to get around a similar issue with the _lockroot method but this is no longer part of AS3. I have searched various forums and note that I am not the only one with this issue but did not find any relevant solutions.   If anyone could give me any ideas on how to get around this it would be appreciated.
    Regards
    Norman

    Hi,
    I have added a download to rapidshare and its link is:
    Download link: http://rapidshare.com/files/380202712/ExtSwfs.zip
    The main file Training01.fla has been set up with links to download several swf's.   The links that do not work properly are those labelled :  Module6 and Module 8.   The first Module 6 connects to a function that is a variation of how I was trying to load external swfs using Application Domain, while Module 8 is a link to a swf that uses and external class.  Module 8 is supposed to load with rotating stars, while Module 6 loads the same file as the link called Module 1.   As soon as I use the two links Module 6 or Module 8 the whole lot ceases to work properly.  I did also follow through the examples on the Adobe site.  The examples for Module 6 and Module 8 are tutorials I have used from the Internet as part of my training from the site FlashMyMind.com but they replicate the type of work we have been doing with respect to using ActionScript3.
    Re my background, at this stage I am self-taught using tutorials on the web and whatever books I can lay my hands on here.  There is no structured training available where I live as there is insufficient demand and no books available on Flash or ActionScript at the local book stores or libraries so the books are ones I have ordered via the Internet.  The one I am currently using apart from Adobe Classroom in a Book Flash CS4 is O'Reilly's Learning ActionScript 3.0 a Beginners Guide.
    The other problem I have been trying to solve and still researching is why one loses sound in the flash player when playing flv files, if the user has selected or restarted a video (or videos) many times eg 25 to 30 times as we create video training files and serve them to the user within the flash environment using Flash Player 9 and IE6.
    Regards
    Norman

  • How to load and unload more than one external swf files in different frames?

    I do not have much experience on Adobe Flash or Action Script 3, but I know the basics.
    I am Arabic language teacher, and I design an application to teach Arabic, I just would like to learn how to load and unload more than one external swf files in different frames.
    Thanks

    Look into using the Loader class to load the swf files.  If you want to have it happen in different frames then you can put the code into the different frames.

  • FAQ: How do I load an external SWF file into a parent SWF file?

    A ton of Flash users visit Adobe’s we site every month wondering  about how to load an external SWF file from within another SWF.
    Adobe's own TechNote on the subject attempts to answer the basic question, along with some common follow-up questions, including:
    How do I load more than one SWF?
    How do I load a SWF into a specific location in the display list?
    How do I resize the loaded SWF?
    How do I set its X and Y location?
    Here are some additional resources that elaborate on loading content and on working with the display list:
    Sample files for the above TechNote. A set of 3 FLA and 3 corresponding SWF files, including a parent SWF and 2 SWFs that the parent loads.
    Help > AS3 Developer’s Guide > Loading an external SWF file
    Help > AS3 Developer’s Guide > Loading display content dynamically
    Loading multiple external SWFs within a main SWF – CreativeCow.net forums
    Video tutorial: ActionScript 101 – Episode 6: Adding named objects to the Stage. By Doug Winnie. An example of how to add the loaded external asset to the Stage and modify its location or other properties.
    Video tutorial: Preloading in ActionScript 3.0.  By Lee Brimelow. A slightly more complicated example, showing how to  make the parent SWF display information about the progress of loading  the external SWF.
    Tutorial: Loading and unloading SWFs - FlashAndMath.com
    This article provides several examples of how to communicate between a parent SWF file and the loaded SWF:
    SWF to SWF Communcation via ActionScript 3.0 (by kglad)

    quote:
    Originally posted by:
    NedWebs
    You now seem to want to get rid of the swf once it has loaded
    and played itself thru. To do that you would need to have something
    in the swf itself that triggers its removal in its last frame. The
    following might work...
    MovieClip(this.parent).removeChild(this);
    Unfortunately I couldn't get this to work. I placed it on the
    last frame of the SWF to be called - is that right?
    I am not sure I am doing it correctly...

  • Trouble loading an external swf file implemented with AS3

    I am using Adobe Flash CS3
    At first, I tried
    swf_mc.loadMovie("//swf file
    location");
    It gave me
    quote:
    Warning: 1060: Migration issue: The method loadMovie is no
    longer supported.
    USE: var l = new Loader(); addChild(l); l.load(new
    URLRequest("your url"));.
    Well, the given code isn't working at all.
    But since it is a migration error, I thought maybe I can just
    save it into Flash5 format with AS1. Then it worked with most
    external swf files. However, the one I am trying to load is a swf
    file with AS3, so my older version swf can't load it at all.
    Anyone has any ideas about how to load an external AS3 swf
    file?

    AS3 is a completely different beast than AS1 or 2. loadMovie
    was removed from the language.
    The answer to your question is two fold. First, Adobe was
    kind enough to give us the code when it finds a migration issue.
    var _ldr:Loader = new Loader();
    addChild( _ldr );
    _ldr.load( new URLRequest( "your url") );
    Handling progress has also changed. I have a ContentLoader
    package on my site that you're free to use that should familiarize
    you with the new way that things are done in AS3.
    http://sd-dezign.com/blog/?page_id=10

  • Loading an external SWF from an external SWF

    Hello,
    I'm somewhat caught between a rock and a hard spot on a flash
    site project. Here is the situation:
    I have created a parent movie (which loads all external SWFs
    inside of it) that has the menu navigation built into it. However,
    my client wants me to place some more links inside of the external
    SWFs that lead to other pages (external SWFs) of the site. Is this
    at all possible? I was hoping there is a way to tell a button in an
    external SWF to make the parent movie switch between external SWFs.
    Any and ALL help is very much appreciated. Thank you.
    Another question: does this involve using the _parent script?
    Elijah

    Hello,
    Thank you for replying. Here is exactly what I'm needing to
    do:
    We will call the parent file "index.swf". Inside "index.swf"
    I have a "holder" for external swf files to load into when I call
    on them from the main menu buttons on "index.swf". When a customer
    comes to the site, the "index.swf" file initially loads
    "welcome.swf". Inside of "welcome.swf", I have some images that I
    want to make into links to other external swf files.
    My problem is when someone clicks on one of those pictures I
    want the "index.swf" file to open up the corresponding external swf
    file in its "holder", where "welcome.swf" currently resides. Also,
    all of these swf files ("index.swf" included) have stand-alone FLA
    files, none are attached to one another. I have never worked with
    "levels" before, would that be necessary in this case? I have
    attached the code for the external swf loader.
    I hope that gives you a better idea of what I'm trying to
    accomplish.
    Thanks again.
    Elijah
    CODE:

  • Loading external swf file

    Hi all,
    I am trying to load an external SWF file into my website.. but it is not working. Here is my code
    public var CD:Loader=new Loader();
    protected function application1_creationCompleteHandler(event:FlexEvent):void
    CD.load(new URLRequest("http://localhost/assets/slide.swf"));
    addChild(this.CD);
    CD.x=2;
    CD.y=170; 
    // TODO Auto-generated method stub
    Can anyone tell me what is going wrong..
    The url is correct and its working in my browser when i type 'http://localhost/assets/slide.swf' in the browser... So problem is with flex..

    I am pretty sure that Flash's security measures prevents the coder from loading swfs that are not local to the swf that is trying to load them.  So the swf that is trying to load another swf would have to be on the same system or same networked server.  From what I have experienced its best to reference the location of the files from the swf that is doing the loading.  I am not sure if you are still referencing your swf as "http://localhost/assets/slide.swf" but that might be a problem as well.
    so
    mainfolder
    movie.swf
    assets
    slide.swf
    so in movie.swf
    //Start: Put in desired function
    var swfLoader:Loader = new Loader();
    swfLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete);
    swfLoader.load(new URLRequest("assets/slide.swf"));
    //End
    Also add this function
    public function loadComplete(e:Event):void
         stage.addChild(e.target.content);
    This might help explain it
    http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/display/Loader.html
    the first set of bullet points highlight the security options
    ps. I got this working on my end, copy and pasted the code, of course i had to recreate the file system structure and slide.swf

  • How do I find the width of an external swf file that I am loading in

    I have loaded in an external swf file and it works fine.
    However, when I get the width dimensions of the movieclip that is housing the external swf file it gives me a '0' for the width.
    Thanks for your time.

    you must wait until loading is complete before trying to access the loaded objects width.  at that point you can determine the width,height of the onstage/backstage objects in frame 1 of the loaded swf.

  • Loading external swf file in a new window

    Hi,
    I've got a few .swf files with video tutorials I've created using Captivate 4.
    I wanted to link them so I've created a main screen with menu with buttons in Flash.
    I've added AS to load the external swf files but they load in the same window. How can I load these .swf files in seperate window so that you could get back to the main window after you've finished watching?
    Here's my code:
    stop();
    var myLoader:Loader = new Loader();
    button1_btn.addEventListener(MouseEvent.CLICK, movie1_1);
    function movie1_1(e:MouseEvent):void
        var myURL:URLRequest = new URLRequest("01_01_Welcome.swf");
        myLoader.load(myURL);
        addChild(myLoader);
    I'm also attaching screenshot with menu in flash

    I've deleted the line and now the code lookes like that:
    stop();
    var myLoader:Loader = new Loader();
    button1_btn.addEventListener(MouseEvent.CLICK, movie1_1);
    function movie1_1(e:MouseEvent):void
        var myURL:URLRequest = new URLRequest("01_01_Welcome.swf");
        addChild(myLoader);
    Unfortunately, it doesn't load the .swf file when you click on the button...

  • How to load External swf file in AIR

    I try this code its working in computer but when I publish this file in .apk or .ipa , my external swf file is not opening
    (I include my external file as well)
    places_btn.addEventListener(MouseEvent.MOUSE_DOWN, newvid);
    function newvid(event:MouseEvent) {
         trace("you clicked me");
         var loadit = new Loader();
         addChild(loadit);
         loadit.load(new URLRequest("scene02.swf"));

    thx boss its working great
    I have 3 scenes; load scene code is working great
    1. How can I unload the scene?
    2. Can I unload all scenes or one by one?
    can I unload some think like this
    Load scene 2 , unload scene 1 and scene 3
    Load scene 3, unload other all scene
    i try this
    load2.addEventListener(MouseEvent.MOUSE_DOWN, newvid);
    function newvid(event:MouseEvent) {
              trace("you clicked me");
              var loadit = new Loader();
              addChild(loadit);
        var _lc:LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain, null);
        loadit.load(new URLRequest("scene02.swf"), _lc);
              loadit.unload();
    load3.addEventListener(MouseEvent.MOUSE_DOWN, newvid1);
    function newvid1(event:MouseEvent) {
              trace("you clicked me");
              var loadit = new Loader();
              addChild(loadit);
        var _lc:LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain, null);
        loadit.load(new URLRequest("scene03.swf"), _lc);
              loadit.unload("scene01.swf scene02.swf");

Maybe you are looking for

  • How can i see BAPI's and RFC's in VC?

    Hi all, my problem is that i cannot see the BAPI's  and the RFC's on VC, any ideas? i have a user in my portal and i have superadmin and CV roles but when i start VC and click on "find data" a message of error appears, i have a user in r3 system too,

  • SSL for Enterprise Manager (on 10g)

    Hi all, Database 10g'a Enterprise manager in its default installation (on Linux) requires HTML browser access to the server's port 5500. There is a lot of authentication (server OS, oracle database credentials) going on. How do I encrypt this traffic

  • Problem with VO Extension (Urgent.......)

    Hi, I extended one VO which is not based on any VO. Is it mandatory to add the new VO to the Application module which the old VO is referencing? The problem is when I am wirting the where clause to the new VO, I am not getting any error but my VO has

  • Migrate Access Reports to APEX

    We already built reports by using Microsoft Access to query one Oracle Schema (11G R2) and generate all the access based reports. We would like to migrate the Access based reports to APEX platform, Are there any best approaches to achieve these? Than

  • New iPhoto not working at all - blank library on startup

    I just upgraded my iLife package to 09 and must admit that I've never experienced this much trouble in my 15 years as an apple. First of all: Upon upgrading and first launch of iPhoto I was met by a complete blank library. I quickly checked all my pr