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

Access Child of Loaded SWF File

New Here ,
Feb 13, 2013 Feb 13, 2013

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?

TOPICS
ActionScript
724
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

Deleted User
Feb 13, 2013 Feb 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

...
Translate
Guest
Feb 13, 2013 Feb 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;

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
New Here ,
Feb 13, 2013 Feb 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.

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
New Here ,
Feb 13, 2013 Feb 13, 2013
LATEST

Here's what I'm putting. I found out that this gets me to the E002 timeline which is where I want to be, but it can't find the j1 one on there. I have a MovieClip with the instance name "j1" on E002.

MovieClip(loadDrawing.content)[jumpNumber].addChild(point);

Here's the error I'm getting:

ReferenceError: Error #1069: Property j1 not found on E002_fla.MainTimeline__Preloader__ and there is no default value.

          at classes::loader/onComplete()

I thought it was because it was trying to access it before it's loaded so I did this, but still get the same error:

private function loadIt()

                    {

                              loadDrawing.load(new URLRequest(drawLoad));

                              loadDrawing.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);

                    }

                    function onComplete (event:Event):void

                    {

                              MovieClip(loadDrawing.content)[jumpNumber].addChild(pointer);

                    }

I actually was able to get it to work on one of my files that was very small because it was fully loaded when it tried to access J1, but the Event.COMPLETE isn't actually waiting until the other swf files are completely loaded. I'm not sure why not...

Message was edited by: Coreydwillis

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