0

Is there a way within Flex Mobile 4.6 to access the main application from within a <s:View> component? Let's say my program looks like this:

Main application:

<s:TabbedViewNavigatorApplication xmlns:fx="http://ns.adobe.com/mxml/2009" 
                  xmlns:s="library://ns.adobe.com/flex/spark"
                  creationComplete="databaseConnection(event)">

  <s:ViewNavigator id="tasks" width="100%" height="100%"
                       label="Tasks" firstView="views.TasksView"
                       title="Tasks" icon="@Embed('assets/icons/tasks.png')">
  </s:ViewNavigator>
</s:TabbedViewNavigatorApplication>

view.TasksView:

<s:View xmlns:fx="http://ns.adobe.com/mxml/2009" 
        xmlns:s="library://ns.adobe.com/flex/spark">

  <s:List left="0" right="0" top="0" bottom="0"
     dataProvider="{taskData}" itemRenderer="renderers.TaskListRenderer"/>
</s:View>

Let's say that there is a variable within the main application that I would like to access within view.TasksView. How can I do that?

Thank you for your time.

Oliver Spryn
  • 16,871
  • 33
  • 101
  • 195

2 Answers2

1

FlexGlobals.topLevelApplication

In your case:

var app : TabbedViewNavigatorApplication = FlexGlobals.topLevelApplication as TabbedViewNavigatorApplication

Of course, accessing the top level application is a great break in encapsulation and not usually recommended.

JeffryHouser
  • 39,401
  • 4
  • 38
  • 59
0

It's better to use "parentApplication" property. For example if you want to disable tab button of view "vsetting" from other views:

parentApplication.vsetting.enabled = false;
MShams
  • 66
  • 3