Futurescale, Inc. PureMVC Home

The PureMVC Framework Code at the Speed of Thought


Welcome, Guest. Please login or register.
June 26, 2017, 11:56:11 AM
Home Help Search Login Register
News: Please DM @puremvc on Twitter to gain forum access. Spambots are why we can't have nice things.
Pages: [1]
Print
Author Topic: addChild Problem  (Read 4593 times)
Nebulous
Newbie
*
Posts: 3


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

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:

Code:

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 {
MonsterDebugger.initialize(clip);
if (e.currentTarget.content != null && e.currentTarget.content.service != null) {
service = e.currentTarget.content.service
service.connect(GameKey, clip);

trace ("[API] Service Successfully Loaded")
API.callback();
} 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) {

Security.allowDomain("domain.com")
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.

Dave.
« Last Edit: April 20, 2011, 05:19:57 AM by Nebulous » Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2870



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

Quote
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.

-=Cliff>
Logged
Pages: [1]
Print
Jump to: