Skip to main content
Coreydwillis
Known Participant
February 13, 2013
Answered

Access Child of Loaded SWF File

  • February 13, 2013
  • 3 replies
  • 757 views

I've read through many forum threads and articles, but I still can't quite figure this one out. Here's my basic setup: Container > LoadedSWF File > MovieClip. I want to access that movie clip that's inside the swf file that's loaded into the container.

This loading code is inside a class that directly associated with an empty MovieClip on the stage. Here are the relevant parts of the code:

public var loadDrawing:Loader = new Loader;

drawLoad = "E002.swf";

loadDrawing.load(new URLRequest(drawLoad)); //I've loaded the drawing into loadDrawing

This is essentially what I want, but it doesn't work exactly like this:

jumpNumber = "j1"; //this matches the instance name of the movie clip I want to control

loadDrawing.drawLoad.jumpNumber.x = 100;


This way I can control that MovieClip that's inside the swf, that's inside the loader. Also, I will need to wait for the clip to completely load before I try accessing items within it, right?

This topic is closed to new replies. Start a new post to keep the conversation going.
Correct answer

>>

jumpNumber = "j1"; //this matches the instance name of the movie clip I want to control

loadDrawing.drawLoad.jumpNumber.x = 100;


If you want to use a string like you show here then you need to use bracket access like so:

loadDrawing.drawLoad[jumpNumber].x = 100;

or else just do like:

loadDrawing.drawLoad.j1.x = 100;

However, you'll also need to cast loadDrawing.content to a MovieClip to be able to do that... so actual code would be like:

MovieClip(loadDrawing.content).drawLoad[jumpNumber].x = 100;

or else just do like:

MovieClip(loadDrawing.content).drawLoad.j1.x = 100;

3 replies

Correct answer
February 13, 2013

>>

jumpNumber = "j1"; //this matches the instance name of the movie clip I want to control

loadDrawing.drawLoad.jumpNumber.x = 100;


If you want to use a string like you show here then you need to use bracket access like so:

loadDrawing.drawLoad[jumpNumber].x = 100;

or else just do like:

loadDrawing.drawLoad.j1.x = 100;

However, you'll also need to cast loadDrawing.content to a MovieClip to be able to do that... so actual code would be like:

MovieClip(loadDrawing.content).drawLoad[jumpNumber].x = 100;

or else just do like:

MovieClip(loadDrawing.content).drawLoad.j1.x = 100;

Coreydwillis
Known Participant
February 13, 2013

I see what you're saying, but that doesn't help me get me the access I need.

It's not as easy as listing those three things to access the child of a loader of a swf. When I do "loadDrawing.drawLoad.j1.x = 100;" it doesn't know what drawLoad is either, even though it knows the value of that variable. There's a different syntax than this for accessing loader type stuff, but I can't figure out what it is.

Edit: You added more to your post while I was replying. :-) That's closer to what I'm looking for, but I'm still having trouble getting it to work.