2012-05-18 28 views
0

Flex Mobile 4.6中有沒有辦法從<s:View>組件中訪問主應用程序?比方說,我的計劃是這樣的:Flex移動視圖組件訪問主應用程序

主要應用:

<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> 

讓我們說有,我想訪問主應用程序中的變量在view.TasksView之內。我怎樣才能做到這一點?

謝謝你的時間。

回答

1

FlexGlobalstopLevelApplication

你的情況:

var app : TabbedViewNavigatorApplication = FlexGlobals.topLevelApplication as TabbedViewNavigatorApplication 

當然,訪問頂級應用程序是在半導體封裝的重大突破,而不是通常建議。

+0

您說得對。這是封裝背後的想法的一個突破,但在這種情況下它將起作用。謝謝! –

0

最好使用「parentApplication」屬性。 例如,如果要禁用其他視圖中的「vsetting」選項卡按鈕:

parentApplication.vsetting.enabled = false; 
相關問題