feathersui / feathersui-starling

User interface components for Starling Framework and Adobe AIR

Home Page:https://feathersui.com/learn/as3-starling/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

The Getting started with Feathers tutorial seems incomplete

chrisvelevitch opened this issue · comments

The Getting started with Feathers tutorial seems incomplete. I'm pretty sure my Feathers install is complete because I used the Feathers SDK Manager and have successfully built and ran the HelloWorld example that comes with the SDK.

The example HelloWorld that comes with the SDK is MXML-based whereas the Getting started with Feathers tutorial is ActionScript-based. When I build and run it, all I get is a blank page. I've gone through the tutorial several times to see what I left but I can't find it. I can't seem to find a copy of the complete working code anywhere for comparison.

When I try do debug this code, I'm getting:-

[Fault] exception, information=TypeError: Error #2023: Class Main$ must inherit from Sprite to link to the root.

which is a bit confusing because Main is extending Sprite (see below).

What am I doing wrong here? What's missing that the tutorial has left out?

Below is my complete code:-

package
{
    import feathers.controls.Button;
    import feathers.controls.TextCallout;
    import feathers.themes.MetalWorksMobileTheme;

    import starling.display.Sprite;
    import starling.events.Event;

    public class Main extends Sprite
    {
        public function Main()
        {
            new MetalWorksMobileTheme();
            super();
            addEventListener( Event.ADDED_TO_STAGE, addedToStageHandler );
        }

        protected var button:Button;

        protected function addedToStageHandler( event:Event ):void
        {

            button = new Button();
            button.label = 'Click Me';
            button.validate();
            button.addEventListener( Event.TRIGGERED, button_triggeredHandler );
            button.x = (this.stage.stageWidth - this.button.width) / 2;
            button.y = (this.stage.stageHeight - this.button.height) / 2;
            addChild(button);
        }

        protected function button_triggeredHandler( event:Event ):void
        {
            TextCallout.show( "Hi, I'm Feathers!\nHave a nice day.", this.button );
        }
    }
}

Check out the other getting started tutorial for the Feathers SDK and MXML:

https://feathersui.com/help/sdk/getting-started-mxml.html

The tutorial that you were trying to follow was for the pure ActionScript version of Feathers. When you download the Feathers library, it includes a different example project, which includes some extra code that is required to initialize Starling. You can find it on GitHub here:

https://github.com/BowlerHatLLC/feathers/tree/master/examples/HelloWorld

The tutorial omits this part because it is assumed that you've already learned how to initialize Starling by following Starling's own getting started tutorial (as listed in the prerequisites).

The Feathers SDK automatically initializes Starling for you, in case you are wondering.