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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:33:13+00:00 2026-05-25T19:33:13+00:00

I’m creating game in which user is given a map and five flags. User

  • 0

I’m creating game in which user is given a map and five flags. User must drag flags, one by one to the countries, so after creating MovieClips that represent flags, I started creating code for them. That worked for France, but after I copied it to Germany and changed everything using CTRL+F (‘france’ to ‘germany’ and ‘France’ to ‘Germany’) it didn’t. Well, actually it did, but there is some error. That’s funny, coz German flag does absolutely everything it should, and still there is an error in the output. Here, that’s the code:

package  {
import flash.display.MovieClip;
import flash.events.MouseEvent;
public class flagGermany extends MovieClip {
    public var Name:String="Germany";
    public var atX:uint;
    public var atY:uint;
    public var wasGuessed:Boolean=false;
    public var isPressed:Boolean=false;
    public function flagGermany() {
        trace(this);
        this.addEventListener(MouseEvent.MOUSE_DOWN, dragEnable);
        this.addEventListener(MouseEvent.MOUSE_UP, dragDisable);
        stage.addEventListener(MouseEvent.MOUSE_UP, dragDisable);
    }
    function dragEnable(e:MouseEvent) {
        isPressed=true;
        trace(isPressed);
        atX=stage.mouseX-this.x;
        atY=stage.mouseY-this.y;
        this.alpha=0.3;
        this.mouseEnabled=false;
        stage.addEventListener(MouseEvent.MOUSE_MOVE, moveFlag);
    }
    function dragDisable(e:MouseEvent) {
        if(isPressed==true) {
            if(wasGuessed==false) {
                this.alpha=1;
                this.mouseEnabled=true;
            }
            trace("invoked by "+e.target);
            if(MovieClip(this.root).germany.currentFrame==2) {
                MovieClip(this.root).germany.gotoAndStop(3);
                MovieClip(this.root).germany.removeEventListener(MouseEvent.ROLL_OVER, MovieClip(this.root).hightlight);
                MovieClip(this.root).germany.removeEventListener(MouseEvent.ROLL_OUT, MovieClip(this.root).unhightlight);
                correct();
            }
            stage.removeEventListener(MouseEvent.MOUSE_MOVE, moveFlag);
            isPressed=false;
            trace(isPressed);
        }
    }
    function moveFlag(e:MouseEvent) {
        this.x=stage.mouseX-atX;
        this.y=stage.mouseY-atY;
    }
    function correct() {
        this.removeEventListener(MouseEvent.MOUSE_DOWN, dragEnable);
        this.removeEventListener(MouseEvent.MOUSE_UP, dragDisable);
        this.alpha=0;
        this.mouseEnabled=false;
        this.wasGuessed=true;
    }
}
}

And here’s an error:

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at flagGermany()
at flash.display::Sprite/constructChildren()
at flash.display::Sprite()
at flash.display::MovieClip()
at EM()

EM is main file’s Document Class. flagGermany() a constructor for German flag. Both flags are created on second frame of the movie. What’s the matter with my code?!

  • 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-25T19:33:14+00:00Added an answer on May 25, 2026 at 7:33 pm

    Make sure stage is available before adding event listeners to it:

    public function flagGermany() {
        /* .. */
        addEventListener("addedToStage", onAddedToStage);
    }
    
    
    private function onAddedToStage(event:*):void {
        stage.addEventListener(MouseEvent.MOUSE_UP, dragDisable);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm making a simple page using Google Maps API 3. My first. One marker
I need to clean up various Word 'smart' characters in user input, including but
I have a text area in my form which accepts all possible characters from
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and

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.