Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/actionscript-3/7.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 #2007:参数格式必须为非空?_Actionscript 3_Flash_Parameters_Format - Fatal编程技术网

Actionscript 3 #2007:参数格式必须为非空?

Actionscript 3 #2007:参数格式必须为非空?,actionscript-3,flash,parameters,format,Actionscript 3,Flash,Parameters,Format,我的as3代码有问题, 我尝试将电影剪辑链接到不同的场景(测验场景)。 所以,我一共有2个测验,第一个测验是使用外部脚本(as) 第二个测验和第一个测验有相同的脚本,但我把动作脚本放在佛罗里达州,它有不同的xml。 但随后出现了以下错误消息: TypeError: Error #2007: Parameter format must be non-null. at flash.text::TextField/set defaultTextFormat() at hiragana/createTe

我的as3代码有问题, 我尝试将电影剪辑链接到不同的场景(测验场景)。 所以,我一共有2个测验,第一个测验是使用外部脚本(as) 第二个测验和第一个测验有相同的脚本,但我把动作脚本放在佛罗里达州,它有不同的xml。 但随后出现了以下错误消息:

TypeError: Error #2007: Parameter format must be non-null.
at flash.text::TextField/set defaultTextFormat()
at hiragana/createText()[E:\flash\!!!! FLASH JADI\PAK ASHAR FIX\hiragana.as:80]
at hiragana/kuisdua()[hiragana::frame209:48]
at hiragana/frame209()[hiragana::frame209:249]
代码如下:

  // creates a text field
    public function createText(text:String, tf:TextFormat, s:Sprite, x,y:         Number, width:Number): TextField {
        var tField:TextField = new TextField();
        tField.x = x;
        tField.y = y;
        tField.width = width;
        tField.defaultTextFormat = tf; //looks like this is the source of problem (-.-)
        tField.selectable = false;
        tField.multiline = true;
        tField.wordWrap = true;
        if (tf.align == "left") {
            tField.autoSize = TextFieldAutoSize.LEFT;
        } else {
            tField.autoSize = TextFieldAutoSize.CENTER;
        }
        tField.text = text;
        s.addChild(tField);
        return tField;
    }
这是埃蒂尔密码

import flash.display.*;
import flash.text.*;
import flash.events.*;
import flash.net.URLLoader;
import flash.net.URLRequest;

///*public class*/ kuisduaa extends MovieClip {

    // question data
    /*private*/ var dataXML2:XML;

    // text formats
    /*private*/ var questionFormat2:TextFormat;
    /*private*/ var answerFormat2:TextFormat;
    /*private*/ var scoreFormat2:TextFormat;

    // text fields
    /*private*/ var messageField2:TextField;
    /*private*/ var questionField2:TextField;
    /*private*/ var scoreField2:TextField;

    // sprites and objects
    /*private*/ var gameSprite2:Sprite;
    /*private*/ var questionSprite2:Sprite;
    /*private*/ var answerSprites2:Sprite;
    /*private*/ var gameButton2:GameButton;

    // game state variables
    /*private*/ var questionNum2:int;
    /*private*/ var correctAnswer2:String;
    /*private*/ var numQuestionsAsked2:int;
    /*private*/ var numCorrect2:int;
    /*private*/ var answers2:Array;

    /*public*/ function kuisdua() {

        // create game sprite
        gameSprite2 = new Sprite();
        addChild(gameSprite2);

        // set text formats
        questionFormat2 = new TextFormat("Arial",80,0xffffff,true,false,false,null,null,"center");
        answerFormat2 = new TextFormat("Arial",50,0xffffff,true,false,false,null,null,"left");
        scoreFormat2 = new TextFormat("Arial",30,0xffffff,true,false,false,null,null,"center");

        // create score field and starting message text
        scoreField2 = createText("",scoreFormat,gameSprite,-30,550,550);
        messageField2 = createText("Loading Questions...",questionFormat,gameSprite,0,50,550);

        // set up game state and load questions
        questionNum2 = 0;
        numQuestionsAsked2 = 0;
        numCorrect2 = 0;
        showGameScore2();
        xmlImport2();
    }

    // start loading of questions
    /*public*/ function xmlImport2() {
        var xmlURL:URLRequest = new URLRequest("kuis2.xml");
        var xmlLoader:URLLoader = new URLLoader(xmlURL);
        xmlLoader.addEventListener(Event.COMPLETE, xmlLoaded);
    }

    // questions loaded
    /*public*/ function xmlLoaded2(event:Event) {
        dataXML  = XML(event.target.data);
        gameSprite.removeChild(messageField);
        messageField = createText("Tap Untuk Memulai",scoreFormat,gameSprite,-10,250,500);
        showGameButton("mulai");
    }

    // creates a text field
    /*public*/ function createText2(text:String, tf:TextFormat, s:Sprite, x,y: Number, width:Number): TextField {
        var tField2:TextField = new TextField();
        tField2.x = x;
        tField2.y = y;
        tField2.width = width;
        tField2.defaultTextFormat = tf;
        tField2.selectable = false;
        tField2.multiline = true;
        tField2.wordWrap = true;
        if (tf.align == "left") {
            tField2.autoSize = TextFieldAutoSize.LEFT;
        } else {
            tField2.autoSize = TextFieldAutoSize.CENTER;
        }
        tField2.text = text;
        s.addChild(tField2);
        return tField2;
    }

    // updates the score
    /*public*/ function showGameScore2() {
        scoreField2.text = "Soal: "+numQuestionsAsked2+"   Benar: "+numCorrect2;
    }

    // ask player if they are ready for next question
    /*public*/ function showGameButton2(buttonLabel:String) {
        gameButton = new GameButton();
        gameButton.label.text = buttonLabel;
        gameButton.x = 240;
        gameButton.y = 480;
        gameSprite2.addChild(gameButton);
        gameButton.addEventListener(MouseEvent.CLICK,pressedGameButton2);
    }

    // player is ready
    /*public*/ function pressedGameButton2(event:MouseEvent) {
        // clean up question
        if (questionSprite2 != null) {
            gameSprite2.removeChild(questionSprite2);
        }

        // remove button and message
        gameSprite2.removeChild(gameButton);
        gameSprite2.removeChild(messageField2);

        // ask the next question
        if (questionNum >= dataXML.child("*").length()) {
            gotoAndStop(6);
        } else {
            askQuestion2();
        }
    }

    // set up the question
    /*public*/ function askQuestion2() {
        // prepare new question sprite
        questionSprite2 = new Sprite();
        gameSprite2.addChild(questionSprite2);

        // create text field for question
        var question2:String = dataXML.item[questionNum].question2;
        if (dataXML.item[questionNum].question.@type == "text") {
            questionField2 = createText(question2,questionFormat2,questionSprite2,50,150,300);
        } else {
            var questionLoader2:Loader = new Loader();
            var questionRequest2:URLRequest = new URLRequest("triviaimages/"+question2);
            questionLoader2.load(questionRequest2);
            questionLoader2.y = 150;
            questionLoader2.x = 180;
            questionSprite2.addChild(questionLoader2);
        }

        // create sprite for answers, get correct answer and shuffle all
        correctAnswer2 = dataXML.item[questionNum2].answers.answer[0];
        answers2 = shuffleAnswers(dataXML.item[questionNum2].answers);

        // put each answer into a new sprite with a icon
        answerSprites2 = new Sprite();
        var xpos:int = 0;
        var ypos:int = 0;
        for(var i:int=0;i<answers2.length;i++) {
            var answerSprite2:Sprite = new Sprite();
            if (answers2[i].type == "text") {
                var answerField2:TextField = createText(answers2[i].value,answerFormat2,answerSprite2,30,-35,200);
            } else {
                var answerLoader2:Loader = new Loader();
                var answerRequest2:URLRequest = new URLRequest("triviaimages/"+answers2[i].value);
                answerLoader2.load(answerRequest2);
                answerLoader2.y = -22;
                answerLoader2.x = 25;
                answerSprite2.addChild(answerLoader2);
            }
            var letter:String = String.fromCharCode(65+i); // A-D
            var circle:Circle = new Circle(); // from Library
            circle.letter.text = letter;
            circle.answer = answers[i].value;
            answerSprite2.x = 100+xpos*250;
            answerSprite2.y = 350+ypos*100;
            xpos++
            if (xpos > 1) {
                xpos = 0;
                ypos += 1;
            }
            answerSprite2.addChild(circle);
            answerSprite2.addEventListener(MouseEvent.CLICK,clickAnswer); // make it a button

            // set a larger click area
            answerSprite2.graphics.beginFill(0x000000,0);
            answerSprite2.graphics.drawRect(-50, 0, 200, 80);

            answerSprites2.addChild(answerSprite2);
        }
        questionSprite2.addChild(answerSprites2);
    }

    // take all the answers and shuffle them into an array
    /*public*/ function shuffleAnswers2(answers:XMLList) {
        var shuffledAnswers2:Array = new Array();
        while (answers2.child("*").length() > 0) {
            var r:int = Math.floor(Math.random()*answers.child("*").length());
            shuffledAnswers2.push({type: answers2.answer[r].@type, value: answers2.answer[r]});
            delete answers2.answer[r];
        }
        return shuffledAnswers2;
    }

    // player selects an answer
    /*public*/ function clickAnswer2(event:MouseEvent) {

        // get selected answer text, and compare
        var selectedAnswer2 = event.currentTarget.getChildAt(1).answer;
        if (selectedAnswer2 == correctAnswer2) {
            numCorrect++;
            messageField2 = createText("Hai, kamu benar ! ",scoreFormat2,gameSprite2,-30,280,550);
        } else {
            messageField2 = createText("Iie, Jawabanmu Salah, yang benar adalah:",scoreFormat2,gameSprite2,53,280,370);
        }

        finishQuestion();
    }

    /*public*/ function finishQuestion2() {
        // remove all but the correct answer
        for(var i:int=0;i<4;i++) {
            answerSprites2.getChildAt(i).removeEventListener(MouseEvent.CLICK,clickAnswer);
            if (answers2[i].value != correctAnswer2) {
                answerSprites2.getChildAt(i).visible = false;
            } else {
                answerSprites2.getChildAt(i).x = 200;
                answerSprites2.getChildAt(i).y = 400;
            }
        }

        // next question
        questionNum2++;
        numQuestionsAsked2++;
        showGameScore2();
        showGameButton2("Lanjutkan");
    }

    // clean up sprites
    /*public*/ function CleanUp2() {
        removeChild(gameSprite);
        gameSprite2 = null;
        questionSprite2 = null;
        answerSprites2 = null;
        dataXML2 = null;
    }
导入flash.display.*;
导入flash.text.*;
导入flash.events.*;
导入flash.net.urloader;
导入flash.net.URLRequest;
///*公共类*/kuisduaa扩展了MovieClip{
//问题数据
/*private*/var dataXML2:XML;
//文本格式
/*private*/var questionFormat2:TextFormat;
/*private*/var answerFormat2:TextFormat;
/*private*/var scoreFormat2:TextFormat;
//文本字段
/*private*/var messageField2:TextField;
/*private*/var questionField2:TextField;
/*private*/var scoreField2:TextField;
//精灵和物体
/*private*/var gameSprite2:Sprite;
/*private*/var问题Sprite 2:Sprite;
/*private*/var answerSprites2:Sprite;
/*private*/var gameButton2:GameButton;
//博弈状态变量
/*私有*/var问题num2:int;
/*private*/var correctAnswer2:字符串;
/*private*/var numQuestionsAsked2:int;
/*private*/var numCorrect2:int;
/*私有*/var应答2:数组;
/*公共*/功能kuisdua(){
//创建游戏精灵
gameSprite2=新精灵();
addChild(gameSprite2);
//设置文本格式
questionFormat2=新文本格式(“Arial”,80,0xffffff,true,false,false,null,null,“中间”);
answerFormat2=新文本格式(“Arial”,50,0xffffff,真,假,假,空,空,“左”);
scoreFormat2=新的文本格式(“Arial”,30,0xffffff,真,假,假,空,空,“中心”);
//创建分数字段和起始消息文本
scoreField2=createText(“”,scoreFormat,gameSprite,-3050550);
messageField2=createText(“加载问题…”),问题格式,游戏精灵,0,50550);
//设置游戏状态并加载问题
问卷num2=0;
numQuestionsAsked2=0;
numCorrect2=0;
showGameScore2();
xmlmimport2();
}
//开始加载问题
/*public*/函数xmlmimport2(){
var xmlURL:URLRequest=newurlRequest(“kuis2.xml”);
var xmlLoader:URLLoader=新的URLLoader(xmlURL);
addEventListener(Event.COMPLETE,xmlLoaded);
}
//大量问题
/*public*/函数xmloaded2(事件:event){
dataXML=XML(event.target.data);
gameSprite.removeChild(messageField);
messageField=createText(“点击Untuk Memulai”,scoreFormat,gameSprite,-10250500);
showGameButton(“mulai”);
}
//创建一个文本字段
/*public*/函数createText2(text:String,tf:TextFormat,s:Sprite,x,y:Number,width:Number):TextField{
var tField2:TextField=newtextfield();
tField2.x=x;
tField2.y=y;
t字段2.width=宽度;
tField2.defaultTextFormat=tf;
tField2.selective=false;
tField2.multiline=true;
tField2.wordWrap=true;
如果(tf.align==“左”){
tField2.autoSize=TextFieldAutoSize.LEFT;
}否则{
tField2.autoSize=TextFieldAutoSize.CENTER;
}
tField2.text=文本;
s、 addChild(tField2);
返回tField2;
}
//更新分数
/*public*/函数showGameScore2(){
scoreField2.text=“Soal:+numQuestionsAsked2+”Benar:+numCorrect2;
}
//询问玩家是否准备好回答下一个问题
/*public*/函数showGameButton2(按钮标签:字符串){
gameButton=新建gameButton();
gameButton.label.text=按钮标签;
gameButton.x=240;
gameButton.y=480;
gameSprite2.addChild(gamesbutton);
gameButton.addEventListener(MouseEvent.CLICK,pressedGameButton2);
}
//玩家准备好了
/*public*/按功能按钮2(事件:MouseEvent){
//清理问题
if(questionSprite2!=null){
游戏精神2.移除儿童(问题精神2);
}
//删除按钮和消息
gameSprite2.removeChild(游戏按钮);
gameSprite2.removeChild(messageField2);
//问下一个问题
if(questionNum>=dataXML.child(“*”).length(){
gotoAndStop(6);
}否则{
询问问题2();
}
}
//提出问题
/*public*/函数askQuestion2(){
//准备新问题雪碧
问题精灵2=新精灵();
游戏精灵2.添加儿童(问题精灵2);
//为问题创建文本字段
变量question2:String=dataXML.item[questionNum].question2;
if(dataXML.item[questionNum].question.@type==“text”){
questionField2=createText(问题2,问题格式2,问题精神2,50150300);
}否则{
var questionLoader2:Loader=new Loader();
var questionRequest2:URLRequest=新的URLRequest(“triviaimages/”+question2);
问题加载程序2.加载(问题请求程序2);
问卷2.y=150;
提问者2.x=180;
问题2.addChild(问题加载程序2);
}
//为答案创建精灵,获得正确答案并洗牌所有
correctAnswer2=dataXML.item[questionNum2]。answers.answers[0];
answers2=shuffleAnswers(dataXML.item[questionNum2].answers);
//将每个答案放入带有图标的新精灵中
answerSprites2=新精灵();
var xpos:int=0;
var-ypos:int=0;
对于(变量i:int=0;i 1){
xpos=0;
ypos+=1;
}
回答2.添加儿童(圆圈);
answerSprite2.addEventListener(MouseEvent.CLICK,clickAnswer);//使其成为一个按钮
//设置一个更大的cl
messageField2 = createText("Loading Questions...",questionFormat,gameSprite,0,50,550);
messageField = createText("Tap Untuk Memulai",scoreFormat,gameSprite,-10,250,500);