views:

612

answers:

3

Good morning friendly Flashers ;) So I've been trying since yesterday to just load a SWF file into my main movie. I've done this before just placing code inside a movieClip, but this time I'm working inside of Class files. I have my main class which calls a function inside of my sub class which contains the loader. My problem is that the swf will load (I can tell via traces) but I cannot see the loaded swf :(

Below is the code inside of my sub class

package src.howdinicurtain {

import flash.net.*;
import flash.display.*;
import flash.events.Event;

public class HowdiniFrame extends MovieClip { 
 //public var splashLoader;
 public var introLoader:Loader = new Loader();
 public var introContainer:MovieClip;
 private var holdX:Number;
 private var holdY:Number;

 public function HowdiniFrame(url:String, loadX, loadY):void {
  holdX = loadX;
  holdY = loadY;

  this.addChild(introLoader);
  //this.addChild(introContainer);

  introLoader.load(new URLRequest(url));

  introLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,swfLoaded);
 }

 public function swfLoaded(e:Event):void {
  introLoader.contentLoaderInfo.removeEventListener(Event.COMPLETE, swfLoaded);
  introContainer = introLoader.content as MovieClip;
  //introContainer = MovieClip(introLoader.contentLoaderInfo.content);

  addChild(introContainer);

  introContainer.x = holdX;

  introContainer.y = holdY;

  trace("holdX = "+holdX);
  trace("holdY = "+holdY);

 } 

}

}

The code above will load the swf file, I can see the swf files trace statements from the start of the animation to the end, but I cannot actually see the swf file inside of the main swf.

Traces:

  • The SWF file is = intro.swf
  • Intro Movie Starts :)
  • contentLoaderInfo event removed
  • Intro Movie Ends :(

Here is the code in my main class that calls the sub class function that loads the movie:

var introPath:String = xmlOutput.intro;
trace("The SWF file is = "+introPath+"\r"+"\r");
hc = new HowdiniFrame(introPath, 0, 20);

I swear I throw my code into the first frame of a movieClip and it works fine, I see the animation in the loaded SWF play instantly, but when I have my code inside of Class files I cannot see my SWF at all :( thoughts? ideas? Thanks for any tips!

~ Leon

A: 

/facepalm again

I forgot to add the HowdiniFrame instance to the display list in my main class!

hc = new HowdiniFrame(introPath, 0, 20);
addChild(hc); //<- forgot this :'(
Leon
+1  A: 

What is hc? Is that a MovieClip on the stage? What if you try:

hc.addChild(new HowdiniFrame(introPath, 0, 20));

or if hc is not a clip on the stage

hc = new HowdiniFrame(introPath, 0, 20);
addChild(hc);
Simon Groenewolt
Yeah I was missing addChild(hc) thanks
Leon
+1  A: 

Always treat your children right. Don't forget to add them in everything you do or else you're a bad parent.

Preston
Haha, that should be a tagline on a Flash geek t-shirt at threadless or something....
Leon