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

  • Home
  • SEARCH
  • 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 4592746
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T22:35:03+00:00 2026-05-21T22:35:03+00:00

Yesterday someone on here was helping me with a problem I was having. I

  • 0

Yesterday someone on here was helping me with a problem I was having. I accepted the Answer before I had tested it and am running into a problem.

What I am doing is I have an airplane mc and a crate mc. The airplane flies along the y axis and I was trying to get the crate mc to drop somewhere randomly along the plane’s path. The plane keeps dropping crates at every point along the y axis.

The code I’m using to move the plate/drop the crate is:

function makePlane():void
{
    var chance:Number = Math.floor(Math.random() * 60);
    if (chance <= 1)
    {
        trace(chance);

        var tempPlane:MovieClip;
        //Make sure a Library item linkage is set to Plane...
        tempPlane = new Airplane();
        tempPlane.planeSpeed = 10;
        tempPlane.x = Math.round(Math.random() * 1000);
        tempPlane.y = Math.round(Math.random() * -1000);
        addChild(tempPlane);
        trace("Made Plane!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
        planes.push(tempPlane);
    }
}

function movePlane():void
{

    var tempX:Number;
    var tempCrate:MovieClip;
    var tempPlane:MovieClip;

    for (var j:int =planes.length-1; j>=0; j--)
    {
        tempPlane = planes[j];
        tempPlane.y +=  tempPlane.planeSpeed;
        tempCrate = new Crate();
        tempCrate.y = tempPlane.y;
        tempCrate.x = tempPlane.x;
        addChild(tempCrate);
        crates.push(tempCrate);
    }
}

The code someone gave me to drop 1 crate only instead of numerous crates is:

  function addRandomCreation():void{
    var animationTime:Number = 5000; //The time the planes will be animating in ms 

    for(var i:int = 0; i < planes.length; i++){
        var planeTimer:Timer = new Timer(Math.round(animationTime * Math.random()));
        planeTimer.addEventListener(TimerEvent.TIMER, timerComplete(i));
        planeTimer.start();
    }
}

function timerComplete(planeID:int):function{
    return function(event:TimerEvent):void{
        event.target.stop();
        event.target.removeEventListener(event.type, arguments.callee);

        var tempCrate:MovieClip = new Crate();
        tempY = Math.round(Math.random() * planes[planeID].y);
        tempCrate.y = tempY;
        tempCrate.x = planes[planeID].x;
        addChild(tempCrate);        
    }
}

When I try using this code I get the error ‘function is not a type’. I’ve never seen function used as a return type before. Can anyone help me?

  • 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-21T22:35:04+00:00Added an answer on May 21, 2026 at 10:35 pm

    The return type function should be capitalized: Function. The timerComplete function is locking the planeID in a closure, so that it is accessible from the event handler (the function returned from timerComplete).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

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.