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 6793421
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:05:54+00:00 2026-05-26T18:05:54+00:00

I’m trying to figure out why, when I create a movieclip in flashdevelop, said

  • 0

I’m trying to figure out why, when I create a movieclip in flashdevelop, said movieclip always ends up being null.

Here is the code I’m trying to use:

import flash.display.MovieClip;
    import flash.events.Event;
    import flash.display.Sprite;
    import flash.display.Bitmap;

    public class Rain extends MovieClip
    {
        [Embed(source = '../../../../../lib/images/icons/drop.png')]
        private var Drop: Class;

        private var offset:int = 50;
        private var dropsNumber:int;
        private var dropsVector:Vector.<MovieClip> = new Vector.<MovieClip>();

        public var drop:MovieClip;

        public function init(drops:int, fallSpeed:int, windSpeed:int, hArea:int, vArea:int, dir:String):void
        {
            dropsNumber = drops;

            if (dir == "right")
            {
                offset *= -1;
            }

            for (var i:int = 0; i < drops; i++)
            {
                drop = new Drop() as MovieClip;

                drop.fallSpeed = fallSpeed;
                drop.windSpeed = windSpeed;
                drop.dir = dir;
                drop.hArea = hArea;
                drop.vArea = vArea;

                drop.x = Math.random() * (hArea + offset);
                drop.y=Math.random()*vArea;

                //

                drop.scaleX = Math.round(((Math.random() * 1) + 0.3) * 10) / 10;
                drop.scaleY=drop.scaleX;

                //

                dropsVector.push(drop);

                addChild(drop);
            }

            inTheDirection();
        }

        private function inTheDirection():void
        {
            for (var i:int = 0; i < dropsNumber; i++)
            {
                switch (dropsVector[i].dir)
                {
                    case "left" :

                        dropsVector[i].addEventListener(Event.ENTER_FRAME, moveLeft);

                        break;

                    case "right" :

                        dropsVector[i].scaleX*=-1;
                        dropsVector[i].addEventListener(Event.ENTER_FRAME, moveRight);

                        break;

                    default :

                        trace("There is some error dude...");
                }
            }
        }

        private function moveLeft(e:Event):void
        {
            e.target.x-=e.target.windSpeed;
            e.target.y+=Math.random()*e.target.fallSpeed;

            if (e.target.y>e.target.vArea+e.target.height)
            {
                e.target.x = Math.random() * (e.target.hArea + (offset * 2));
                e.target.y=- e.target.height;
            }
        }

        private function moveRight(e:Event):void
        {
            e.target.x+=e.target.windSpeed;
            e.target.y+=Math.random()*e.target.fallSpeed;

            if (e.target.y>e.target.vArea+e.target.height)
            {
                e.target.x = Math.random() * (e.target.hArea - offset * 2) + offset * 2;//Check
                e.target.y=- e.target.height;
            }
        }
    }

It is meant to draw rain drops on the screen for a rainy effect but I’m getting this error:

**[Fault] exception, information=TypeError: Error #1009: Cannot access a property or method of a null object reference.
Fault, Rain.as:32**

I’ve done some looking around to no avail. So any help is greatly appreciated!

Thanks!

  • 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-26T18:05:55+00:00Added an answer on May 26, 2026 at 6:05 pm

    The problem is that your Drop class is a Bitmap. It cannot have properties dynamically added.

    The easy fix is to create empty movie clips and add your drop to it. The better fix is to write a custom class for your Drop that has the properties you need. But since you only asked for the easy fix, try this:

    drop = new MovieClip();
    drop.addChild(new Drop());
    

    That should replace:

    drop = new Drop() as MovieClip; // replace this line
    

    The better fix is to make a class that extends Bitmap with the properties you want like so:

    package 
    {
        import flash.display.Bitmap;
        import flash.display.BitmapData;
    
        /**
         * ...
         * @author ...
         */
    
         [Embed(source = '../../../../../lib/images/icons/drop.png')]
          private var DropArt: Class;
          public var fallSpeed;
          public var windSpeed;
          public var dir;
          public var hArea;
          public var vArea;
    
        public class  Drop extends Bitmap
        {   
            var art:Bitmap  = new DropArt();
            this.bitmapData = art.bitmapData;
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I'm trying to create an if statement in PHP that prevents a single post
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString

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.