Referencing Flashbuilder Views by their string name
I have a TabbedViewNavigator application with a navigatory bar which opens view just fine. In each view there is a ButtonBar that will open a new view related to the parent view. I have a single handler which decodes the name of the button and can build a string with the name of the view to be opened. I am looking for some way of referencing the view from this string, in a similar fashion to this["someName"]
or getDefinitionByName("someName")
. In my code, 'this' refers to the current view and the views 开发者_高级运维that I need to find are not child elements. I don't know where getDefinitionByName()
is looking, but it can't find the view either.
I have solved it temporarily with a switch statement, but this is not a good solution. Is there a view collection; if so, who is the owner of the collection or am I not going about this in the correct way.
Thanks for reading this far.
If the view is in a package/folder, you need to supply the full package to getDefinitionByName
:
var viewClass : Class = getDefinitionByName("com.us.project.AwesomeView");
var view : DisplayObject = new viewClass();
精彩评论