本文介绍了如何将Java对象发送到Java中的两个mxml文件之间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Flex + java ..因为我有两个Sub mxml文件Sub1.mxml和Sub2.mxml

Sub1.mxml代码..

p>

  [Bindable] private var editTimetableVO:TimetableVO; 
public function forwardToCreateEvent(event:MouseEvent):void
{
editTimetableVO = new TimetableVO();
editTimetableVO = editDataGrid.selectedItem as TimetableVO; // editDataGrid是DataGrid id
Alert.show(value+ editTimetableVO.startDate);
}

听到警报正在打印某个日期,这很好...那我的第二个Mxml文件..

Sub2.mxml代码..

$ pre $ code public var myEditEvent:Sub1 = new Sub1();
private var timetableVO:TimetableVO = new TimetableVO();

// private var editTimetableVO:TimetableVO = new TimetableVO();
protected function init(event:FlexEvent):void
{
Alert.show(Show);
timetableVO = myEditEvent.editDataGrid.selectedItem as TimetableVO;

Alert.show(value+ timetableVO.startDate);


但是在那个时候Alert Not Printing ....
是他们以其他方式访问Sub1.mxml中的 editTimetableVO 到Sub2.mxml文件...

package
{
public class ModelLocator {
public static var instance:ModelLocator;

public var editTimetableVO:*;
$ b public function ModelLocator(instance:SingletonEnforcer){}
$ b public static function getInstance():ModelLocator {
if(!instance){
instance = new ModelLocator(new SingletonEnforcer());
}
返回实例;



} class SingletonEnforcer {}

// sub1.mxml
[Bindable] private var model:ModelLocator = ModelLocator .getInstance();
public function forwardToCreateEvent(event:MouseEvent):void
{
model.editTimetableVO = new TimetableVO();
model.editTimetableVO = editDataGrid.selectedItem as TimetableVO; // editDataGrid is DataGrid id
Alert.show(value+ model.editTimetableVO.startDate);
}


// Sub2.mxml
[Bindable] private var model:ModelLocator = ModelLocator.getInstance();
protected function init(event:FlexEvent):void
{
Alert.show(Show);
model.timetableVO = myEditEvent.editDataGrid.selectedItem as TimetableVO;

Alert.show(value+ model.timetableVO.startDate);

}


I'm Using Flex + java .. in that i have two Sub mxml files Sub1.mxml and Sub2.mxml

Sub1.mxml code..

[Bindable] private var editTimetableVO:TimetableVO;
        public function forwardToCreateEvent(event:MouseEvent):void
        {
            editTimetableVO = new TimetableVO();
editTimetableVO=editDataGrid.selectedItem as TimetableVO;//editDataGrid is DataGrid id
                Alert.show("value   "+editTimetableVO.startDate);
            }

Hear Alert is Print some date it is good... then my Second Mxml file..

Sub2.mxml code..

public var myEditEvent:Sub1 = new Sub1();
private var timetableVO:TimetableVO = new TimetableVO();

    //  private var editTimetableVO:TimetableVO = new TimetableVO();
        protected function init(event:FlexEvent):void
        {
            Alert.show("Show");
            timetableVO=myEditEvent.editDataGrid.selectedItem as TimetableVO;

            Alert.show("value "+timetableVO.startDate);

        }

But in that time Alert not Printing ....Is their any other way to access to editTimetableVO in Sub1.mxml to Sub2.mxml file...

解决方案
package
{
public class ModelLocator{
    public static var instance:ModelLocator;

    public var editTimetableVO:*;

    public function ModelLocator(instance:SingletonEnforcer){}

    public static function getInstance():ModelLocator{
        if(!instance){
            instance = new ModelLocator(new SingletonEnforcer());
        }
        return instance;
    }
}

}class SingletonEnforcer{}

// sub1.mxml
[Bindable]private var model:ModelLocator = ModelLocator.getInstance();
    public function forwardToCreateEvent(event:MouseEvent):void
    {
        model.editTimetableVO = new TimetableVO();
        model.editTimetableVO=editDataGrid.selectedItem as     TimetableVO;//editDataGrid is DataGrid id
        Alert.show("value   "+model.editTimetableVO.startDate);
        }


// Sub2.mxml
[Bindable]private var model:ModelLocator = ModelLocator.getInstance();
    protected function init(event:FlexEvent):void
    {
        Alert.show("Show");
        model.timetableVO=myEditEvent.editDataGrid.selectedItem as TimetableVO;

        Alert.show("value "+model.timetableVO.startDate);

    }

这篇关于如何将Java对象发送到Java中的两个mxml文件之间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 09:04