Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 745637
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T09:36:24+00:00 2026-05-14T09:36:24+00:00

I am trying to get an instance of a class to the load an

  • 0

I am trying to get an instance of a class to the load an external swf and show it.
So far I have the following:
1) I wrote a class that uses the Loader class to load an external swf “loadExtSWF”.
2) I have a fla named “MainSWF.fla” that uses a document class “MainSWF.as”.
3) I have the MainSWF.as file that instances “loadExtSWF” and calls loadExtSWF.startLoad to load the swf.

This almost works. The instance of loadExtSWF loads the external swf, but the swf is not displayed.

If I replace the fla’s document class with loadExtSWF (this has an empty constructor) instead of MainSWF, and run loadExtSWF.startLoad, then the external swf is loaded and displayed.

It seems that the way I initially do it, loads the swf to the wrong stage (?).

Any ideas? Thanks for the help.

Bye,
RaamEE

P.S.

If you replace the document class for test_tsscreen from test_tsscreen.as to TSScreen.as, and remove the comment inside the test_tsscreen’s constructor, the swf will be loaded.

my code is:

file test_as3.swf

an external as3 swf file.

file test_tsscreen.fla

the fla is empty and references test_tsscreen.as as its document class.

file test_tsscreen.as

package {

 import flash.display.MovieClip;
 import TSScreen;

 public class test_tsscreen extends MovieClip{
  var tsScreen1;

  public function test_tsscreen(){
//   var tsScreen1:TSScreen = new TSScreen(10,10,100,100,0.5,0);
   var tsScreen1:TSScreen = new TSScreen();
   tsScreen1.startLoad(this.stage);
  }
 }
}

file TSScreen.as

package {
 import flash.display.MovieClip;

 import flash.display.*;
 import flash.net.URLRequest;
 import flash.system.ApplicationDomain;
 import flash.system.LoaderContext;

 import flash.display.Loader;
 import flash.events.Event;
 import flash.events.ProgressEvent; 

 public class TSScreen extends MovieClip implements ITSScreenable{


  public function TSScreen():void{
//   startLoad(this); //Look important comment in above text
  }


  function startLoad(_this:Stage) {
   var mLoader:Loader = new Loader();
   var mRequest:URLRequest = new URLRequest("test_as3.swf");

   mLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onCompleteHandler);
   mLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgressHandler);
   _this.parent.addChild(mLoader);
   mLoader.load(mRequest);
   trace(this.name);
   trace(_this.name);
  }

  function onCompleteHandler(loadEvent:Event) {
   addChild(loadEvent.currentTarget.content);
  }

  function onProgressHandler(mProgress:ProgressEvent) {
   var percent:Number = mProgress.bytesLoaded/mProgress.bytesTotal;
   trace(percent);
  }


 }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T09:36:24+00:00Added an answer on May 14, 2026 at 9:36 am

    As sometimes happens, asking the question leads to finding your answer. After reading the manual, again, I saw that once you add a new swf in AS3, you need to add your new DisplayObject as a child to an existing DisplayObject in an existing DisplayObjectContainer.

    So, the problem I had is that I loaded the external swf properly but didn’t add it to a DisplayList, so it wasn’t displayed.

    Here is a fixed version of the code blocks I quoted earlier

    test_tsscreen.as

    package {

    import flash.display.MovieClip;
    import TSScreen;
    
    public class test_tsscreen extends MovieClip{
        var tsScreen1:TSScreen;
    
        public function test_tsscreen(){
            tsScreen1 = new TSScreen(10,10,100,100,0.5,0);
            //tsScreen1 = new TSScreen();
            this.addChildAt(tsScreen1,1);
        }
    }
    

    }

    TSScreen.as

    package {
    import flash.display.MovieClip;

    import flash.display.*;
    import flash.net.URLRequest;
    import flash.system.ApplicationDomain;
    import flash.system.LoaderContext;
    
    import flash.display.Loader;
    import flash.events.Event;
    import flash.events.ProgressEvent;  
    
    public class TSScreen extends MovieClip {
        private var _xPos:int;
        private var _yPos:int;
        private var _width:int;
        private var _height:int;
        private var _xScale:int;
        private var _yScale:int;
    
        private var _visible:Boolean;
        private var _alpha:Boolean;
        private var _shadow:Boolean;
        private var _backgroundColor:uint;
        private var _rotation:Boolean;
    
        private var _displayTime:int;
    
    
        public function TSScreen():void{
            startLoad();
        }
    
    
        function startLoad() {
            var mLoader:Loader = new Loader();
            var mRequest:URLRequest = new URLRequest("C:/FlashProjects/test_as3.swf");
    
            mLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onCompleteHandler);
            mLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgressHandler);
            addChild(mLoader);
            mLoader.load(mRequest);
        }
    
        function onCompleteHandler(loadEvent:Event) {
            addChild(loadEvent.currentTarget.content);
        }
    
        function onProgressHandler(mProgress:ProgressEvent) {
            var percent:Number = mProgress.bytesLoaded/mProgress.bytesTotal;
            trace(percent);
        }
    
    
    }
    

    }

    If you’d like more information please chapter 04 of the book “FriendsofED Foundation Actionscript 3.0 With Flash CS3” which contains helpful introduction into this subject.

    Hope this helps others with the same problem.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to get the instance name of my class. The way I do
I have sugar crm instance and i was trying to get some data from
I'm trying to load an assembly, instantiate a class from that assembly, and then
I have been trying to make a StringTable class that holds a simple unordered_map<string,
I'm trying to get an image to load in a game that I am
I'm trying get values from a GridView using the following code: foreach (GridViewRow row
I am trying to load this model: class Menu { function show_menu() { $obj
I am trying to get cancan to work with a polymorphic association, i have
I get an error trying to format the following code: The code was copy-pasted
I'm trying to get the hang of MVC architecture. Say I have a plist

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.