English 中文(简体)
Adobe Flex:MXML 组件主应用程序访问结果
原标题:Adobe Flex: Accessing Result Event From Main Application In Component MXML

在我的主要应用程序中,我有一个结果事件和一个 XMLList , 里面填满了我的结果。 XMLList 定义于一个函数之外, 例如 :

public var testList:XMLList = new XMLList();

但在我的结果处理器内,它包含来自结果的数据,而且效果很好。我需要创建一个外部组件 MXML 文件,其中将包含一个列表,但在这个组件文件中,我无法访问主应用程序的测试列表。

我在每个文件中都包含了 xmlns:local=*" ,我的部件文件也有以下导入内容:

import mx.collections.XMLListCollection;
import mx.controls.Alert;
import mx.core.Application;
import mx.events.FlexEvent;
import mx.rpc.events.ResultEvent;

我不明白我做错了什么

最佳回答

您需要将 testList 作为您组件的属性通过 。

Main - 您有来自结果事件和自定义组件的测试列表。 将 < code> testList 传给您在组件中定义的属性, 如 < code> data :

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
               xmlns:s="library://ns.adobe.com/flex/spark"
               xmlns:mx="library://ns.adobe.com/flex/mx"
               xmlns:local="*">

    <fx:Script>
        <![CDATA[
            [Bindable]
            public var testList:XMLList = new XMLList();
        ]]>
    </fx:Script>

    <local:CustomComponent data="{testList}" />

</s:Application>

CustomComponent - 从您创建的组件中从属性访问 testList , 如此示例中的 data :

<?xml version="1.0" encoding="utf-8"?>
<s:Group xmlns:fx="http://ns.adobe.com/mxml/2009"
         xmlns:s="library://ns.adobe.com/flex/spark"
         xmlns:mx="library://ns.adobe.com/flex/mx">

    <fx:Script>
        <![CDATA[
            [Bindable]
            public var data:XMLList;
        ]]>
    </fx:Script>

    <s:List dataProvider="{new XMLListCollection(data)}" />

</s:Group>
问题回答

暂无回答




相关问题
Disable button tooltip in AS3

I want to disable the tooltip on certain buttons. The tooltip manager seems to be an all or nothing solution. Is it possible to disable the tooltip for just one or two buttons?

Multiple Remote call made simultenously

I was making multiple remote calls and they are done sequentially and when I am getting a result event back it s triggering calls to all the methods with ResultEvent as an argument . I am supposed to ...

Attaching a property to an event in Flex/AS3

I have a parameter that needs to be passed along with an event. After unsuccessful attempts to place it on the type by extending the class, I ve been advised in another SO question to write a custom ...

Clearing RSL in Cache

I have built a flex application which has a "main" project and it is assosciated with a few RSL s which are loaded and cached once i run my "main" application. The problem i am facing is that the ...

What s a good way of deserializing data into mock objects?

I m writing a mock backend service for my flex application. Because I will likely need to add/edit/modify the mock data over time, I d prefer not to generate the data in code like this: var mockData =...

AS3 try/catch out of memory

I m loading a few huge images on my flex/as3 app, but I can t manage to catch the error when the flash player runs out of memory. Here is the what I was thinking might work (I use ???? because i dont ...

热门标签