Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/s9tpepper/robotlegs-starling-plugin
A Robotlegs plugin that adds some Robotlegs classes to support usage with the Starling framework.
https://github.com/s9tpepper/robotlegs-starling-plugin
Last synced: 3 months ago
JSON representation
A Robotlegs plugin that adds some Robotlegs classes to support usage with the Starling framework.
- Host: GitHub
- URL: https://github.com/s9tpepper/robotlegs-starling-plugin
- Owner: s9tpepper
- Created: 2011-10-12T19:01:11.000Z (about 13 years ago)
- Default Branch: master
- Last Pushed: 2013-01-04T02:36:59.000Z (almost 12 years ago)
- Last Synced: 2024-06-23T19:35:58.836Z (5 months ago)
- Language: ActionScript
- Homepage:
- Size: 1.94 MB
- Stars: 113
- Watchers: 16
- Forks: 33
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-actionscript-sorted - robotlegs-starling-plugin - A Robotlegs plugin that adds some Robotlegs classes to support usage with the Starling framework. (Frameworks / RobotLegs Framework)
README
# robotlegs-starling-plugin
This plugin adds some classes to Robotlegs to support usage with the Starling framework. Because the Starling framework uses Stage3D and not the flash.display.DisplayList a StarlingContext must be used along with a StarlingMediator. The rest of the framework usage remains the same.
Pull Requests are encouraged! Please if you add/fix anything contribute it back! :)
Added Classes
-------------
* StarlingMediatorMap.as
* StarlingViewMap.as
* StarlingViewMapBase.as
* IStarlingMediatorMap.as
* IStarlingViewMap.as
* StarlingContext.as
* StarlingMediator.as
* StarlingCommand.asUsage Example
-------------
Below are some excerpts from a very simple usage example. The .fxp file for the example file is in the Downloads section. Below are the key parts.The main class set up remains the same:
package
{
import com.example.MyGame;import flash.display.Sprite;
import flash.events.Event;import org.robotlegs.mvcs.StarlingContext;
import starling.core.Starling;
public class Main extends Sprite
{
private var _starling:Starling;
private var _starlingContext:StarlingContext;public function Main()
{
addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
}protected function onAddedToStage(event:Event):void
{
_starling = new Starling(MyGame, stage);
_starling.start();
}
}
}Inside the main Starling class (MyGame) sent into the first Starling constructor argument start a subclass of a StarlingContext instance. Usage of the StarlingContext is identical to the default Robotlegs Context class.
package com.example
{
import flash.utils.setTimeout;import org.robotlegs.mvcs.StarlingContext;
import starling.display.Sprite;
import starling.events.Event;public class MyGame extends Sprite
{
private var _starlingContext:StarlingContext;public function MyGame()
{
super();_starlingContext = new MyStarlingGameContext(this);
addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
}private function onAddedToStage(event:Event):void
{
var secondView:SecondView = new SecondView();
addChild(secondView);// Test mediator removal
setTimeout(secondView.parent.removeChild, 3000, secondView);
}
}
}Contents of the MyStarlingGameContext class (StarlingContext subclass):
package com.example
{
import org.robotlegs.mvcs.StarlingContext;import starling.display.DisplayObjectContainer;
public class MyStarlingGameContext extends StarlingContext
{
public function MyStarlingGameContext(contextView:DisplayObjectContainer=null, autoStartup:Boolean=true)
{
super(contextView, autoStartup);
}override public function startup():void
{
mediatorMap.mapView(MyGame, MyGameMediator);
mediatorMap.mapView(SecondView, SecondViewMediator);
commandMap.mapEvent(FlashEvent.EVENT_NAME, EventCommand);super.startup();
}
}
}
Contents of the EventCommand (StarlingCommand sub-class, alternatively you can no subclass anything and declare a public execute() method, but do not use the default Robotlegs Command class, it will crash.)package com.example
{
import org.robotlegs.mvcs.StarlingCommand;public class EventCommand extends StarlingCommand
{
public function EventCommand()
{
super();
}override public function execute():void
{
trace("EventCommand.execute()");
}
}
}
Alternate EventCommand class declaration (you dont get access to default things you might be used to with the default Robotlegs command class, like the injector, mediator map, etc):package com.example
{
public class EventCommand
{
public function EventCommand()
{
}public function execute():void
{
trace("EventCommand.execute()");
}
}
}And finally, the contents of one of the mediators (SecondViewMediator):
package com.example
{
import org.robotlegs.mvcs.StarlingMediator;public class SecondViewMediator extends StarlingMediator
{
public function SecondViewMediator()
{
super();
}override public function onRegister():void
{
trace("SecondViewMediator.onRegister()");
}override public function onRemove():void
{
trace("SecondViewMediator.onRemove()");
}
}
}