Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7668297
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T15:19:40+00:00 2026-05-31T15:19:40+00:00

I have a function that draws a rectangle on the screen (see createInfoPanel()) While

  • 0

I have a function that draws a rectangle on the screen (see createInfoPanel())
While drawing rectangle, I am adding 2 text fields on it.
But as you may guess, it is adding those immediately.
I want to delay adding these text fields, then I want to remove these panels after a while.
The problem is, when I set an interval or timer, they won’t work after I using once (I had to stop them by clearing/removing, it didn’t set them again).
Since my panel is being created each time image changes, I need them to work every time image changes.

So, I have 2 questions:
1- How can I re-set interval each time my createInfoPanel() function works? It won’t work anymore after setting and claring once.

2- You can see infoPanel.addChild(titleField); line in addInfoPanel() function. How can I work a smooth animation here? I mean, text appears slowly?

Thanks in advance.

public class ImageRotator extends Sprite
{
private var ... ; //Some variables

public function ImageRotator(xmlPath:String = "images.xml", interval:int = 8301):void
{
    timer = new Timer(interval);
    loadXML(xmlPath);
}

private function loadXML(file:String):void
{
    urlLoader = new URLLoader(new URLRequest(file));
    urlLoader.addEventListener(Event.COMPLETE, parseXML);
}

private function parseXML(e:Event):void
{
    xml = new XML(e.target.data);
    loadImages();
}

private function loadImages():void
{
    for (var i:int = 0; i < xml.children().length(); i++)
    {
        var loader:Loader = new Loader();
        loader.load(new URLRequest(xml.children()[i].@src));
        imagesVector.push(loader);
        loader.contentLoaderInfo.addEventListener(Event.COMPLETE, sortImages);
    }
}

private function sortImages(e:Event):void
{
    imagesCounter++;

    for (var i:int = 0; i < imagesVector.length; i++)
    {
        imagesVector.reverse();
        addChild(imagesVector[i]);
    }

    //I have only 3 images, I needed to set indexes because
    //they were covering each other
    this.setChildIndex(imagesVector[2], 0);
    this.setChildIndex(imagesVector[1], 0);
    this.setChildIndex(imagesVector[0], 0);

    if (imagesCounter == imagesVector.length)
    {
        createInfoPanel();
        timer.addEventListener(TimerEvent.TIMER, autoChange);
        timer.start();
    }

}

private function createInfoPanel():void
{
    infoPanel.graphics.beginFill(0x000000, 0.0);
    infoPanel.graphics.drawRect(0, 0, 967, 138);
    infoPanel.graphics.endFill();

////Here I want to run addInfoPanel() function with 2 seconds delay,
////After it starts, I want to run removeInfoPanel() function with 2 more seconds delay

    addChild(infoPanel);

}

private function addInfoPanel():void {
    titleField.text = xml.children()[infoCounter]. @ title;
    titleField.x = 425;
    titleField.y = 0;

    description.text = xml.children()[infoCounter]. @ description;
    description.x = 427;
    description.y = 26;

    infoPanel.y = 300;
    infoPanel.addChild(titleField);
    infoPanel.addChild(description);
}

private function removeInfoPanel():void {

    infoPanel.removeChild(titleField);
    infoPanel.removeChild(description);
}

private function addActions():void
{
    //Some function
}

private function changeImage(e:MouseEvent):void
{
    //Image changing function
}

private function changeDepth(e:TweenEvent):void
{
    //Some function
}

private function autoChange(e:TimerEvent):void
{
    //Some function
}
}

Edit: How I used to work the intervals:

private function createInfoPanel():void
{
    //lines above code sample
    intervalInfoPanel = setInterval(addInfoPanel,2000);

    addChild(infoPanel);
}

private function addInfoPanel():void {
    //lines above code sample
    clearInterval(intervalInfoPanel);
    intervalInfoPanelRemove = setInterval(removeInfoPanel,3500);
}

private function removeInfoPanel():void {
    //lines above code sample
    clearInterval(intervalInfoPanelRemove);
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T15:19:42+00:00Added an answer on May 31, 2026 at 3:19 pm

    1- How can I re-set interval each time my createInfoPanel() function
    works? It won’t work anymore after setting and claring once.

    how exactly are you resetting your interval? you don’t show the code here.
    but normally you can reset + re-use a timer like this:

    timer.reset();
    

    this will stop and reset the timer’s currentCount to 0.
    you can then later say timer.start(); and everything should work like it never ran before.

    2- You can see infoPanel.addChild(titleField); line in addInfoPanel()
    function. How can I work a smooth animation here? I mean, text appears
    slowly?

    use a tween. add the TextFields with txt.alpha = 0; and then tween the alpha value slowly to 1.0. TweenLite (http://www.greensock.com/tweenlite/) is a great tweening-engine.

    import com.greensock.*;
    
    txt.alpha = 0.0;
    TweenLite.to(txt, 1, {alpha:1.0, delay:0.4});
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wrote a drawing function that draws various on-screen sprites. These sprites can only
I have the following function that draws some data from a chi-squared distribution and
So we have a function DrawPoint(x,y) that draws a point, we have to draw
I have a global variable p. I have a function that draws (or redraws)
I have written a function that draws x number of squares in a random
I have a helper method drawRect(p1, p2) that draws a rectangle (in orthographic projection).
I have a function that draw an image on graphics: private void DrawSmallImage(Graphics g)
So I have function that formats a date to coerce to given enum DateType{CURRENT,
In my Java code I have function that gets file from the client in
I have a function that gives me the following warning: [DCC Warning] filename.pas(6939): W1035

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.