ContextView in RL2 with Starling
Hi I want to ask if we use Starling in RL2 by using
StarlingViewMapExtension
like from this example
https://github.com/lidev/robotlegs2-signals-feathers-flickr-example/
and in this cace FlickrGalleryApp.as class (FlickGalleryApp.as is
extends flash.display.Sprite)
_context = new Context();
_context.install( MVCSBundle, StarlingViewMapExtension, SignalCommandMapBundle );
_context.configure( AppConfig, this, _starling );
_context.configure( new ContextView( this ) );
if I
[Inject]
public var contextView:ContextView;
to some command , will contextView.view automatically return as starling.display.DisplayObjectContainer . ?
or I should change it to
_context.configure( new ContextView( _starling.stage) );
or
_context.configure( new ContextView(Starling.current.root) );
so I can add display object like
contextView.view.addChild(new SomeStarlingDisplayObject());
or is there other example/best practice using RL2 with
feathers/starling ? I only found two so farThanks for the advice
Comments are currently closed for this discussion. You can start a new one.
Keyboard shortcuts
Generic
? | Show this help |
---|---|
ESC | Blurs the current field |
Comment Form
r | Focus the comment reply box |
---|---|
^ + ↩ | Submit the comment |
You can use Command ⌘
instead of Control ^
on Mac
Support Staff 1 Posted by Ondina D.F. on 22 Jul, 2013 01:41 PM
Hi,
Adding "this" to the configure doesn't make sense:
_context.configure( AppConfig, this, _starling );
This is the correct configuration:
_context.configure(AppConfig, _starling , new ContextView( this ));
As you know, the ContextView is expecting a DisplayObjectContainer, and every time you call contextView.view, it will return the display object container that you provided, in your example that's FlickGalleryApp, which is not a starling.display.DisplayObjectContainer.
That's not a good idea, and I think it wouldn't work actually. I'm not very familiar with Starling, but just from looking at the class, I guess Starling adds a view as a Starling root Class to an already created stage. So you need to pass on to it a parent view (FlickGalleryApp) and a view (StarlingRootSprite) to be added to its parent's stage (FlickGalleryApp.stage).
FlickGalleryApp is the DisplayObjectContainer used by robotlegs' ContextView, while StarlingRootSprite is the 'root class' used by Starling. That means, you'll never get StarlingRootSprite by calling contextView.view.
It would be better if you could avoid manipulating views in a command (adding views is View logic !), but if you really need to do that, you can access starling's instance like so :
(contextView.view as Object)._starling.stage.addChild(views);
which is pretty disturbing ;)
or you can inject an instance of Starling that you mapped like so:
and then inject it like this:
SARS is a nice utility. In SARS, the mapping of a Starling instance happens behind the scenes, and all you have to do is inject the instance into the command.
(https://github.com/Vj3k0/robotlegs-bender-example-SARS-integration/...)
Hope this helps.
Ondina
2 Posted by khaneron_898 on 22 Jul, 2013 02:11 PM
Thanks for the reply , much more clear now
Support Staff 3 Posted by Ondina D.F. on 22 Jul, 2013 03:30 PM
Glad to hear that!
Ondina D.F. closed this discussion on 22 Jul, 2013 03:30 PM.