add the ability to save QTEs by POSTing to a given URL
This commit is contained in:
parent
8d56123345
commit
b816a45b4d
|
@ -1,6 +1,11 @@
|
||||||
package
|
package
|
||||||
{
|
{
|
||||||
|
import com.adobe.serialization.json.JSON;
|
||||||
import flash.events.EventDispatcher;
|
import flash.events.EventDispatcher;
|
||||||
|
import flash.net.sendToURL;
|
||||||
|
import flash.net.URLRequest;
|
||||||
|
import flash.net.URLRequestMethod;
|
||||||
|
import flash.net.URLVariables;
|
||||||
/**
|
/**
|
||||||
* ...
|
* ...
|
||||||
* @author jjp
|
* @author jjp
|
||||||
|
@ -11,6 +16,7 @@ package
|
||||||
public static const VIDEOTUBE_YOUTUBE:String = "yt";
|
public static const VIDEOTUBE_YOUTUBE:String = "yt";
|
||||||
|
|
||||||
public var urlVideo:String;
|
public var urlVideo:String;
|
||||||
|
public var urlPostQte:String;
|
||||||
public var typeVideotube:String;
|
public var typeVideotube:String;
|
||||||
public var rgqte:Array;
|
public var rgqte:Array;
|
||||||
public function Gamedisc(urlVideo:String = null, typeVideotube:String = null)
|
public function Gamedisc(urlVideo:String = null, typeVideotube:String = null)
|
||||||
|
@ -22,6 +28,15 @@ package
|
||||||
public function AddQte(qte:Qte):void
|
public function AddQte(qte:Qte):void
|
||||||
{
|
{
|
||||||
rgqte.splice(Math.abs(Util.binarySearch(rgqte, qte, Qte.compare)), 0, qte);
|
rgqte.splice(Math.abs(Util.binarySearch(rgqte, qte, Qte.compare)), 0, qte);
|
||||||
|
if (urlPostQte != null)
|
||||||
|
{
|
||||||
|
var req:URLRequest = new URLRequest(urlPostQte);
|
||||||
|
req.method = URLRequestMethod.POST;
|
||||||
|
var data:URLVariables = new URLVariables();
|
||||||
|
data.qte = JSON.encode(qte.ToJson());
|
||||||
|
req.data = data;
|
||||||
|
sendToURL(req);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
public function CreateVideotube():Videotube
|
public function CreateVideotube():Videotube
|
||||||
{
|
{
|
||||||
|
@ -36,7 +51,10 @@ package
|
||||||
var jsonRgqte:Array = [];
|
var jsonRgqte:Array = [];
|
||||||
for each (var qte:Qte in rgqte)
|
for each (var qte:Qte in rgqte)
|
||||||
jsonRgqte.push(qte.ToJson());
|
jsonRgqte.push(qte.ToJson());
|
||||||
return { urlVideo: urlVideo, typeVideotube: typeVideotube, rgqte: jsonRgqte };
|
var json:Object = { urlVideo: urlVideo, typeVideotube: typeVideotube, rgqte: jsonRgqte };
|
||||||
|
if (urlPostQte != null)
|
||||||
|
json.urlPostQte = urlPostQte;
|
||||||
|
return json;
|
||||||
}
|
}
|
||||||
public function FromJson(json:Object):void
|
public function FromJson(json:Object):void
|
||||||
{
|
{
|
||||||
|
@ -49,6 +67,7 @@ package
|
||||||
}
|
}
|
||||||
urlVideo = json.urlVideo;
|
urlVideo = json.urlVideo;
|
||||||
typeVideotube = json.typeVideotube;
|
typeVideotube = json.typeVideotube;
|
||||||
|
urlPostQte = json.urlPostQte;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,14 +19,12 @@ package
|
||||||
private var gamedisc:Gamedisc;
|
private var gamedisc:Gamedisc;
|
||||||
private var gameeditor:GameEditor;
|
private var gameeditor:GameEditor;
|
||||||
private var gameplayer:GamePlayer;
|
private var gameplayer:GamePlayer;
|
||||||
private var fPlayOnly:Boolean;
|
|
||||||
|
|
||||||
public function Main():void
|
public function Main():void
|
||||||
{
|
{
|
||||||
gamedisc = new Gamedisc();
|
gamedisc = new Gamedisc();
|
||||||
gamedisc.FromJson(JSON.decode(loaderInfo.parameters.jsonDisc));
|
gamedisc.FromJson(JSON.decode(loaderInfo.parameters.jsonDisc));
|
||||||
videotube = gamedisc.CreateVideotube();
|
videotube = gamedisc.CreateVideotube();
|
||||||
fPlayOnly = JSON.decode(loaderInfo.parameters.fPlay);
|
|
||||||
if (stage) init();
|
if (stage) init();
|
||||||
else addEventListener(Event.ADDED_TO_STAGE, init);
|
else addEventListener(Event.ADDED_TO_STAGE, init);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue