Skip to main content
socalfish-fDJTBM
Inspiring
March 16, 2009
Question

Going to a loaded frame in a loaded swf

  • March 16, 2009
  • 8 replies
  • 877 views
I've been successful to load a external swf using the loader. Lesson_mc is a movieclip I have on stage that I am loading the external swf. I have some masking that is there, that is why the movieclip. myLoader is a Load object. I can find the swf loaded using the debugger and see the currentLabel and Frame but when I try to get the information it sends a DisplayObject error. I have a Menu in the Main Window that controld the navigation. Getting to the frame on the first click works but trying to go to a frame within the same sef does not. Any thoughts?

myRequest = new URLRequest("overview09.swf");
myLoader = new Loader();
myLoader.load(myRequest);
addChild(myLoader);

myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, LessonLoad);
function LessonLoad(evt:Event):void{
trace("Lesson Loaded = ");
Lesson_mc.addChild(myLoader);
}//end function
This topic has been closed for replies.

8 replies

socalfish-fDJTBM
Inspiring
March 17, 2009
Manno, thanks for the reminding me to type cast. The light came on when I read that and I figured what I was doing wrong. I kept trying to get to the information in the Loader when I should of been using the Loader.content information.

I am waiting for the loaded swf to be complete before trying to go to the frame called.

THANKS for the Assistance!
socalfish-fDJTBM
Inspiring
March 16, 2009
I will check that out in just a few. I have found a work around to my problem thoug. I assigned a variable with the Loader content...

See my function below.

function jump(frm):void {
//this[topLevelMenu].gotoAndStop(frm);
frameLevelMenu = frm;
trace("\n" + "JUMP FUNCTION frm = " + frm);

if(currentTopLevel == topLevelMenu){
var A_Lesson_mc = myLoader.content;
A_Lesson_mc.gotoAndStop(frm);
trace("Same Top Level = " + A_Lesson_mc.currentLabel);

}//end else if
else if(topLevelMenu != "Menu"){
gotoAndStop(topLevelMenu);
}//end if

} // Accordion Jump Function
Inspiring
March 16, 2009
socalfish wrote:
> trace("Same Top Level = " + myLoader.content.currentFrame);
>
> This points to the Loader Object and shows the frame in the external swf. It
> throws an error.... Access of possibly undefined property currentFrame through
> a reference with static type flash.display:DisplayObject.
>

Ah, cast it to a MovieClip:
trace("Same Top Level = " + MovieClip(myLoader.content).currentFrame)

I think that should do it.
Flash does not know it's a movieClip with frames etc., you need to tell
it so.

NedWebs:
why is it bad to add the Loader before it's content is loaded? If you
don't mind showing the first frame and don't really care to exercise
exact control of when it is shown you might as well leave it like it is
now or am I wrong?
Ned Murphy
Legend
March 16, 2009
There were a couple of issues with what was being done, or at least I get that impression from the descriptions. The movie that was being loaded was being utilized immediately to take some kind of action, so if the addChild is used immediately following the load command, the chances of the loading movie having it's brains set up sufficently to do what it needs to do is slim. And it's a wasted effort to be moving the same child to two different parents... first the stage, then the containing movieclip. Sounds like there's an orphan somewhere there.
Inspiring
March 17, 2009
I figured the currentframe property was accessed in or after the COMPLETE event although it was not clear from the code.
You're right that I missed the reparenting of the loader in the COMPLETE eventhandler. redundant but it should not lead to the errors he experiences.
socalfish-fDJTBM
Inspiring
March 16, 2009
trace("Same Top Level = " + myLoader.content.currentFrame);

This points to the Loader Object and shows the frame in the external swf. It throws an error.... Access of possibly undefined property currentFrame through a reference with static type flash.display:DisplayObject.
Inspiring
March 16, 2009
then what is the exact error?

My solution does not work, docs tell me init is dispatched after
comlete. I had it hte other way round...



socalfish wrote:
> This DisplayObject stuff is confusing to me. Basically what I have is a
> MovieClip on the stage. I want to load an external swf into the MovieClip. All
> that works and I am able to add the Loader Object as a child into the MovieClip
> (Lesson_mc). In my external clip in the beginning a check a variable. That
> sends me to the frame I want. Now that the MovieClip is loaded I want to go to
> another frame within the same external swf. That is where I don't understand. I
> try and read the current frame in the external swf and it sends the
> DisplayObject error.
>
>
>
socalfish-fDJTBM
Inspiring
March 16, 2009
This DisplayObject stuff is confusing to me. Basically what I have is a MovieClip on the stage. I want to load an external swf into the MovieClip. All that works and I am able to add the Loader Object as a child into the MovieClip (Lesson_mc). In my external clip in the beginning a check a variable. That sends me to the frame I want. Now that the MovieClip is loaded I want to go to another frame within the same external swf. That is where I don't understand. I try and read the current frame in the external swf and it sends the DisplayObject error.

Ned Murphy
Legend
March 16, 2009
You should still remove that 4th line of code. As far as the primary issue goes, can you provide the complete error message that you get? Also, can you show the code that you are using to try to read the current frame?
Ned Murphy
Legend
March 16, 2009
I didn't follow most of the discussion, but in your code you are adding the loader before it has loaded (4th line). Try removing that and see if your problem is still evident.
Inspiring
March 16, 2009

OTTOMH:
don't you need the INIT event instead of the COMPLETE event?

socalfish wrote:
> I've been successful to load a external swf using the loader. Lesson_mc is a
> movieclip I have on stage that I am loading the external swf. I have some
> masking that is there, that is why the movieclip. myLoader is a Load object. I
> can find the swf loaded using the debugger and see the currentLabel and Frame
> but when I try to get the information it sends a DisplayObject error. I have a
> Menu in the Main Window that controld the navigation. Getting to the frame on
> the first click works but trying to go to a frame within the same sef does not.
> Any thoughts?
>
> myRequest = new URLRequest("overview09.swf");
> myLoader = new Loader();
> myLoader.load(myRequest);
> addChild(myLoader);
>
> myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, LessonLoad);
> function LessonLoad(evt:Event):void{
> trace("Lesson Loaded = ");
> Lesson_mc.addChild(myLoader);
> }//end function
>
>