0

我能够从自定义 SkinnablePopUpContainer 发回单个值,但不能将具有多个值的数组发回创建它的视图?

我怎么能这样做有什么帮助吗?

这是 SkinnablePopUpContainer 的代码:我想发回 activityDetails 数组

        import spark.events.IndexChangeEvent;

        import valueObjects.Model;

        /* Variables */

        public var model:Model = new Model();
        private var selectCatStmt:SQLStatement;
        private var selectCatSQL:String = 'SELECT category FROM Activity GROUP BY category';
        private var activityStmt:SQLStatement = new SQLStatement();
        private var activitySQL:String = 'SELECT * FROM Activity WHERE category = :category';

        private var activityDetails:Array = [{category:'', activityId:0, hours:0}];  // I want to send this back to the view that creates this popup

        private function getCategories():void
        {
            selectCatStmt = new SQLStatement();
            selectCatStmt.sqlConnection = model.connection;
            selectCatStmt.text = selectCatSQL;
            selectCatStmt.addEventListener(SQLErrorEvent.ERROR, errorHandler);
            selectCatStmt.addEventListener(SQLEvent.RESULT, selectResult);
            selectCatStmt.execute();
        }

        private function selectResult(event:SQLEvent):void
        {
            var result:SQLResult = selectCatStmt.getResult();

            if(result.complete)
            {
                if(result.data)
                {
                    categoriesList.dataProvider = new ArrayCollection(result.data);
                }
            }   
        }

        private function errorHandler(event:SQLErrorEvent):void
        {
            trace ("\nError message: " + event.error.message);
            trace("\nDetails: " + event.error.details);
        }

        /* Event Handlers */

        protected function categoryList_changeHandler(event:IndexChangeEvent):void
        {
            selectCatStmt = new SQLStatement();
            activityStmt.sqlConnection = model.connection;
            activityStmt.text = activitySQL;
            activityStmt.parameters[":category"] = categoriesList.selectedItem.category;
            activityStmt.addEventListener(SQLErrorEvent.ERROR, errorHandler);
            activityStmt.addEventListener(SQLEvent.RESULT, activityResult);
            activityStmt.execute();
        }

        private function activityResult(event:SQLEvent):void
        {
            var result:SQLResult = activityStmt.getResult();

            if(result.complete)
            {
                if(result.data)
                {
                    activitiesList.dataProvider = new ArrayCollection(result.data);
                }
            }   
        }

        protected function addActButton_clickHandler(event:MouseEvent):void
        {
            activityDetails[0]["category"] = categoriesList.selectedItem.category;
            activityDetails[0]["activityId"] = activitiesList.selectedItem.id;
            activityDetails[0]["hours"] = Number(duration.text);

            this.close(true,activityDetails);
        }

        protected function skinnablepopupcontainer1_creationCompleteHandler(event:FlexEvent):void
        {
            getCategories();
        }

    ]]>
</fx:Script>

<s:layout>
    <s:VerticalLayout horizontalAlign="center" verticalAlign="middle"/>
</s:layout>

<flextras:DropDownList id="categoriesList" labelField="category" width="100%" height="34" prompt="Select Type" change="categoryList_changeHandler(event)"/>
<s:List id="activitiesList" itemRenderer="renderers.ActivitiesList" width="100%" height="100%"/>
<s:HGroup verticalAlign="middle" horizontalAlign="left" width="100%">
    <s:Label text="Activity duration in minutes : "/>
    <s:TextInput id="duration" width="50"/>
</s:HGroup>
<s:Button id="addActButton" label="Set" click="addActButton_clickHandler(event)"/>

这是弹出关闭处理程序

        protected function activitySelect_closeHandler(event:PopUpEvent):void
        {
            if(!event.commit)
            {
                return;
            }

            activities.push(event.data);
            trace(activities);
        }
4

1 回答 1

0

close方法的第二个参数采用每个数据类型“*”。因此,发回数组或对象应该不是问题。

您需要PopUp.CLOSE在弹出窗口上监听事件。将activityDetailsdata财产中PopUpEvent

于 2013-10-29T15:58:46.927 回答