0

i am new in actionscript3, i have a problem with my code that i refer to Designing for a multi-device, multi-resolution world and i stuck at initializing starling. the syntax is good but found error when i test my project by ctrl+enter. here is my code

this.stage.align = StageAlign.TOP_LEFT;
this.stage.scaleMode = StageScaleMode.NO_SCALE;

import feathers.system.DeviceCapabilities;

DeviceCapabilities.dpi = 265;
DeviceCapabilities.screenPixelWidth = 480;
DeviceCapabilities.screenPixelHeight = 800;

import starling.core.Starling;
import flash.events.Event;

var starling:Starling;

this.loaderInfo.addEventListener(Event.COMPLETE, loaderInfoComplete);
function loaderInfoComplete(e:Event):void
{

    starling=new Starling(Main, this.stage);
    starling.start();
}
tejom
  • 1
  • 2

2 Answers2

0

The Problem is from the initiation of Starling: starling=new Starling(Main, this.stage);

It needs a class rather than Main to startup.

What you need to do is insert a new symbol with class: screen and extends starling.display.Sprite. as Shown below: enter image description here

then modify your code as starling=new Starling(screen, this.stage);

PS: it seems you are using flash cs6 to develop starling. It is quite difficult to handle. Suggest Flash Develop or Flash Builder instead.

Jacky Lau
  • 665
  • 5
  • 21
0

When you create Starling, you need to pass in a class for Starling to instantiate as its "root" container. In your code, you're asking Starling to use a class named Main here:

starling=new Starling(Main, this.stage);

Do you have a file in your project named Main.as? If not, then you need to create one. Here's some simple example code that you could try to add to Main.as:

package
{
    import starling.display.Sprite;

    public class Main extends Sprite
    {
        public function Main()
        {
            super();

            var quad:Quad = new Quad(100, 100, 0xff000);
            addChild(quad);
        }
    }
}
Josh Tynjala
  • 5,235
  • 3
  • 23
  • 25