Flex 3:将一个 arrayCollection 设置为另一个会导致应用程序停止运行

发布于 2024-11-25 12:31:12 字数 2701 浏览 0 评论 0原文

我将继续并 C/P 整个函数,以确保你们看到发生的一切:

public function directorsPrepsToShow():void
{
    var tempDPrepsAC:ArrayCollection = new ArrayCollection;
    var dprepSD:Date = new Date;
    var dprepED:Date = new Date;
    var viewSD:Date = rightDate(startViewDate.getMonth(), startViewDate.getDate(), startViewDate.getFullYear());
    var viewED:Date = rightDate(viewSD.getMonth(), viewSD.getDate() + 14, viewSD.getFullYear());
    var newACIDs:String = new String;
    var useACIDs:String = new String;

    for each (var item:Object in dPrepAC)
    {
            dprepSD = textToDate(item[2]);
            dprepED = rightDate(dprepSD.getMonth(), Number(dprepSD.getDate() + (item[3] - 1)), dprepSD.getFullYear());

            if (dateCollider(dprepSD, dprepED, viewSD, viewED))
                    tempDPrepsAC.addItem(item as Array);
    }

    if (tempDPrepsAC.length != usePrepAC.length)
    {
            usePrepAC = new ArrayCollection();
            usePrepAC = tempDPrepsAC;
            Alert.show("HI");
    }
}

该函数位于一个单独的文件中,通过以下方式从主 mxml 调用:

<mx:Script source="functions/dprep.as" />

导致应用程序停止的行是“ usePrepAC = tempDPrepAC;”。 usePrepAC 在主 mxml 中声明如下:

[Bindable] public var usePrepAC:ArrayCollection = new ArrayCollection;

有人知道为什么这一行会导致应用程序停止吗?如果我注释掉该行,应用程序将正常加载(加载除此 AC 应包含的信息之外的所有内容)。我现在已经研究了大约一个小时,尝试不同的方法将 tempDPrepsAC 的内容放入 usePrepAC - 但没有任何效果。我尝试用谷歌搜索,但什么也没找到:(

谢谢, Brds

编辑

dprep AC 在主 mxml 中声明如下:

[Bindable] public var dPrepAC:ArrayCollection = new ArrayCollection;

填充它的函数如下:

public function createDirectorsPrepCollection(e:ResultEvent):void
{
    var xmlList:XMLList = XML(e.result).directorsprep;
    var dupString:String = "|";
    var tempArray:Array = new Array;

    for (var i:int = 0; i < xmlList.length(); i++)
    {
        if (dupString.indexOf(String("|" + xmlList[i].name.@id) + "|") == -1)
        {
            tempArray = new Array;
            tempArray[0] = xmlList[i].prepDBID;
            tempArray[1] = xmlList[i].projectDBID;
            tempArray[2] = xmlList[i].startdate;
            tempArray[3] = xmlList[i].numdays;
            tempArray[4] = xmlList[i].positions;

            dPrepAC.addItem(tempArray);

            dupString += "|" + xmlList[i].prepDBID + "|";
        }
    }

    directorsPrepsToShow();
}

该函数是这样调用的:

<mx:HTTPService id="dprepHttp" url="{dprepXML}" resultFormat="e4x" makeObjectsBindable="true" result="createDirectorsPrepCollection(event)" />

dPrepAC 正在填充很好顺便说一句...我在 a 中检查它对于每个循环。

I'll just go ahead and C/P the entire function to ensure you guys see everything going on:

public function directorsPrepsToShow():void
{
    var tempDPrepsAC:ArrayCollection = new ArrayCollection;
    var dprepSD:Date = new Date;
    var dprepED:Date = new Date;
    var viewSD:Date = rightDate(startViewDate.getMonth(), startViewDate.getDate(), startViewDate.getFullYear());
    var viewED:Date = rightDate(viewSD.getMonth(), viewSD.getDate() + 14, viewSD.getFullYear());
    var newACIDs:String = new String;
    var useACIDs:String = new String;

    for each (var item:Object in dPrepAC)
    {
            dprepSD = textToDate(item[2]);
            dprepED = rightDate(dprepSD.getMonth(), Number(dprepSD.getDate() + (item[3] - 1)), dprepSD.getFullYear());

            if (dateCollider(dprepSD, dprepED, viewSD, viewED))
                    tempDPrepsAC.addItem(item as Array);
    }

    if (tempDPrepsAC.length != usePrepAC.length)
    {
            usePrepAC = new ArrayCollection();
            usePrepAC = tempDPrepsAC;
            Alert.show("HI");
    }
}

This function is in a separate file, that's called from the main mxml via the following:

<mx:Script source="functions/dprep.as" />

The line that's causing the app to stall is "usePrepAC = tempDPrepAC;". usePrepAC is declared in the main mxml like this:

[Bindable] public var usePrepAC:ArrayCollection = new ArrayCollection;

Dose anybody see why this one line would cause the application to stall? If I comment out that line, the application loads fine (loads everything except for the information that this AC should contain). I've been looking at this now for about an hour, trying different ways to get the contents of tempDPrepsAC into usePrepAC - but nothing is working. I tried googling it, but found nothing :(

Thanks,
Brds

EDIT

dprep AC is declared in the main mxml like this:

[Bindable] public var dPrepAC:ArrayCollection = new ArrayCollection;

And the function that populates it is as follows:

public function createDirectorsPrepCollection(e:ResultEvent):void
{
    var xmlList:XMLList = XML(e.result).directorsprep;
    var dupString:String = "|";
    var tempArray:Array = new Array;

    for (var i:int = 0; i < xmlList.length(); i++)
    {
        if (dupString.indexOf(String("|" + xmlList[i].name.@id) + "|") == -1)
        {
            tempArray = new Array;
            tempArray[0] = xmlList[i].prepDBID;
            tempArray[1] = xmlList[i].projectDBID;
            tempArray[2] = xmlList[i].startdate;
            tempArray[3] = xmlList[i].numdays;
            tempArray[4] = xmlList[i].positions;

            dPrepAC.addItem(tempArray);

            dupString += "|" + xmlList[i].prepDBID + "|";
        }
    }

    directorsPrepsToShow();
}

This function is called by this:

<mx:HTTPService id="dprepHttp" url="{dprepXML}" resultFormat="e4x" makeObjectsBindable="true" result="createDirectorsPrepCollection(event)" />

dPrepAC is populating fine btw... I check it in a for each loop.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

怀念你的温柔 2024-12-02 12:31:12

尝试使用以下代码:

usePrepAC.source = tempDPrepsAC.source;

Try using following code:

usePrepAC.source = tempDPrepsAC.source;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文