此行引发堆栈错误 (FlashDevelop) 未编译错误。我还有其他错误,但我认为其他错误可能来自于此。
任何人都可以理解为什么代码的这个基本部分有问题吗?
在外部错误查看器中显示时为 1009。
线条
if (stage) {init();}
抛出这个错误。
它不会毫无错误地附加第二个精灵-尽管它似乎确实设置在舞台上-即使它们之前(使用 4.4.2)也没有给出任何结果,但是我刚刚更新到 4.4.3。
package
{
import flash.display.Bitmap;
import flash.display.Sprite;
import flash.events.*;
import flash.ui.Keyboard;
//import board;
import flash.accessibility.AccessibilityImplementation;
import flash.display.Bitmap;
import flash.display.MovieClip;
import flash.text.TextField;
import flash.text.TextFormat;
import flash.display.Sprite;
import flash.utils.ByteArray;
import flash.events.MouseEvent;
import flash.text.AntiAliasType;
import flash.utils.describeType;
import boxsprite;
import flash.net.*;
import flash.display.Stage;
import board;
/**
* ...
* @author Michael
*/
public class Main extends Sprite
{
internal var kanaList:Vector.<String> = new <String>["あ/ア", "あ/ア", "え/え", "え/え", "い/イ", "い/イ", "お/オ", "お/オ", "う/ウ", "う/ウ", "う/ウ", "う/ウ", "か/カ", "か/カ", "け/ケ", "け/ケ", "き/キ", "き/キ", "く/ク", "く/ク", "こ/コ", "こ/コ", "さ/サ", "さ/サ", " し/シ", " し/シ", "す/ス", "す/ス", "そ/ソ", "そ/ソ", "す/ス", "す/ス", "た/タ", "た/タ", "て/テ", "て/テ", " ち/チ", " ち/チ", "と/ト", "と/ト", "つ/ツ", "つ/ツ", "ら/ラ", "ら/ラ", "れ/レ", "れ/レ", "り/リ", "り/リ", "ろ/ロ", "ろ/ロ", "る/ル", "る/ル", "だ/ダ", "で/デ", "じ/ジ", "ど/ド", "ず/ズ", "ざ/ザ", "ぜ/ゼ", "ぞ/ゾ", "な/ナ", "ね/ネ", "に/二", "の/ノ", "ぬ/ヌ", "じゃ/ジャ", "じゅ/ジュ", "じょ/ジョ", "ん/ン", "しゃ/シャ", "しゅ/シュ", "しょ/ショ", "や/ヤ", "ゆ/ユ", "よ/ヨ", "は/ハ", "ひ/ヒ", "ふ/フ", "へ/ヘ", "ほ/ホ", "ば/バ", "ば/バ", "ぶ/ブ", "ぶ/ブ", "び/ビ", "び/ビ", "ぼ/ボ", "ぼ/ボ", "べ/ベ", "べ/ベ", "ぱ/パ", "ぴ/ピ", "ぷ/プ", "ぺ/ペ", "ぽ/ポ", "ま/マ", "み/ミ", " む/ム", "め/メ", "も/モ", "を/ヲ", "みゃ/ミャ", "みゅ/ミャ", "みょ/ミョ", "きゃ/キャ", "きゅ/キュ", "きょ/キョ", "にゃ/ニャ", "にゅ/ニュ", "にょ/ニョ", "びゃ/びゃ", "びゅ/ビュ", "びょ/ビョ", " ひゃ/ヒャ", "ひゅ/ヒュ", "ひょ/ヒョ", "ぴゃ/ピャ", "ぴゅ/ピュ", "ぴょ/ピョ", "っ/ッ", "っ/ッ"];
internal var valueList:Vector.<uint>= new <uint>[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 10, 10, 5, 5, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 20, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 1, 1];
// Lists of Kana that can be replaced in the replace mode and the substitute Kana and Values
internal var selectghostList:Vector.<String>=new<String>["ま/マ","む/ム","も/モ","か/カ","く/ク","こ/コ","な/ナ","ぬ/ヌ","の/ノ","ば/バ","ぶ/ブ","ぼ/ボ","は/ハ","ふ/フ","ほ/ホ","ぱ/パ","ぷ/プ","ぽ/ポ"];
internal var selectkanaList:Vector.<String>=new <String>["みゃ/ミャ", "みゅ/ミャ", "みょ/ミョ", "きゃ/キャ", "きゅ/キュ", "きょ/キョ", "にゃ/ニャ", "にゅ/ニュ", "にょ/ニョ", "びゃ/びゃ", "びゅ/ビュ", "びょ/ビョ", " ひゃ/ヒャ", "ひゅ/ヒュ", "ひょ/ヒョ", "ぴゃ/ピャ", "ぴゅ/ピュ", "ぴょ/ピョ"];
internal var selectghostvalueList:Vector.<uint>=new <uint>[2, 2, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2];
//Start list of playerHand contents as I don't know if Null is 0
internal var playernumber:uint;
internal var playerHand:Array = [[0], [0], [0], [0],[0], [0]];
[Embed(source = "C:/Windows/Fonts/Verdana.ttf", fontName = "Verdana", fontWeight = "bold", advancedAntiAliasing = "true", mimeType = "application/x-font")]
public static const VERD:Class;
/*[Embed(source="../lib/StartText.txt",mimeType="application/octet-stream")]
private var myFile:Class;
public var b:ByteArray = new myFile();
public var s:String = b.readUTFBytes(b.length)*/
public function Main():void
{
if (stage) {init();}
else addEventListener(Event.ADDED_TO_STAGE, init);
}
private function init(e:Event = null):void
{
removeEventListener(Event.ADDED_TO_STAGE, init);
//var board1:Sprite = new board();
//stage.addChild(board1);
//
var boardonScreen:Sprite = new board();
boardonScreen.x = 0;
boardonScreen.y = 0;
addChild(boardonScreen);
var box1:Sprite = new boxsprite();
box1.x = 480;
box1.y = 0;
addChild(box1);
}
package
{
import flash.display.Bitmap;
import flash.display.Sprite;
import flash.events.*;
import flash.ui.Keyboard;
//import board;
import flash.accessibility.AccessibilityImplementation;
import flash.display.MovieClip;
import flash.text.TextField;
import flash.text.TextFormat;
import flash.display.Sprite;
import flash.utils.ByteArray;
import flash.events.MouseEvent;
import flash.text.AntiAliasType;
import flash.utils.describeType;
import flash.net.*;
import Set;
import StatusBox;
import Statusx;
import flash.display.InteractiveObject;
import flash.text.TextFieldType;
import flash.events.FocusEvent;
import fl.managers.FocusManager;
import flash.display.*;
import flash.display.Stage;
import flash.events.KeyboardEvent;
public class boxsprite extends Sprite
{
[Embed(source="../lib/Box.jpg")]
private var boxspriteClass:Class
internal var mode:uint= 1;
internal var displaytext:String;
internal var setBox:Boolean = false;
internal var onBoard:Array = [0];
internal var playerRound:uint = 1;
internal var round:uint = 1;
public var playernumber:uint;
public function boxsprite():void
{
trace (mode);
init2();
addEventListener(KeyboardEvent.KEY_DOWN, myKeyDown);
choosetext();
}
private function init2():void
{
var boxsprite2:Bitmap = new boxspriteClass() as Bitmap;
this.addChild(boxsprite2); }
不管我如何写那部分,无论是 init 还是 init()
从日语翻译的错误并删除了名称。
null: TypeError: 1009 Error #.
at boxsprite / frontpage () ...Test \ New Project \ src \ boxsprite.as: 168]
at boxsprite / choosetext () ... Games \ Test \ New Project \ src \ boxsprite.as: 132]
at boxsprite () ... Test \ New Project \ src \ boxsprite.as: 53]
at Main / init () ...Test \ New Project \ src \ Main.as: 75]
at Main ().... \ Test \ New Project \ src \ Main.as: 56]
所有函数都是 ():void 除了 eventlistener 相关函数寻找自己没有未初始化的变量 - 一切都是在使用之前定义的。它完全无法创建文本字段,这就是 stage.focus 失败的原因。
package
{
import flash.display.Bitmap;
import flash.display.Sprite;
import flash.events.*;
import flash.ui.Keyboard;
//import board;
import flash.accessibility.AccessibilityImplementation;
import flash.display.MovieClip;
import flash.text.TextField;
import flash.text.TextFormat;
import flash.display.Sprite;
import flash.utils.ByteArray;
import flash.events.MouseEvent;
import flash.text.AntiAliasType;
import flash.utils.describeType;
import flash.net.*;
import Set;
import StatusBox;
import Statusx;
import flash.display.InteractiveObject;
import flash.text.TextFieldType;
import flash.events.FocusEvent;
import fl.managers.FocusManager;
import flash.display.*;
import flash.display.Stage;
import flash.events.KeyboardEvent;
public class boxsprite extends Sprite
{
[Embed(source = "C:/Windows/Fonts/Verdana.ttf", fontName = "Verdana", fontWeight = "bold", advancedAntiAliasing = "true", mimeType = "application/x-font")]
public static const VERD:Class;
[Embed(source="../lib/Box.jpg")]
private var boxspriteClass:Class
internal var mode:uint;
internal var displaytext:String;
internal var setBox:Boolean = false;
internal var onBoard:Array = [0];
internal var playerRound:uint = 1;
internal var round:uint = 1;
internal var playernumber:uint;
internal var myTextBox:TextField = new TextField();
public function boxsprite():void
{mode = 1;
trace (mode);
init2();
this.addEventListener(KeyboardEvent.KEY_DOWN, myKeyDown);
}
private function init2():void
{
var boxsprite2:Bitmap = new boxspriteClass() as Bitmap;
this.addChild(boxsprite2);
choosetext();
}
protected function myKeyDown(e2:KeyboardEvent):void
{if (e2.keyCode ==Keyboard.ENTER)
{
/*mode 2 is beginning mode- setting a tile prompts a Set event which return a StatusBox event which unsets the tile
* mode 3 is return mode- setting a tile prompts a Set event which triggers a change to mode 4
* mode 4 return finish- add more tiles to return and either press Enter to end game and remove tile ID from hand list or double click any tile which trigger Status Box event to unset tiles
* mode 5 exchange simpler- setting a tile prompts a Set event which adds to temp list triggers function replace which a create simpleTile- double click on either triggers StatusBox event which kills the other tile and removes the tile from player list
* mode 6 exchange Kanji- setting a tile prompts Set event which triggers function newKanji which creates a kanjiTile-
* mode 7 set more tiles add to temp remove list double click on any set tile or click on Kanji tile to write Kanji or double click to complete press H to hide other tile to check with other players
* mode 8 end turn- press Enter to end score or press R to return tiles to hand
* mode 9 score
*/
switch (mode)
{ case 1:{mode = 2;
choosetext();
}
case 8:
{ mode = 9;}
case 9:
{mode = 2;
turn1();
}
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
if (setBox == false){
if (onBoard.length>1)
{mode = 8;
choosetext();}}
if (onBoard.length == 1)
{mode = 2;
choosetext();
turn1();
}
else if (setBox == true)
//set SetBox to true only for
{mode += 1;
choosetext();
}
}
}
if (e2.keyCode ==Keyboard.H)
{
navigateToURL(new URLRequest("http://wp.me/P3FUQl-n"));
}
//else if (e.Keycode == Keyboard.Q)
}
internal function choosetext():void
{switch (mode)
{case 1: {myTextBox.text = "";
frontpage();
trace ("mode is one"); }
case 2: {myTextBox.text = "Below are your tiles. Move them onto the board- double click to place. 下記のタイルは場所にボードをダブルクリックにそれらを移動している。"; }
case 3: {myTextBox.text = "Remove from your hand- place tile on the box (double click)- Press Enter when done.ボックス(ダブルクリック)であなたの手の場所のタイルから削除 - 終了したら、Enterキーを押します。";}
case 4: {myTextBox.text = "Press Enter to remove tiles and end your turn or double click any placed tile to not remove.タイルを削除してターンを終了するには、Enterキーを押したり、ダブル削除しないように、任意のタイル配置をクリックします。";}
case 5: {myTextBox.text = "Place tile on box to get alternate kana tile- double click the one that you want あなたが望むものを得るために別の仮名タイルをダブルクリックを取得するためのボックスの上に置いてタイル" }
case 6: {myTextBox.text = "Place tile on box to get blank tile for writing kanji- click on it. 漢字を書くために空白のタイルを取得するためのボックスの上に置いてタイル. それをクリック";}
case 7: {myTextBox.text = "Place more tiles to form full reading. Press H to (un)hide other tiles so partner can check. Double click on the new or one old to select. 完全読書を形成するために多くのタイルを配置します。パートナーがチェックすることができるように他のタイルを隠すために、Hを押します。選択して新規または1歳をダブルクリックします。"; }
case 8: {myTextBox.text = "Press Enter if you or other players are OK with your word(s) or press R to return tiles. あなたや他のプレイヤーがあなたの言葉でOKであればEnterキーを押すか、タイルを返すためにRを押してください。"; }
case 9: {myTextBox.text = " Your score for this turn is below as calculated is below. Press S to reduce score and A to increase score. このターンのためにあなたのスコアは以下のように下にある計算されます。スコアAを押しますを高めるためにスコアSキーを押しを低減するために、"; }
}
}
protected function frontpage():void
{ //Introduction
trace ("draw");
var playerQ:TextField = new TextField();
playerQ.text = "Number of players 1-6?プレイヤーの数は(1)";
trace (playerQ.text);
playerQ.x = 0;
playerQ.y = 0;
playerQ.width = 64;
playerQ.height = 32;
playerQ.wordWrap = true;
this.addChild(playerQ);
var playernotext:TextField = new TextField();
playernotext.type = TextFieldType.INPUT;
playernotext.x = 0;
playernotext.y = 32;
playernotext.width = 32;
playernotext.height = 32;
playernotext.border = true;
addChild(playernotext);
stage.focus = playernotext;
playernotext.restrict = "1-6";
if (mode!=1){
if (playernotext.text != null)
{
playernumber = Number(playernotext.text); }
else
{playernumber = 1; }}
}
protected function turn1():void
{
if (playerRound > playernumber)
{playerRound = 1;
round += 1;
//create();
//display();
}
}
/*
deal();
}
internal function deal():void
{ var tileattrib:Array;
var kana:String;
var value:uint;
var newTileGroup:Array;
for (var i:uint = 1; i < 8; i += 1)
{
tileattrib = playerHand[playerRound[i]];
var newTile:Sprite = new tile(tileattrib[1],tileattrib[2]);
newTile.x = 15*32;
newTile.y = (15-i)*32;
newTileGroup.push(newTile);
addChild(newTile);}
}*/
protected function display():void
{
var format:TextFormat = new TextFormat("VERD", 20);
format.size = 20;
format.color = 0xFF0000;
format.font = "VERD";
myTextBox.defaultTextFormat = format;
myTextBox.setTextFormat(format);
myTextBox.antiAliasType = AntiAliasType.ADVANCED;
myTextBox.multiline = true;
myTextBox.textColor = 0xFF0000;
myTextBox.background = true;
myTextBox.border = true;
myTextBox.type = TextFieldType.DYNAMIC;
myTextBox.x=4;
myTextBox.y=4;
myTextBox.width = 32*4-4;
myTextBox.height = 32*6;
myTextBox.wordWrap = true;
stage.addChild(myTextBox);
myTextBox.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownScroll);
//
function mouseDownScroll(event:MouseEvent):void
{
myTextBox.scrollV+=1;
}
}
}
}
出于某种原因,如果我推理它至少会创建实例和文本字段,尽管它仍然对 Enter 按键没有响应。如果我在 Main() 中注释掉对 Board() 的引用
package
{
import flash.display.Bitmap;
import flash.display.Sprite
import flash.text.TextField
import flash.text.TextFormat
import flash.events.MouseEvent
import flash.text.AntiAliasType
import flash.events.KeyboardEvent
import flash.ui.Keyboard
/**
* ...
* @author ...
*/
public class board extends Sprite
{
[Embed(source="../lib/Board.jpg")]
private var boardClass :Class;
public function board():void
{
start();
this.addEventListener(KeyboardEvent.KEY_DOWN, kill);
}
private var startBox:TextField = new TextField();
private function start():void
{var boardclass1:Bitmap = new boardClass() as Bitmap
this.addChild(boardclass1);
startBox.text = "Jabble. Click to Scroll Down. (下にスクロールする]をクリック) Instructions alternate between English and Japanese (translations). Press H for the help web page or put http://wp.me/P3FUQl-n in your web browser. Beneath is the Board and to the right is the Box. Press ENTER to go through the game stages- complete word, check and the score, deal next set of tiles. Press Spacebar to change the tile return modes- remove tiles from hand, exchange for alternate kana, exchange for a kanji. Click and Drag Tiles to move it and double click it set it on a square space on the Board or Box and click on the Box to change its mode. Jabble- 英語と日本語(訳)との間で交互に指示。を押して、ヘルプWebページのHまたはWebブラウザでhttp://wp.me/P3FUQl-nを置く。下には、取締役会であり、右に?などのさらなる命令ディスプレイボックスです.、ゲームを通してステージコンプリート単語、チェックとスコアを行くタイルの次のセットを扱うためにEnterキーを押します。モード·削除タイルの手札からタイル戻り、代替カナ引き換え、漢字と引き換えを変更するにはスペースバーを押します。クリックして、それを移動し、倍増するタイルをドラッグ 。クリックして、それを移動するにはタイルをドラッグし、ダブル会またはボックス上の正方形のスペースには、それを設定してクリックし、そのモードを変更するには、ボックスをクリックしてください " ;
var format:TextFormat = new TextFormat("VERD", 20);
format.size = 20;
format.color = 0xFF0000;
format.font = "VERD";
startBox.defaultTextFormat = format;
startBox.setTextFormat(format);
startBox.antiAliasType = AntiAliasType.ADVANCED;
startBox.multiline = true;
startBox.textColor = 0xFF0000;
startBox.background = true;
startBox.border = true;
startBox.x=32;
startBox.y=32;
startBox.width = 32*13;
startBox.height = 32*13;
startBox.wordWrap = true;
this.addChild(startBox);
startBox.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownScroll);
//
function mouseDownScroll(event:MouseEvent):void
{
startBox.scrollV+=1;
}
}
private function kill (e:KeyboardEvent):void
{ if (e.keyCode == Keyboard.ENTER)
{removeChild(startBox);
startBox = null;
this.removeEventListener(KeyboardEvent.KEY_DOWN, kill);
}
}
}
}