Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
340 views
in Technique[技术] by (71.8m points)

actionscript 3 - AS3: Error 1009:

In a little game I have to make for college I render a menu at runtime, using movieclips i made of buttons i drawed in illustrator. I imported the illustrator file in flash professional like I always do, and made a AS linkage like I do with my other movieclips that run fine. But when I try to render these buttons I get a error 1009, a null reference. I use AS3 by the way.

private function initMenuComponents():void{
        var btnPlay:MovieClip = new Play();
        var btnOptions:MovieClip = new Options();
        var btnLikeOnFacebook:MovieClip = new LikeOnFacebook();
        var btnShareOnFacebook:MovieClip = new ShareOnFacebook();

        btnPlay.x = (stage.stageWidth / 2) - (btnPlay.width / 2);
        btnOptions.x = (stage.stageWidth / 2) - (btnOptions.width / 2);
        btnLikeOnFacebook.x = (stage.stageWidth / 2) - (btnLikeOnFacebook.width / 2);
        btnShareOnFacebook.x = (stage.stageWidth / 2) - (btnShareOnFacebook.width / 2);

        btnPlay.y = 100;
        btnOptions.y = 150;
        btnLikeOnFacebook.y = 200;
        btnShareOnFacebook.y = 250;

        stage.addChild(btnPlay);
        stage.addChild(btnOptions);
        stage.addChild(btnLikeOnFacebook);
        stage.addChild(btnShareOnFacebook);
    }
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

It sounds like you're not properly linking the files in the IDE. The error you're seeing stems from this issue. I would comment out almost all of your code, and test to find exactly where the error is.

var btnPlay:MovieClip = new Play();
//var btnOptions:MovieClip = new Options();
//var btnLikeOnFacebook:MovieClip = new LikeOnFacebook();
//var btnShareOnFacebook:MovieClip = new ShareOnFacebook();

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...