Copy link to clipboard
Copied
Hi all - I have a question which I'm sure has a simple answer, but I'm just not seeing it and I'm spinning my wheels. One of those things that I'm too close to see, I'm sure.
Consider the following which is working:
The objective:
The problem:
What I've tried that does not work:
I cant share code but hopefully that's pretty clear... any ideas?
Copy link to clipboard
Copied
Have you tried
getChildAt(index:int😞DisplayObject
for the NavigatorContent Komponent? I believe (haven't checked) that this function is declared private in the ASDOC, so it doesnt show in content-assist and the docs, but can still be called..
Copy link to clipboard
Copied
I tried that. It gives me what I want, but it seems the way I'm doing it without that gives the same result a little easier. The relevant code, redacted a bit, is as follows:
public function gotoView(i:uint = 0):void {
MainApp(this).nav.selectedIndex = i; // set the TabBar index according to which view in the map we wish to see.
var item:NavigatorContent = MainApp(this).mainView.selectedChild = NavigatorContent(MainApp(this).mainView.getChildByName(navMap)); // set the selectedChild and a reference to that child as the view's child-by-name according to the navigation mapping.
trace(item.getChildAt(0)); // MainApp.ApplicationSkin2._ApplicationSkin_Group1.contentGroup.mainView.welcome.SkinnableContainerSkin23
trace(getQualifiedClassName(item.getChildAt(0))); // spark.skins.spark::SkinnableContainerSkin
// "welcome" is the ID of the currently active view in the ViewStack. Its this application whose public method I need to call.
trace(item.getChildAt(0).parent); // MainApp.ApplicationSkin2._ApplicationSkin_Group1.contentGroup.mainView.welcome
trace(getQualifiedClassName(item.getChildAt(0).parent)); // spark.components::NavigatorContent
// the above is the same as just
trace(item); // MainApp.ApplicationSkin2._ApplicationSkin_Group1.contentGroup.mainView.welcome
trace(getQualifiedClassName(item)); // spark.components::NavigatorContent
// what I'm trying to say that does not work:
ChildApplication(item).init(); // init is a public method. fails because it cannot convert NavigatorContent to ChildApplication. I don't want to convert it anyway. What I want is basically that NavigatorContent's content...
}
Copy link to clipboard
Copied
After some thought, it might be the case that this just isn't allowed for security purposes. Similar to how in JavaScript, you cannot mess with an IFRAME's content. I suppose there is nothing stopping me from pulling in a remote site's SWF and trying to act upon it if what I'm trying to do were possible. Or, even worse, somebody taking the child SWFs and including it in their own malicious parent container.
Is there perhaps a better way to accomplish what I'm trying to do?
Copy link to clipboard
Copied
Got it.
Solution:
var item:NavigatorContent = NavigatorContent(MainApp(this).mainView.selectedChild;
ChildApplication(SystemManager(SWFLoader(item.getElementAt(0)).content).application).init();
That will call the public init() method of MainApp's ViewStack's selectedChild, which is nested inside a NavigatorContent item, which contains a SWFLoader loaded at run-time.