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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T17:42:14+00:00 2026-05-16T17:42:14+00:00

I have the following code: package ; import flash.display.DisplayObject; import flash.display.Graphics; import flash.display.MovieClip; import

  • 0

I have the following code:

package ;

import flash.display.DisplayObject;
import flash.display.Graphics;
import flash.display.MovieClip;
import flash.display.Shape;
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.geom.Rectangle;
import flash.Lib;
import flash.utils.Timer;

/**
 * ...
 * @author RCIX
 */

class Main 
{
 static function main()
 {
  trace("game started");
  var game : Game = new Game();
  game.Run();
  trace("game finished");
 }
}
class Game extends DisplayObject
{
 var rectX : Int;
 var rectY : Int;
 var velocityX : Int;
 var velocityY : Int;

 var screenBounds : Rectangle;
 var graphics : Graphics;

 public function new()
 {
  super();
  screenBounds = Lib.current.getBounds(new DisplayObject());
  graphics = Lib.current.graphics;
  Lib.current.addChild(this);
  trace("Game constructor");
 }

 public function Run()
 {
  trace("Run");
  Lib.current.addEventListener(Event.ENTER_FRAME, OnFrameEnter);
  velocityX = 1;
  velocityY = 1;
 }
 function OnFrameEnter(event : Event)
 {
  trace("OnFrameEnter");
  graphics.beginFill(0xFFFFFF, 0xFFFFFF);
  graphics.drawRect(0, 0, screenBounds.width, screenBounds.height);
  graphics.endFill();
  Update();
 }
 function Update()
 {
  trace("Updating");
  if (rectX + 50 > screenBounds.width || 
      rectX < 0)
  {
   velocityX *= -1;
  }
  if (rectY + 50 > screenBounds.height || 
      rectY < 0)
  {
   velocityY *= -1;
  }
  rectX += 1;
  rectY += 1;
  graphics.beginFill(0xFF0000);
  graphics.drawRect(rectX, rectY, 50, 50);
  graphics.endFill();
 }
}

but the only trace output i get is “Game started”; nothing else is tracing or working. Why?

Update: After having fixed the screenBounds problem, the following problems remain:

  • None of my OnFrameEnter or Update calls ever trace; why?
  • Extending my Game class from DisplayObject makes things grind to a halt and never get to any of my other code, regardless of whether i call super(); in the constructor.

Update: since the first problem is a separate issue, i’m splitting that out into another question.

  • 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-16T17:42:14+00:00Added an answer on May 16, 2026 at 5:42 pm

    From AS3 language reference:

    DisplayObject is an abstract base class; therefore, you cannot call DisplayObject directly. Invoking new DisplayObject() throws an ArgumentError exception.

    So basically you should extends Shape or Sprite instead of DisplayObject.

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

Sidebar

Related Questions

I have this code: package graphics { import flash.display.Sprite; import flash.events.*; public class Ball
I've the following code in my displayandmove.as file: package { import flash.display.MovieClip; public class
I have the following code package myPackage; import org.neo4j.graphdb; import org.neo4j.kernel.EmbeddedGraphDatabase; public class dbServlet
I have the following code. The problem is that neither SELECT nor CANCEL event
I have written the following code with permissions included in the manifest file. package
Hi i have the following Groovy code: package fp; abstract class Function { public
I Have following code: Controller: public ActionResult Step1() { return View(); } [AcceptVerbs(HttpVerbs.Post)] public
I have following Code Block Which I tried to optimize in the Optimized section
I'm trying to use opengl in C#. I have following code which fails with
I have the following code in a web.config file of the default IIS site.

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.