English 中文(简体)
AS3 物体在1.5 - 2分钟后 disappear然消失
原标题:AS3 object inexplicably disappears after 1.5 - 2 minutes

I m new to as3 but have been learning as I go. I am creating a container which appears with text field inputs so the user can create a post . This is triggered to occur when an animation is removed from the stage which it does automatically when it has completed.

However after about 1.5-2 minutes the container inexplicably disappears. This is a problem as a user may well want to take more than 2 minutes to make a post. I cannot for the life of me figure out why this is happening, could it possible be a garbage collection issue?

非常感谢您,

丹麦

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);
    }
}
问题回答

Do you know for a fact that there are no rounding issues with your alpha incrementer? I d be checking the integer value of alpha and not the real, floating point value. Or, do a fuzz comparison (alpha >= 1-FUZZ && alpha <= 1+FUZZ) for some small value of FUZZ.





相关问题
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 ...

Sorting twodimensional Array in AS3

So, i have a two-dimensional Array of ID s and vote count - voteArray[i][0] = ID, voteArray[i][1] = vote count I want the top 3 voted items to be displayed in different colors, so i have a 2nd Array -...

Virtual Tour using sketch up, ajax, flash technologies

I want to know if there are existing technology that make your 3d models in sketch into virtual tours, using either Ajax or Flash for web presentation. If there s none, which will be a good approach ...

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 ...

热门标签