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

Show Posts

* | |

  Show Posts
Pages: [1]
1  PureMVC Manifold / Standard Version / addChild Problem 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 {
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.
2  PureMVC Manifold / MultiCore Version / Re: Using an External API with PureMVC on: April 04, 2011, 03:45:18
Cliff,

Thank you very much for your detailed response.

I am glad I waited for the reply, rather then hacking it in :)

I shall give it a try shortly, and if I get stuck I shall let you know. It doesn't help that the API i'm trying to implement is a great big ball of mud :(

Thanks again..

Dave.
3  PureMVC Manifold / MultiCore Version / Using an External API with PureMVC on: April 01, 2011, 12:24:57
Hi,

I have just started using this framework, and so far I like how structured it is.

The only real problem I am having currently is how to integrate our GameAPI into it correctly... I understand that it should be a proxy, as it is retrieving and sending data? It uses simplexml to parse and process XML responses....

So I need work out the best way to...

1) Create a global object that can be accessed via anywhere
2) Make sure this object is only instaniated once
3) Post data to the API which then parses it into XML and sends it to our server
4) Handle the responses and callbacks of the API.

I spent a while looking at this yesterday, but could not figure out the correct implementation of how to do it.

Any help would be great.

Dave.
Pages: [1]