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 783515
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T20:33:37+00:00 2026-05-14T20:33:37+00:00

I am loading one swf into another using the Loader class, but when the

  • 0

I am loading one swf into another using the Loader class, but when the child swf finishes loading and is added to the display list, its Document Class is not instantiated. I have a few trace statements that should execute when the object is created, but nothing is happening when loaded into the parent SWF. When I compile the child SWF on its own, the Document Class runs as expected.

So I’m wondering… how do I associate a child SWF’s Document Class with Loader.content?

Code updated with a solution from Kishi below.

public class Preloader extends Sprite {
    import flash.net.*;
    import flash.display.*;
    import flash.events.*;

    // code in parent SWF's Document Class (Preloader.as)
    private var swfLoader:Loader;
    public var mainMovie:MovieClip;

    public function Preloader(){   
        swfLoader = new Loader();
        swfLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, loaderDone);
        swfLoader.load(new URLRequest("mainmovie.swf"));
    }

    private function loaderDone(e:Event):void {
        // Cast Loader.content to MovieClip
        mainMovie = MovieClip(swfLoader.content);

        mainMovie.addEventListener(Event.ADDED_TO_STAGE, mainMovieAddedListener);

        addChildAt(mainMovie, 0);

    }
    private function mainMovieAddedListener(e:Event):void {
       // init() not necessary
    }
}

// MainMovie.as runs after casting swfLoader.content to MovieClip

public class MainMovie extends Sprite {

    public function MainMovie(){
        trace('MainMovie WHATTUP'); 
    }

    public function init():void {
        trace('init'); 
    }
}

Cheers!

  • 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-14T20:33:37+00:00Added an answer on May 14, 2026 at 8:33 pm

    The problem is how you are trying to access the swf instance.

    First, the document class instance is referred by Loader‘s content property. You’d reference it like this:

    var swf:DisplayObject = swfLoader.content;
    

    But, even then you’d have to cast the DisplayObject either to it’s real class (MainMovie, in this case) or a dynamic class (such as MovieClip), as you are trying to use a custom property, that’s not part of DisplayObject itself. Therefore, you could call MainMovie.init() like so:

    var swf:MovieClip = MovieClip(swfLoader.content);
    swf.init();
    

    Hope that helps.

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

Sidebar

Ask A Question

Stats

  • Questions 495k
  • Answers 495k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The main reason is that master is not calibrated for… May 16, 2026 at 11:30 am
  • Editorial Team
    Editorial Team added an answer The most likely cause is a missing or unregistered/corrupt ActiveX… May 16, 2026 at 11:30 am
  • Editorial Team
    Editorial Team added an answer no, it is File.Open who lock files. try to put… May 16, 2026 at 11:30 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I'm loading an swf file into my main application using URLLoader, I want to
I have a Main class loading 2 SWF (loader and viewer, also with document
I'm using Loader::load() successfully to load swfs into my main swf and then I
I am having an issue loading an external swf into my as3 project. I
One advantage of PNG is full alpha transparency, which allows you to have smooth
I´m having troubble positioning an externally loaded swf. It simply does not respond to
I'm moving to a pure as3 environment into flex and I have a question
Alright, currently I have my SWF hitting a php file that will go and
how to load multiple content placeholders with user controls from server side using C#..
If one of relational databases paradigms is to be tuple oriented we have the

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.