Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

loading external SWF

Community Beginner ,
Dec 30, 2012 Dec 30, 2012

I have this code to load an external SWF.  The external SWF is loads an XML file and creates a slideshow from the XML file.  The movie I am loading it into has the following code on a frame and has about 20 layers to it.  It all seems to execute but I dont see the external movie and I am not sure why.  Anyone see a problem with this code or know why it doesnt show up? Thanks

CODE:

this.createEmptyMovieClip("slideshow_mc", 2000);

var my_listener:Object = new Object();

my_listener.onLoadComplete = function(target_mc:MovieClip) {

    target_mc._x = 50;

          target_mc._y = 50;

}

my_listener.onLoadProgress = function(target_mc:MovieClip) {

          trace(target_mc.getBytesLoaded() + " out of " + target_mc.getBytesTotal());

}

var my_loader:MovieClipLoader = new MovieClipLoader();

my_loader.addListener(my_listener);

my_loader.loadClip("slideshow-endsample.swf", slideshow_mc);

this.slideshow_mc.loadMovie("slideshow-endsample.swf", _level0.slideshow_mc);

TOPICS
ActionScript
1.4K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Dec 31, 2012 Dec 31, 2012

The last thing I will offer for the moment... if you are loading a file that makes use of _root references, that might be the reason you have problems when you load it into another file into a movieclip.  Within that loaded file you should be setting the _lockroot property to true so that it does not look to the main file for its _root references.

Translate
LEGEND ,
Dec 30, 2012 Dec 30, 2012

The last two lines you show are could represent a conflict of interests. 

my_loader.loadClip("slideshow-endsample.swf", slideshow_mc);

this.slideshow_mc.loadMovie("slideshow-endsample.swf", _level0.slideshow_mc);

Both of those lines are for loading an external file, and it appears they are both trying to load the same one.  Since you are set up for the MovieClipLoader, which is the better option if you need to know when loading is complete, first try getting rid of the last line and see how things go.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 30, 2012 Dec 30, 2012

ok So I have this code now that works but it replaces my whole original movie and I am not sure why.  If I remove the last line.  I nothing happens.

CODE:

this.createEmptyMovieClip("slideshow_mc", 2000);

var my_listener:Object = new Object();

my_listener.onLoadComplete = function(target_mc:MovieClip) {

    target_mc._x = 50;

          target_mc._y = 50;

}

my_listener.onLoadProgress = function(target_mc:MovieClip) {

          trace(target_mc.getBytesLoaded() + " out of " + target_mc.getBytesTotal());

}

var my_loader:MovieClipLoader = new MovieClipLoader();

my_loader.addListener(my_listener);

my_loader.loadClip("slideshow-endsample.swf", _level0.slideshow_mc);

_root.loadMovie("slideshow-endsample.swf", _level0.slideshow_mc);

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 31, 2012 Dec 31, 2012

I already indicated that you are doing two different loadings with the code you show.  Use one method or the other, but not both.  If you want to use loadMovie, then try using just....

    this.createEmptyMovieClip("slideshow_mc", 2000);

    loadMovie("slideshow-endsample.swf", this["slideshow_mc"]);

The reason you replace your original movie is because you are using the loadMovie method (_root.loadMovie... a method of the _root object), which will replace whatever you have in the _root with the loaded movie.

But using loadMovie eliminates your ability to track the loading progress and manipulation of position once the movie is loaded.  If those are necessary features, then use the MovieClipLoader approach instead.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 31, 2012 Dec 31, 2012

To use the MovieClipLoader approach you only need to use...

this.createEmptyMovieClip("slideshow_mc", 2000);

var my_listener:Object = new Object();

my_listener.onLoadComplete = function(target_mc:MovieClip) {

    target_mc._x = 50;

    target_mc._y = 50;

}

my_listener.onLoadProgress = function(target_mc:MovieClip) {

    trace(target_mc.getBytesLoaded() + " out of " + target_mc.getBytesTotal());

}

var my_loader:MovieClipLoader = new MovieClipLoader();

my_loader.addListener(my_listener);

my_loader.loadClip("slideshow-endsample.swf", this["slideshow_mc"]);

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 31, 2012 Dec 31, 2012

The last thing I will offer for the moment... if you are loading a file that makes use of _root references, that might be the reason you have problems when you load it into another file into a movieclip.  Within that loaded file you should be setting the _lockroot property to true so that it does not look to the main file for its _root references.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 31, 2012 Dec 31, 2012

if I want to turn this line my_loader.loadClip("slideshow-endsample.swf", this["slideshow_mc"]); to where the "Slideshow-endsample.swf" is a variable name like currentArray.  How would I do that?  cause substituting currentArray doesnt seem to work.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 31, 2012 Dec 31, 2012

ok I got it.  Thanks.

my_loader.loadClip(currentArray+".swf", this["slideshow_mc"]);

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 31, 2012 Dec 31, 2012
LATEST

You're welcome

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines