Skip to content

Commit

Permalink
Added support for swf assets. Fixed page transition bug. Added Swf pa…
Browse files Browse the repository at this point in the history
…ge to example.
  • Loading branch information
ConfidantCommunications committed Jun 28, 2016
1 parent 0a88338 commit c8fc6cb
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 7 deletions.
8 changes: 6 additions & 2 deletions examples/ebook/assets/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@
</page>
<page id="options" type="overlay" original="" width="960" height="640">
<actor id="background" type="prop" z="0" x="0" y="0" width="960" height="640" src="options/actor_0000_background.png"></actor>
<actor id="duck" type="control" action="pageSkipTo:svg,transitionOut:options" z="1" x="461" y="352" width="223" height="209" src="options/actor_0001_duck.png"></actor>
<actor id="duck" type="control" action="pageSkipTo:svg,transitionOut:options" z="1" x="361" y="352" width="223" height="209" src="options/actor_0001_duck.png"></actor>
<actor id="swfBoy" type="control" action="pageSkipTo:swfPage,transitionOut:options" z="1" x="601" y="400" width="200" height="214" src="options/swfBoy.png"></actor>
<actor id="home" type="control" action="pageSkipTo:title,transitionOut:options" z="2" x="132" y="136" width="252" height="264" src="options/actor_0002_home.png"></actor>
<actor id="cow" type="control" action="pageSkipTo:deal,transitionOut:options" z="3" x="351" y="150" width="219" height="220" src="options/actor_0003_cow.png"></actor>
<actor id="easyXML" type="control" action="pageSkipTo:easy,transitionOut:options" z="4" x="551" y="136" width="273" height="246" src="options/actor_0004_easyXML.png"></actor>
<actor id="limerick" type="control" action="pageSkipTo:limerickPage,transitionOut:options" z="5" x="235" y="366" width="198" height="185" src="options/actor_0005_limerick.png"></actor>
<actor id="limerick" type="control" action="pageSkipTo:limerickPage,transitionOut:options" z="5" x="135" y="366" width="198" height="185" src="options/actor_0005_limerick.png"></actor>
<actor id="close" z="6" type="control" action="transitionOut:options" x="860" y="40" width="50" height="50" src="closeX.svg" ></actor>
<actor id="choose" z="7" type="prop" x="244" y="41" width="461" height="109" src="options/choose.png" ></actor>
</page>
Expand Down Expand Up @@ -49,4 +50,7 @@
<actor id="duck" z="1" type="prop" x="0" y="0" width="962" height="640" src="duck.svg" ></actor>
<actor id="star1" z="1" type="prop" x="100" y="120" width="100" height="100" src="title/star.svg" ></actor>
</page>
<page id="swfPage" type="normal" original="" width="960" height="640">
<actor id="littleboy" z="1" type="prop" x="0" y="0" width="962" height="640" src="swflibrary:LittleBoy" ></actor>
</page>
</pages>
Binary file added examples/ebook/assets/options/swfBoy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/ebook/assets/swflibrary.fla
Binary file not shown.
Binary file added examples/ebook/assets/swflibrary.swf
Binary file not shown.
5 changes: 4 additions & 1 deletion examples/ebook/project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@
<haxelib name="svg" />
<haxelib name="glory" />
<haxelib name="puremvc-standard" />
<haxelib name="swf" />

<icon path="assets/nme.svg" />
<assets path="assets" include="*" />

<library path="assets/swflibrary.swf" preload="true" />
<assets path="assets" include="*" exclude="*.swf|*.fla" />

</project>
4 changes: 2 additions & 2 deletions haxelib.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"description": "Glory Framework is a page-based media framework built using [Haxe 3](http://haxe.org/), [OpenFL](http://openfl.org), and [PureMVC](http://puremvc.org/). It can be used for interactive e-books, adventure games, websites, or slide presentations on any target supported by OpenFL. It uses an XML configuration file to build the layout of each page, including placement and function of different controls. Each page can have its own custom class if desired. Glory also includes two Photoshop scripts which make it easy to rapidly convert a PSD layout into something that Glory can use. It can also use SVG files saved directly from Illustrator (not all types of object are supported).",
"contributors": ["ConfidantCommunications"],
"classPath":"src/",
"releasenote": "Modified to use PureMVC from Haxelib.",
"version": "1.1.0",
"releasenote": "Now supporting swf assets.",
"version": "1.2.0",
"url": "https://github.com/ConfidantCommunications/Glory-Framework/",
"dependencies": {
"openfl" :"",
Expand Down
2 changes: 1 addition & 1 deletion src/ca/confidant/glory/controller/BuildPageCommand.hx
Original file line number Diff line number Diff line change
@@ -1 +1 @@
package ca.confidant.glory.controller; import flash.display.Sprite; import flash.display.Bitmap; import flash.display.BitmapData; import flash.display.DisplayObject; import haxe.xml.Fast; //import nme.Assets; //moved to loaderProxy import org.puremvc.haxe.patterns.command.SimpleCommand; import org.puremvc.haxe.interfaces.INotification; import ca.confidant.glory.view.PageMediator; import ca.confidant.glory.view.ApplicationMediator; import ca.confidant.glory.view.ActorComponentMediator; import ca.confidant.glory.view.components.ActorComponent; import ca.confidant.glory.view.components.PageComponent; import ca.confidant.glory.model.ControlsRegistryProxy; import ca.confidant.glory.ApplicationFacade; import ca.confidant.glory.model.PagesConfigProxy; import ca.confidant.glory.model.ActorComponentConfigProxy; import ca.confidant.glory.model.LoaderProxy; //import ca.confidant.glory.controller.ClassConverter; /* * @author Allan Dowdeswell * This is triggered first by the GotoIntroCommand, then by calls to the ChangePageCommand. * It retrieves configuration information from the PageConfigProxy and puts the page together * with the necessary mediators. */ class BuildPageCommand extends SimpleCommand { var pcp:PagesConfigProxy; var appMediator:ApplicationMediator; var lp:LoaderProxy; public function new(){ super(); } override public function execute( note:INotification ) : Void { trace('BuildPageCommand'); //trace(ClassConverter.theContent); pcp=cast(facade.retrieveProxy(PagesConfigProxy.NAME) , PagesConfigProxy); lp=cast(facade.retrieveProxy(LoaderProxy.NAME) , LoaderProxy); appMediator = cast(facade.retrieveMediator(ApplicationMediator.NAME) , ApplicationMediator); var pageId=cast(note.getBody(),String);//current page //var s:PageComponent=new PageComponent();//main page container //Custom page classes get handled here: var class_name:String = "pages.P"+pageId; var a_class = Type.resolveClass( class_name ); var s = ( a_class != null ) ? Type.createInstance( a_class,[] ) : new PageComponent(); s.name=pageId; if(pcp.getPageById(pageId).get("type")=="overlay"){ //trace("overlay"); appMediator.addDisplayObject(s,-1); } else { //trace("not overlay"); appMediator.addDisplayObject(s,0); } //trace("page holder added: "+pageId); var pm = new PageMediator(pageId,s); facade.registerMediator(pm); s.transitionIn(); var actorsList=pcp.getPageActors(pageId); //trace("length:"+actorsList.length); if (actorsList.length>0){ for (thisActor in actorsList){ //trace("makeActor: "+thisActor.att.id); s.addActor(thisActor.att.id, makeActor(thisActor)); //appMediator.addDisplayObject(makeActor(thisActor),0); } } var crp=cast(facade.retrieveProxy(ControlsRegistryProxy.NAME),ControlsRegistryProxy); var controls=crp.getControls(); for(thisControl in controls){ appMediator.getApp().removeChild(thisControl); appMediator.getApp().addChild(thisControl); //trace("control:"+thisControl.x+":"+thisControl.y); //var newx=thisControl.x; //thisControl.x=newx; //var newy=thisControl.y; //thisControl.y=newy; } s.init(); } private function makeActor(actor:Fast):ActorComponent{ //try{ var ext:String=cast(actor.att.src,String).substr(-3); //trace("ext:"+ext); //var class_name:String = "actors.Asomething"; //var a = Type.createInstance( Type.resolveClass(class_name), [] ); //if(a!=null){ var a=new ActorComponent(); //} //trace(imageData+ " is my data"); if(ext=="svg"){ var theText=lp.getText("assets/"+actor.att.src); a.addSVG(theText); } else { var imageData:BitmapData = lp.getBitmapData("assets/"+actor.att.src,true); var b=new Bitmap (imageData); a.addBitmap(b); } var action:String; if(actor.has.action){ action=Std.string(actor.att.action); } else { action=''; } var accp:ActorComponentConfigProxy=new ActorComponentConfigProxy(actor.att.id,Std.string(actor.att.type), action); facade.registerProxy(accp); var acm = new ActorComponentMediator(actor.att.id,a,accp); facade.registerMediator(acm); //appMediator.addDisplayObject(a); a.x=Std.parseInt(actor.att.x); a.y=Std.parseInt(actor.att.y); a.width=Std.parseInt(actor.att.width); a.height=Std.parseInt(actor.att.height); a.type=actor.att.type; a.name=actor.att.id; if(a.type=="control"){ a.mouseEnabled=true; a.useHandCursor=true; a.buttonMode=true; } return a; //} catch(e:Dynamic){ //trace(Std.string(e)); //} } }
package ca.confidant.glory.controller; import flash.display.Sprite; import flash.display.Bitmap; import flash.display.BitmapData; import flash.display.DisplayObject; import haxe.xml.Fast; import openfl.Assets; import org.puremvc.haxe.patterns.command.SimpleCommand; import org.puremvc.haxe.interfaces.INotification; import ca.confidant.glory.view.PageMediator; import ca.confidant.glory.view.ApplicationMediator; import ca.confidant.glory.view.ActorComponentMediator; import ca.confidant.glory.view.components.ActorComponent; import ca.confidant.glory.view.components.PageComponent; import ca.confidant.glory.model.ControlsRegistryProxy; import ca.confidant.glory.ApplicationFacade; import ca.confidant.glory.model.PagesConfigProxy; import ca.confidant.glory.model.ActorComponentConfigProxy; import ca.confidant.glory.model.LoaderProxy; //import ca.confidant.glory.controller.ClassConverter; /* * @author Allan Dowdeswell * This is triggered first by the GotoIntroCommand, then by calls to the ChangePageCommand. * It retrieves configuration information from the PageConfigProxy and puts the page together * with the necessary mediators. */ class BuildPageCommand extends SimpleCommand { var pcp:PagesConfigProxy; var appMediator:ApplicationMediator; var lp:LoaderProxy; public function new(){ super(); } override public function execute( note:INotification ) : Void { trace('BuildPageCommand'); //trace(ClassConverter.theContent); pcp=cast(facade.retrieveProxy(PagesConfigProxy.NAME) , PagesConfigProxy); lp=cast(facade.retrieveProxy(LoaderProxy.NAME) , LoaderProxy); appMediator = cast(facade.retrieveMediator(ApplicationMediator.NAME) , ApplicationMediator); var pageId=cast(note.getBody(),String);//current page //var s:PageComponent=new PageComponent();//main page container //Custom page classes get handled here: var class_name:String = "pages.P"+pageId; var a_class = Type.resolveClass( class_name ); var s = ( a_class != null ) ? Type.createInstance( a_class,[] ) : new PageComponent(); s.name=pageId; if(pcp.getPageById(pageId).get("type")=="overlay"){ //trace("overlay"); appMediator.addDisplayObject(s,-1); } else { //trace("not overlay"); appMediator.addDisplayObject(s,0); } //trace("page holder added: "+pageId); var pm = new PageMediator(pageId,s); facade.registerMediator(pm); s.transitionIn(); var actorsList=pcp.getPageActors(pageId); //trace("length:"+actorsList.length); if (actorsList.length>0){ for (thisActor in actorsList){ //trace("makeActor: "+thisActor.att.id); s.addActor(thisActor.att.id, makeActor(thisActor)); //appMediator.addDisplayObject(makeActor(thisActor),0); } } var crp=cast(facade.retrieveProxy(ControlsRegistryProxy.NAME),ControlsRegistryProxy); var controls=crp.getControls(); for(thisControl in controls){ appMediator.getApp().removeChild(thisControl); appMediator.getApp().addChild(thisControl); //trace("control:"+thisControl.x+":"+thisControl.y); //var newx=thisControl.x; //thisControl.x=newx; //var newy=thisControl.y; //thisControl.y=newy; } s.init(); } private function makeActor(actor:Fast):ActorComponent{ //try{ var ext:String=cast(actor.att.src,String).substr(-3); //trace("ext:"+ext); //var class_name:String = "actors.Asomething"; //var a = Type.createInstance( Type.resolveClass(class_name), [] ); //if(a!=null){ var a=new ActorComponent(); //} //trace(imageData+ " is my data"); switch(ext){ case "svg": var theText=lp.getText("assets/"+actor.att.src); a.addSVG(theText); case "jpg": var imageData:BitmapData = lp.getBitmapData("assets/"+actor.att.src,true); var b=new Bitmap (imageData); a.addBitmap(b); case "gif": var imageData:BitmapData = lp.getBitmapData("assets/"+actor.att.src,true); var b=new Bitmap (imageData); a.addBitmap(b); case "png": var imageData:BitmapData = lp.getBitmapData("assets/"+actor.att.src,true); var b=new Bitmap (imageData); a.addBitmap(b); default: //must be a swf //load swf asset per instructions at http://www.openfl.org/learn/tutorials/using-swf-assets/ var clip = Assets.getMovieClip (actor.att.src); trace("loading:"+actor.att.src); a.addChild(clip); } /*if(ext=="svg"){ var theText=lp.getText("assets/"+actor.att.src); a.addSVG(theText); } else { var imageData:BitmapData = lp.getBitmapData("assets/"+actor.att.src,true); var b=new Bitmap (imageData); a.addBitmap(b); }*/ var action:String; if(actor.has.action){ action=Std.string(actor.att.action); } else { action=''; } var accp:ActorComponentConfigProxy=new ActorComponentConfigProxy(actor.att.id,Std.string(actor.att.type), action); facade.registerProxy(accp); var acm = new ActorComponentMediator(actor.att.id,a,accp); facade.registerMediator(acm); //appMediator.addDisplayObject(a); a.x=Std.parseInt(actor.att.x); a.y=Std.parseInt(actor.att.y); a.width=Std.parseInt(actor.att.width); a.height=Std.parseInt(actor.att.height); a.type=actor.att.type; a.name=actor.att.id; if(a.type=="control"){ a.mouseEnabled=true; a.useHandCursor=true; a.buttonMode=true; } return a; //} catch(e:Dynamic){ //trace(Std.string(e)); //} } }
Expand Down
Loading

0 comments on commit c8fc6cb

Please sign in to comment.