Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/file/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Actionscript 3 TypeError:Error#2007:参数子项必须为非null_Actionscript 3 - Fatal编程技术网

Actionscript 3 TypeError:Error#2007:参数子项必须为非null

Actionscript 3 TypeError:Error#2007:参数子项必须为非null,actionscript-3,Actionscript 3,我正在运行以下代码: package { import fl.controls.Button; import fl.controls.Label; import fl.controls.RadioButton; import fl.controls.RadioButtonGroup; import flash.display.Sprite; import flash.events.MouseEvent; import flash.text.TextFieldAutoSize; public

我正在运行以下代码:

package {

import fl.controls.Button;
import fl.controls.Label;
import fl.controls.RadioButton;
import fl.controls.RadioButtonGroup;
import flash.display.Sprite;
import flash.events.MouseEvent;
import flash.text.TextFieldAutoSize;

public class RadioButtonExample extends Sprite {
    private var j:uint;
    private var padding:uint = 10;
    private var currHeight:uint = 0;
    private var verticalSpacing:uint = 30;

    private var rbg:RadioButtonGroup;
    private var questionLabel:Label;
    private var answerLabel:Label;
    private var question:String = "What day is known internationally as Speak Like A Pirate Day?";
    private var answers:Array = [ "August 12", "March 4", "September 19", "June 22" ];

    public function RadioButtonExample() {
        setupQuiz();
    }
    private function setupQuiz():void {
        setupQuestionLabel();
        setupRadioButtons();
        setupButton();
        setupAnswerLabel();
    }
    private function setupQuestionLabel():void {
        questionLabel = new Label();
        questionLabel.text = question;
        questionLabel.autoSize = TextFieldAutoSize.LEFT;
        questionLabel.move(padding, padding + currHeight);

        currHeight += verticalSpacing;
        addChild(questionLabel);
    }
    private function setupAnswerLabel():void {
        answerLabel = new Label();
        answerLabel.text = "";
        answerLabel.autoSize = TextFieldAutoSize.LEFT;
        answerLabel.move(padding + 120, padding + currHeight);

        addChild(answerLabel);
    }
    private function setupRadioButtons():void {
        rbg = new RadioButtonGroup("question1");
        createRadioButton(answers[0], rbg);
        createRadioButton(answers[1], rbg);
        createRadioButton(answers[2], rbg);
        createRadioButton(answers[3], rbg);
    }
    private function setupButton():void {
        var b:Button = new Button();
        b.move(padding, padding + currHeight);
        b.label = "Check Answer";
        b.addEventListener(MouseEvent.CLICK, checkAnswer);

        addChild(b);
    }
    private function createRadioButton(rbLabel:String, rbg:RadioButtonGroup):void {
        var rb:RadioButton = new RadioButton();
        rb.group = rbg;
        rb.label = rbLabel;
        rb.move(padding, padding + currHeight);
        addChild(rb);

        currHeight += verticalSpacing;
    }
    private function checkAnswer(e:MouseEvent):void {
        if (rbg.selection == null) {
            return;
        }
        var resultStr:String = (rbg.selection.label == answers[2]) ? "Correct" : "Incorrect";
        answerLabel.text = resultStr;
    }
}
}

这是来自AdobeLiveDocs。 我在舞台上添加了一个单选按钮,然后删除了它,这样它就在图书馆里了

然而,我得到以下错误

TypeError:Error#2007:参数子项必须为非null。 在flash.display::DisplayObjectContainer/addChildAt()中 在fl.controls::BaseButton/fl.controls:BaseButton::牵引地面() 在fl.controls::LabelButton/fl.controls:LabelButton::draw()处 在fl.controls::Button/fl.controls:Button::draw() 在fl.core::UIComponent/::callLaterDispatcher()处


有谁能告诉我发生了什么以及如何删除此错误。

这里的问题是您的库中没有包含按钮组件

将按钮从“组件”面板(以及RadioButton组件)拖到库中(或将其拖到后台并删除)。运行时错误将消失,您将在问题下方有一个“检查答案”按钮