• Stars
    star
    113
  • Rank 308,948 (Top 7 %)
  • Language ActionScript
  • Created almost 13 years ago
  • Updated almost 12 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A Robotlegs plugin that adds some Robotlegs classes to support usage with the Starling framework.

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

Usage 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()");
		}
	}
}

More Repositories

1

MongoAS3

AS3 Driver for mongoDB.
ActionScript
73
star
2

karma-cucumberjs

A Cucumber.js Karma test runner adapter.
PHP
54
star
3

grunt-cucumber-js

A grunt.js task for cucumber.js
JavaScript
36
star
4

OSMFSparkComponents

A collection of classes that provide an OSMF media player skinnable using Spark skinning practices. Also included is a powerful playlist component used to create playlists for your OSMF media players.
ActionScript
16
star
5

JSONTools

JSONTools is an ActionScript3 library that goes beyond providing a decoding and encoding engine. JSONTools provides JSON errors on bad property calls, the speed of the JSWoof JSON library, and E4X style queries dubbed E4J, JSONList and JSONListCollection classes for Flex, as well as some features that are coming in upcoming releases.
ActionScript
16
star
6

SignalsCircuit-for-PureMVC

SignalsCircuit is a small set of classes that implement and extend PureMVC core classes and interfaces to allow you to wire Signals to a Command pattern that provides access to the rest of your application via your PureMVC Facade implementation.
ActionScript
9
star
7

VectorTools

Small set of tools for working with Vector type objects in AS3. Includes some translation methods to turn vectors to Array or Dictionary, and a VectorCollection class for use in Flex lists.
ActionScript
8
star
8

LinkageClassGenerator

A Flash Professional JSFL extension that generates classes and interfaces for your linked MovieClips in the Flash Professional library.
6
star
9

MongoAS3-CodeExamples

Code examples using the MongoAS3 MongoDB driver.
6
star
10

ObjUtil

Modified version of mx.utils.ObjectUtil, modified to work with AS3 only projects.
JavaScript
5
star
11

Simple-AMF-Scoreboard-API

This project contains a complete AMFPHP based scoreboard API to record and retrieve top scores for any type of Flash game, web, desktop or mobile.
PHP
4
star
12

SkinnableItemRenderer

An alternative to s:ItemRenderer, allows you to use SkinPart metadata in your item renderers.
4
star
13

AsyncSignalHandler

AsyncSignalHandler lets you easily handle unit testing as3Signal dispatching when working with FlexUnit.
ActionScript
3
star
14

grunt-jasmine-node-example

A project example of using Jasmine via Node.js
3
star
15

EventMapper

EventMapper is an AS3 event handling utility used to configure how you handle events from any Event class dispatched by any type of EventDispatcher object.
2
star
16

BasicJSTDExample

Example of a basic JSTD project setup
JavaScript
2
star
17

AndroidList

The AndroidList class extends the Spark List component to provide the capability to bring up an options menu pop up on touch and hold in the same style as the Android native list component.
JavaScript
2
star
18

rebar.js

JavaScript code generation tool that runs on node.js
JavaScript
1
star
19

centcom

Postman but for terminal, and better
Rust
1
star
20

sergeant

Rust based twitch chat bot and chat client
Rust
1
star