NSouth
NSouth

Reputation: 5276

Having trouble running my first Flash project in FlashDevelop (using Starling)

I'm new to Flash development and I'm trying to work with Starling, but I'm having trouble getting my tutorial project to run. The most difficult part has been finding a good setup guide. The Starling guide is quite outdated. Here's what I've done.

  1. Installed FlashDevelop (default settings)
  2. Used FlashDevelop's "AppMan" to install "AIR SD + ASC 2.0", ver 14.
  3. Created a new "AIR Mobile AS3 App" project.
  4. Changed project target to AIR Mobile 14.0
  5. Added "Hi-Res-Stats" src and Starling src to project Classpaths
  6. Added "-swf-version=25" to the compiler options.
  7. Copied out the attached code
  8. Added my downloaded AIR 15 SDK to the project properties (because it complained and I couldn't find the AIR 14 SDK)
  9. Ran program. Got these errors...

C:\Users\Noah\Dev Stuff\Flash Dev\DemoHungryHeroASC\src\Main.as:21: Error: Implicit coercion of a value of type Stats to an unrelated type DisplayObject.

C:\Users\Noah\Dev Stuff\Flash Dev\DemoHungryHeroASC\src\Main.as:23: Error: Implicit coercion of a value of type Stage to an unrelated type Stage.

Here's my code. What do you think? Thanks!

Main.as

package 
{
   import net.hires.debug.Stats;
   import starling.core.Starling;
   import starling.display.Sprite;
   /**
    * ...
    * @author NSouth
    */
   public class Main extends Sprite 
   {
      private var stats:Stats;
      private var myStarling:Starling;
      
      public function Main():void 
      {
         stats = new Stats();
         this.addChild(stats);
         
         myStarling = new Starling(Game, stage);
         myStarling.antiAliasing = 1;
         myStarling.start();
      }
   }
}

Game.as

package 
{
   import starling.display.Sprite;
   import starling.events.Event;
   
   /**
    * ...
    * @author NSouth
    */
   public class Game extends Sprite
   {
      public function Game()
      {
         super();
         this.addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
      }
      
      private function onAddedToStage(event:Event):void
      {
         trace("this was initialized");
      }
   }
}

Upvotes: 0

Views: 340

Answers (1)

Crabar
Crabar

Reputation: 1857

Your Main class must extends flash.display.Sprite instead of starling.display.Sprite.

Example

Upvotes: 1

Related Questions