Futurescale, Inc. PureMVC Home

The PureMVC Framework Code at the Speed of Thought

Over 10 years of community discussion and knowledge are maintained here as a read-only archive.

New discussions should be taken up in issues on the appropriate projects at https://github.com/PureMVC

Pages: [1]
Author Topic: addChild Problem  (Read 5016 times)
Posts: 3

View Profile Email
« on: April 20, 2011, 05:18:13 »

Hi There,

We have just changed the way our API works, and now it downloads a remote SWF so we only have to maintain one set of code. However, this has broken the integration in PureMVC and I can't work out how it should be done.

Currently, I register the old API in a Proxy, which has a Command that sends all of the requests to it.

The API Loader Class is as follows:


package {

import fl.controls.TextArea;
import flash.display.Loader
import flash.display.LoaderInfo
import flash.net.URLRequest
import flash.events.Event
import flash.display.MovieClip
import flash.system.Security
import com.demonsters.debugger.*;

public class API {

public static var service:Object = { connect: load_service }

public static var clip:MovieClip
public static var GameKey:String
public static var callback:Function;

private static function load_service_complete(e:Event):void {
if (e.currentTarget.content != null && e.currentTarget.content.service != null) {
service = e.currentTarget.content.service
service.connect(GameKey, clip);

trace ("[API] Service Successfully Loaded")
} else {
trace("[API] failed to load")

private static function load_service(mainMovie:MovieClip, GameKey:String, callbk:Function):void {

API.clip = mainMovie;
API.GameKey = GameKey;
hAPI.callback = callbk;

if (service.submitScore == null) {

var loader:Loader = new Loader();

loader.contentLoaderInfo.addEventListener(Event.COMPLETE, load_service_complete);
loader.load(new URLRequest("domain.com/api.swf"));
clip.addChild(loader); // THIS LINE BREAKS IT


The highlighted line above, is the one causing the problem as I can't work out what I need to pass from the Proxy into this class in order to add the SWF to the Movie. It currently says addChild is not defined.

Any help would be great.

« Last Edit: April 20, 2011, 05:19:57 by Nebulous » Logged
Global Moderator
Hero Member
Posts: 2871

View Profile WWW Email
« Reply #1 on: April 25, 2011, 07:28:25 »

It currently says addChild is not defined.

Doesn't look like you've even gotten into PureMVC territory yet. The static clip property and this method that sets it aren't working. I don't immediately see anything wrong, but I suggest using the debugger to check inside the  load_service method and see what the clip and mainMovie properties look like just before trying the addChild.

Pages: [1]