navigation: referencing root v using event

6 views
Skip to first unread message

Rick Benitez

unread,
Dec 3, 2014, 11:57:37 AM12/3/14
to as3-commons...@googlegroups.com
Hello:
I have a question regarding the following snippet.

//give sketchscreen a ref to Main.as to call the homescreen func
var rootMain:Main = this.root as Main;
//let's go to main and show the homescreen
rootMain.goToHomeScreen();

Versus using....
var scrnNav:ScreenNavigator = new ScreenNavigator();
scrnNav.addScreen("homeScreen", new ScreenNavigatorItem(HomeScreen));
addChild(scrnNav);
scrnNav.showScreen( "homeScreen" );

I was told there could be a situation where "This can fail if "root" is ever unavailable (unlikely but can happen) and it's a lot cleaner using the events"

Can anyone confirm or deny?

Please advise,
RIck

Reply all
Reply to author
Forward
0 new messages