Actionscript 3 AS3物体在1.5-2分钟后莫名其妙地消失

Actionscript 3 AS3物体在1.5-2分钟后莫名其妙地消失,actionscript-3,Actionscript 3,我是as3新手,但一直在学习。 我正在创建一个带有文本字段输入的容器,这样用户就可以创建一个“post”。当动画从舞台移除时会触发此操作,动画完成后会自动执行此操作 然而,大约1.5-2分钟后,容器莫名其妙地消失了。这是一个问题,因为用户可能需要花费2分钟以上的时间来发表文章。 我一辈子都搞不清楚为什么会发生这种情况,这可能是垃圾收集的问题吗 非常感谢您的帮助,谢谢 丹 你知道你的alpha递增器没有舍入问题吗?我将检查alpha的整数值,而不是实际的浮点值。或者,模糊比较alpha>=1-fu

我是as3新手,但一直在学习。 我正在创建一个带有文本字段输入的容器,这样用户就可以创建一个“post”。当动画从舞台移除时会触发此操作,动画完成后会自动执行此操作

然而,大约1.5-2分钟后,容器莫名其妙地消失了。这是一个问题,因为用户可能需要花费2分钟以上的时间来发表文章。 我一辈子都搞不清楚为什么会发生这种情况,这可能是垃圾收集的问题吗

非常感谢您的帮助,谢谢


你知道你的alpha递增器没有舍入问题吗?我将检查alpha的整数值,而不是实际的浮点值。或者,模糊比较alpha>=1-fuzz&&alpha是否使用此函数同时创建多篇文章?我明白你关于垃圾收集的观点,但它不应该删除stage元素,因为你声明了变量,它应该足以保护它免受垃圾的影响……alpha值在增加,所以即使条件没有触发,这也不应该是他的问题。无论如何,总的来说,这是一件好事。
var titleText:Title = new Title();
var titleInput:TextField = new TextField();

var categoryText:Category = new Category();
var categoryInput:TextField = new TextField();

var postText:Text = new Text();
var postInput:TextField = new TextField();

//setup text formats to be used
var postCreationTextFormat:TextFormat = new TextFormat();

postCreationTextFormat.font = "arial";
postCreationTextFormat.size = 20;
postCreationTextFormat.align = "left";
postCreationTextFormat.leftMargin = 2;


//Fade In Post Creation Box after Seed to Bud Animation.
seedToBud.addEventListener(Event.REMOVED_FROM_STAGE, createPostInput);

//Some variables to declare for the createPostInput function.
var postCreationContainer:PostCreationContainer = new PostCreationContainer;
var contentWindow:ContentWindow = new ContentWindow;
var postCreationInputBoxes:PostCreationInputBoxes = new PostCreationInputBoxes;
var thumb:Thumb = new Thumb;
var track:Track = new Track;
var scrollDownArrow:ScrollDownArrow = new ScrollDownArrow;
var scrollUpArrow:ScrollUpArrow = new ScrollUpArrow;

function createPostInput(event:Event)
{
    addChild(postCreationContainer);    
    postCreationContainer.x = 230;
    postCreationContainer.y = 400;

    postCreationContainer.addChild(track);
    track.x = 428;
    track.y = 25;

    postCreationContainer.addChild(thumb);
    thumb.x = 418;
    thumb.y = 25;

    postCreationContainer.addChild(scrollDownArrow);
    scrollDownArrow.x = 418;
    scrollDownArrow.y = 269;

    postCreationContainer.addChild(scrollUpArrow);
    scrollUpArrow.x = 418;
    scrollUpArrow.y = 6;

    postCreationContainer.addChild(contentWindow);
    contentWindow.x = 6;
    contentWindow.y = 6;

    postCreationContainer.addChild(postCreationInputBoxes);
    postCreationInputBoxes.x = 6;
    postCreationInputBoxes.y = 6;

    postCreationContainer.alpha = 0;
    postCreationContainer.addEventListener(Event.ENTER_FRAME, fadeInCreatePostInput);

    postCreationInputBoxes.addChild(titleText);
    titleText.x = 0;
    titleText.y = 0;

    postCreationInputBoxes.addChild(titleInput);

    postCreationInputBoxes.addChild(categoryText);
    categoryText.x = 0;
    categoryText.y = 60;

    postCreationInputBoxes.addChild(categoryInput);

    postCreationInputBoxes.addChild(postText);
    postText.x = 0;
    postText.y = 124;

    postCreationInputBoxes.addChild(postInput); 

    titleInput.defaultTextFormat = postCreationTextFormat;
    titleInput.type = "input";
    titleInput.multiline = false;
    titleInput.wordWrap = false;
    titleInput.maxChars = 150;
    titleInput.border = true;
    titleInput.width = 403;
    titleInput.height = 30;
    titleInput.x = 0;
    titleInput.y = 32;
    titleInput.background = true;
    titleInput.backgroundColor = 0xFFFFFF;

    categoryInput.defaultTextFormat = postCreationTextFormat;
    categoryInput.type = "input";
    categoryInput.multiline = false;
    categoryInput.wordWrap = false;
    categoryInput.maxChars = 150;
    categoryInput.border = true;
    categoryInput.width = 403;
    categoryInput.height = 30;
    categoryInput.x = 0;
    categoryInput.y = 96;
    categoryInput.background = true;
    categoryInput.backgroundColor = 0xFFFFFF;

    postInput.defaultTextFormat = postCreationTextFormat;
    postInput.type = "input";
    postInput.multiline = true;
    postInput.wordWrap = true;
    postInput.maxChars = 500;
    postInput.border = true;
    postInput.width = 403;
    postInput.height = 361.5;
    postInput.x = 0;
    postInput.y = 156;
    postInput.background = true;
    postInput.backgroundColor = 0xFFFFFF;

    stage.focus = titleInput;
    seedToBud.removeEventListener(Event.REMOVED_FROM_STAGE, createPostInput);
}

function fadeInCreatePostInput(event:Event):void
{
    postCreationContainer.alpha += 0.05;
    if (postCreationContainer.alpha == 1)
    {
        postCreationContainer.removeEventListener(Event.ENTER_FRAME, fadeInCreatePostInput);
    }
}