actionscript 3 - Error 1007- Instantiation attempted on a non-constructor -
new error me- can't see why problem - compiles fails error 1007 despite changing considerable amounts of code- still same error clearing debugger window allows run tile.as.
as per pulsar's request here entire code 2 problem files.
this in main.as
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; import flash.events.keyboardevent; import flash.ui.keyboardtype; import set; import tile; /** * ... * @author michael */ public class main extends sprite { [embed(source="../lib/board.jpg")] private var boardclass :class; public function main():void {if (stage) init(); else addeventlistener(event.added_to_stage, init); } private var t1:sprite; private var t2:sprite; private var t3:sprite; private var t4:sprite; private var t5:sprite; private var t6:sprite; private var t7:sprite; private var base:sprite; private var tilex:sprite; private var boardonscreen:bitmap; private var box1:sprite; private function init():void { removeeventlistener(event.added_to_stage, init); boardonscreen= new boardclass() bitmap; boardonscreen.x = 0; boardonscreen.y = 0; stage.addchild(boardonscreen); box1 = new boxsprite(); box1.x = 480; box1.y = 0; stage.addchild(box1); base = new tile(); base.x =672; base.y = 448; stage.addchild(base); t1 = new tile(); t1.x = 480; t1.y = 448; stage.addchild(t1); t2 = new tile(); t2.x = 480; t2.y = 416; stage.addchild(t2); t3 = new tile(); t3.x = 480; t3.y = 384; stage.addchild(t3); t4 = new tile(); t4.x = 480; t4.y = 352; stage.addchild(t4); t5 = new tile(); t5.x = 480; t5.y = 320; stage.addchild(t5); t6 = new tile(); t6.x = 480; t6.y = 288; stage.addchild(t6); t7 = new tile(); t7.x = 480; t7.y = 256; stage.addchild(t7);}}}
in file: tiles.as
package { import fl.transitions.*; import fl.transitions.easing.*; import flash.display.bitmap; import flash.display.sprite; import flash.events.*; import flash.events.mouseevent; import flash.text.textfield; import flash.text.*; import flash.utils.*; import lob; import flash.events.keyboardevent; import flash.ui.keyboard; import math; import main; import boxsprite; import statusbox; import set; ///these import functions used ease button place after drag public class tile extends sprite { private var kana:string; private var value:uint; //private const backingcolour:uint = 0xe0e0e0; private var type:uint; private var issetbox:boolean; private static var valueaggreg:uint; //value of kanjitile static private var ret:boolean; //do return tiles board static private var yplace:uint = 0; private var xx:int; private var yy:uint; private var initialx:uint; private var initialy:uint; private var finalx:uint; private var finaly:uint; private var id:uint; private var selectghostlist:vector.<string>=new<string>["ま,マ","む,ム","も,モ","か,カ","く,ク","こ,コ","な,ナ","ぬ,ヌ","の,ノ","ば,バ","ぶ,ブ","ぼ,ボ","は,ハ","ふ,フ","ほ,ホ","ぱ,パ","ぷ,プ","ぽ,ポ"]; private var selectkanalist:vector.<string>=new <string>["みゃ,ミャ", "みゅ,ミャ", "みょ,ミョ", "きゃ,キャ", "きゅ,キュ", "きょ,キョ", "にゃ,ニャ", "にゅ,ニュ", "にょ,ニョ", "びゃ,びゃ", "びゅ,ビュ", "びょ,ビョ", " ひゃ,ヒャ", "ひゅ,ヒュ", "ひょ,ヒョ", "ぴゃ,ピャ", "ぴゅ,ピュ", "ぴょ,ピョ"]; private var selectghostvaluelist:vector.<uint> = new <uint>[2, 2, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2]; private const multiplier:array = [["tw","1","1","dl","1","1","1","tw","1","1","1","dl","1","1","tw"],["1","dw","1","1","1","tl","1","1","1","tl","1","1","1","dw","1"],["1","1","dw","1","1","1","dl","1","dl","1","1","1","dw","1","1"],["dl","1","1","dw","1","1","1","dl","1","1","1","dw","1","1","dl"],["1","1","1","1","dw","1","1","1","1","1","dw","1","1","1","1"],["1","tl","1","1","1","tl","1","1","1","tl","1","1","1","tl","1"],["1","1","dl","1","1","1","dl","1","dl","1","1","1","dl","1","1"],["tw","1","1","dl","1","1","1","dl","1","1","1","dl","1","1","tw"],["1","1","dl","1","1","1","dl","1","dl","1","1","1","dl","1","1"],["1","tl","1","1","1","tl","1","1","1","tl","1","1","1","tl","1"],["1","1","1","1","dw","1","1","1","1","1","dw","1","1","1","1"],["dl","1","1","dw","1","1","1","dl","1","1","1","dw","1","1","dl"],["1","1","dw","1","1","1","dl","1","dl","1","1","1","dw","1","1"],["1","dw","1","1","1","tl","1","1","1","tl","1","1","1","dw","1"],["tw","1","1","dl","1","1","1","tw","1","1","1","dl","1","1","tw"]]; private var vis:boolean = true; //visibility private var isset:boolean; [embed(source = "c:/users/makiko/desktop/michael/games/test/new project/lib/tile.png")] private var tileclass:class private var kanalist:vector.<string> = new <string>["あ,ア", "あ,ア", "え,エ", "え,エ", "い,イ", "い,イ", "お,オ", "お,オ", "う,ウ", "う,ウ", "う,ウ", "う,ウ", "か,カ", "か,カ", "け,ケ", "け,ケ", "き,キ", "き,キ", "く,ク", "く,ク", "こ,コ", "こ,コ", "さ,サ", "さ,サ", " し,シ", " し,シ", "す,ス", "す,ス", "そ,ソ", "そ,ソ", "す,ス", "す,ス", "た,タ", "た,タ", "て,テ", "て,テ", " ち,チ", " ち,チ", "と,ト", "と,ト", "つ,ツ", "つ,ツ", "ら,ラ", "ら,ラ", "れ,レ", "れ,レ", "り,リ", "り,リ", "ろ,ロ", "ろ,ロ", "る,ル", "る,ル", "だ,ダ", "で,デ", "じ,ジ", "ど/ド", "ず,ズ", "ざ,ザ", "ぜ,ゼ", "ぞ/ゾ", "な,ナ", "ね,ネ", "に,二", "の,ノ", "ぬ,ヌ", "じゃ,ジャ", "じゅ,ジュ", "じょ,ジョ", "ん,ン", "しゃ,シャ", "しゅ,シュ", "しょ,ショ", "や,ヤ", "ゆ,ユ", "よ,ヨ", "は,ハ", "ひ,ヒ", "ふ,フ", "へ,ヘ", "ほ,ホ", "ば,バ", "ば,バ", "ぶ,ブ", "ぶ,ブ", "び,ビ", "び,ビ", "ぼ,ボ", "ぼ,ボ", "べ,ベ", "べ,ベ", "ぱ,パ", "ぴ/ピ", "ぷ,プ", "ぺ,ペ", "ぽ,ポ", "ま,マ", "み,ミ", " む,ム", "め,メ", "も,モ", "を/ヲ", "みゃ,ミャ", "みゅ,ミャ", "みょ,ミョ", "きゃ,キャ", "きゅ,キュ", "きょ,キョ", "にゃ,ニャ", "にゅ,ニュ", "にょ,ニョ", "びゃ,びゃ", "びゅ,ビュ", "びょ,ビョ", "ひゃ,ヒャ", "ひゅ,ヒュ", "ひょ,ヒョ", "ぴゃ,ピャ", "ぴゅ,ピュ", "ぴょ,ピョ", "っ,ッ", "っ,ッ"]; private 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 can replaced in replace mode , substitute kana , values //start list of playerhand contents don't know if null 0 private var playernumber:uint; //total number of players private var allplayershand:array = [[], [], [], [],[], []]; private var playerround:uint = 1; //which player private var round:uint = 1; //round of game private var aplayershand:array; // hand of current player private var mode:uint; private var tileimage:bitmap; private static var idvar:uint; static private var first:boolean = true; private var special:boolean = false; static private var handstatus:vector.<string>; //handstatus types idle: free, ret: ready return stock, set: set on board, rem: ready removed, not public function tile() { addeventlistener(event.added_to_stage, standarddisplay) } private function standarddisplay(e:event=void) : void {trace("project running fine!"); removeeventlistener(event.added_to_stage, standarddisplay); tileimage = new tileclass bitmap; addchild(tileimage); //draws japanese letter on tile var kanafield:textfield = new textfield(); kanafield.width = 40; kanafield.height = 20; kanafield.x = -2; kanafield.y = -5; kanafield.text == ""; trace(kanafield.text); kanafield.wordwrap = true; kanafield.background = true; var kanafieldformat:textformat = new textformat(); kanafieldformat.size = 12; kanafieldformat.font = "arial"; kanafield.settextformat(kanafieldformat); this.addchild(kanafield); kanafield.mouseenabled = false; //draw number on tile valuefield= new textfield(); valuefield.width = 30; valuefield.height = 10; valuefield.x = 0; var valuefieldformat:textformat = new textformat; valuefieldformat.size = 7; valuefield.text = ""; valuefield.y = 15; valuefield.background = false; valuefield.settextformat(valuefieldformat); this.addchild(valuefield); valuefield.mouseenabled = false; //add event listener tile on stage checktype(); } private function checktype():void {if (first != true) { id = idvar; idvar += 1; value = playerhandvalue[id]; stage.addeventlistener(keyboardevent.key_down,keyboardinput); this.addeventlistener(statusbox.statusboxchanged,moderesponse); this.addeventlistener(statusbox.hide, setalpha); issetbox = false } else { special = true; first = false; this.addeventlistener(set.box_set_changed,btr) init();}} private function init():void { trace("starting"); stage.addeventlistener(keyboardevent.key_down, mykeydown); stage.addeventlistener(mouseevent.mouse_up, dnp);} private function dnp(e:mouseevent):void { stage.removeeventlistener(keyboardevent.key_down,mykeydown); stage.removeeventlistener(mouseevent.mouse_up, dnp); trace(playernumber); create(); } private function mykeydown(e2:keyboardevent):void { if (e2.keycode == keyboard.number_1) {playernumber = 1; trace(playernumber);} else if (e2.keycode == keyboard.number_2) {playernumber = 2; trace(playernumber) else if (e2.keycode == keyboard.number_3) {playernumber = 3; trace(playernumber);} else if (e2.keycode == keyboard.number_4) {playernumber = 4; trace(playernumber); } else if (e2.keycode == keyboard.number_5) {playernumber = 5; trace(playernumber);} else if (e2.keycode == keyboard.number_6) {playernumber = 6; } else {playernumber = 1;}} private function create():void { var listlength:uint; var row:uint aplayershand = allplayershand[playerround]; (var i:uint = (aplayershand.length-1); <= 6; i+=1) { listlength = kanalist.length; row = int(math.random() * listlength); trace (row); trace(i); aplayershand[i] = [0, kanalist[row], valuelist[row],] trace (aplayershand); trace (aplayershand[i]); kanalist.splice(row,1); valuelist.splice(row, 1); playerhandkana.push(kanalist[row]); playerhandvalue.push(valuelist[row]);} dispatchevent( new statusbox(statusbox.statusboxchanged, 1)); } private function moderesponse(e:statusbox):void { mode = e.mode; cleanup(); if (special == false) { if (mode == 1) { this.visible = true; this.kanafield.visible = true; this.valuefield.visible = true; this.x = 480; this.y = (480 - (id*32)); kana = playerhandkana[id]; value = playerhandvalue[id]; kanafield.text = kana; valuefield.text = string(value); this.addeventlistener(mouseevent.mouse_down, draglocation); } else if (mode == 4) {if (handstatus[id] == "rem") {handstatus[id] = "idle"; } } } else if (special == true) { if (mode == 8) {stage.addeventlistener(keyboardevent.key_down, keyboardinput); (var i:uint = 0; (handstatus.length - 1); += 1) {if (handstatus[i] == "ret") {kanalist.push(playerhandkana[i]); valuelist.push(playerhandvalue[i]); endgame = true;} } if (endgame == true) { dispatchevent(new statusbox(statusbox.statusboxchanged, 9, false, false));} else {{var cfh:boolean = checkforwordtype(horzword); var cfv:boolean = (checkforwordtype(vertword)); var hl2:uint; if ((handstatus.length > 1 && (cfh == false) && (cfv == false))) {dispatchevent(new statusbox(statusbox.statusboxchanged, 10, false, false));} if (generalx.length == 0) {for (var j:uint = 0; (handstatus.length - 1); += 1) {if (handstatus[i] == "set") {hl2 += 1 } } if (hl2 == 1) {dispatchevent(new statusbox(statusbox.statusboxchanged, 10, false, false)); }} if ((cfh == true) && (cfv == true)) {dispatchevent(new statusbox(statusbox.statusboxchanged, 10, false, false)); } else if (cfh == true) {calctotalscore(valuehor, valuevert);} else if (cfv == true) {calctotalscore(valuevert, valuehor); } } } (var k:uint = 0; k < (handstatus.length - 1); k += 1) { if(handstatus[i] == "idle" || "rem") { var o:uint=0 allplayershand[playernumber][o] = [kana, value]; o += 1; }}} else if (mode == 9) {if (ret == true) { ret = false; (var m:uint = 0; m < (handstatus.length - 1); m += 1) { if(handstatus[i] == "set") { var p:uint=0 allplayershand[playernumber][p] = [kana, value]; p += 1; }} dispatchevent(new statusbox(statusbox.statusboxchanged, 1, false, false));} else { setinplace(); dispatchevent(new statusbox(statusbox.statusboxchanged, 1, true, true)); } } else if (mode == 10) {isset = false; issetbox = false; this.visible = false; create();}}} private function btr(e:set):void {if (e.valueex > 0) { if (e.kanaex == "kanji") {kanafield.type = textfieldtype.input; value += e.valueex; valuefield.text = string(value);} else if (e.kanaex == "k+" ) {value += e.valueex; valuefield.text = string(value);} else if (e.kanaex == "k-") {value-= e.valueex; valuefield.text = string(value);} else if (e.kanaex == "nokanji") {kanafield.type = textfieldtype.dynamic; value = 0; kana = ""; valuefield.text = "";}} else {if (kana == "") { if (e.valueex == 0) {kana =selectghostlist[selectkanalist.indexof(e.kanaex, 0)]; value = selectghostvaluelist[selectkanalist.indexof(kana, 0)]; kanafield.text = kana; valuefield.text = string(value);} else {kana = ""; value = 0; kanafield.text = ""; valuefield.text = "";}}}} private var error:string; private function setalpha(e:statusbox):void { if (issetbox == true) {this.alpha = 0; this.mouseenabled = false; } } static private var scorelist:array = [[]]; private function setinplace():void { if (isset==true) { /*var lob1:sprite = new lob(kana, value); lob1.x = xx; lob1.y = yy; stage.addchild(lob1);*/ removeeventlistener(statusbox.setdown, setinplace); stage.removechild(this);} else {stage.removechild(this);} } static private var turnscore:uint; static private function calctotalscore(main:vector.<uint>,side:vector.<uint>):uint { var tws:uint; var twm:uint; var amws:uint; var asws:uint; (var i:uint = 0; (handstatus.length - 1); += 1) {if (handstatus[i] == "set") { if (side[i] > 0) {asws += (side[i] + (exclusionvalue[i] * lm[i])) * wm[i]; } amws += main[i] + (exclusionvalue[i] * lm[i]) twm += wm[i] generalx.push(exclusionx[i]); generaly.push(exclusiony[i]); generalkana.push(exclusionkana[i]); generalvalue.push(exclusionvalue[i]);}} exclusionx = new vector.<uint> exclusiony = new vector.<uint> exclusionkana = new vector.<string> exclusionvalue= new vector.<uint> tws = (asws + amws) * twm; return tws;} private function checkforwordtype(wordcheck:vector.<boolean>):boolean { (var i:uint = 0; handstatus.length - 1; += 1) { var check:boolean = false; if (handstatus[i] == "set") {if (wordcheck[i] == true) {check = true;}}} return check;} private var endgame:boolean; private var playerhandkana:vector.<string> = new vector.<string>(7); private var playerhandvalue:vector.<uint> = new vector.<uint>(7); private var valuefield:textfield; private function keyboardinput(e:keyboardevent):void { if (mode == 2 || 3 || 4 || 5||8) {if (e.keycode == keyboard.i) { vis = !vis; if ((isset=false)&&(issetbox=false)) {this.visible = vis; this.kanafield.visible = vis; this.valuefield.visible = vis;}}} if (mode == 8) {if (e.keycode == keyboard.r) {ret = !ret; }}} private var kanafield:textfield = new textfield(); static private var generalx:vector.<uint>; static private var generaly:vector.<uint>; static private var generalkana:vector.<string>; static private var generalvalue:vector.<uint>; static private var exclusionx:vector.<uint>; static private var exclusiony:vector.<uint>; static private var exclusionvalue:vector.<uint>; static private var exclusionkana:vector.<string>; private function addexclusion():void {exclusionx[id]=xx; exclusiony[id] = yy; exclusionkana[id] = kana; exclusionvalue[id] = value; } private function removeexclusion():void { exclusionvalue[id] = 0; exclusionkana[id] = "0"; exclusionx[id] = 0; exclusiony[id] = 0; } //the initial event performed when button first clicked; private function draglocation(e:mouseevent):void { removeeventlistener(mouseevent.mouse_down, draglocation); initialx = this.x; initialy = this.y; if (isset==false ||issetbox == false) { stage.addchild(this) this.startdrag(); this.addeventlistener(mouseevent.mouse_up, clickcheck);} } private function clickcheck(e:event):void { if (issetbox==false || isset == false) { this.stopdrag(); removeeventlistener(mouseevent.mouse_up, clickcheck);} finalx = this.x; finaly = this.y; if ((((finaly - initialy) ^ 2 + (finalx - initialx) ^ 2)^0.5) < 5) {handledoubleclick(); } } private function handledoubleclick():void {if (this.x < 480 && this.y < 480) {if (isset == false) {isset = true; this.stopdrag(); xx= int((this.x+16) / 32); this.x = 32*xx; yy= int((this.y+16) / 32); this.y = (32 * yy); (var i:uint = 0; < (exclusionx.length-1); += 1) {if (xx == exclusionx[i] && yy == exclusiony[i]) {notset = true }} if (generalx.length > 0) {var notset:boolean; for (var q:uint = 0; q < (generalx.length - 1); q += 1) {if (xx == generalx[q] && yy == generaly[q]) {notset = true } else {notset=false}}} if (notset == false) {handstatus[id] = "set"; addexclusion(); notset = true; } else {isset = false;}} else { handstatus[id] = "idle"; removeexclusion();}} else if (this.x > 480 && this.y < 480 && this.x < 704) {if (issetbox == false) {setonbox(); } else {takeoffbox(); }} } static private var killsetbox: boolean; static private var wm:vector.<uint>; static private var lm:vector.<uint>; static private var horzword:vector.<boolean>; static private var vertword:vector.<boolean>; static private var idtoreplace:uint; private function rawscore(calcx:int, calcy:int):uint { var xincr:uint = 1; var yincr:uint = 1; var value:uint = 0; while ((number(boardarray[xx + (calcx * xincr)][yy + calcy * yincr])) != 0) { value += (boardarray[xx + (calcx * xincr)][yy + calcy * yincr]); xincr += 1; yincr += 1; } if (value == 0) { (var i:uint = 0; exclusionx.length - 1;i+=1) { if (((exclusionx[i] == exclusionx[id]+calcx) && (exclusiony[i] == exclusiony[id] + calcy))) {if (math.abs(calcx) == 1) { horzword[id] = true;} else {vertword[id] = true; } } } } return value; } static private var valuehor:vector.<uint>; static private var valuevert:vector.<uint>; static private var boardarray:array=new array[[]]; private function checkscore():void { switch(multiplier[exclusionx[id], exclusiony[id]]) {case "tw": wm[id] = 3; lm[id] = 1; break; case "dw": wm[id] = 2; lm[id] = 1; break; case "tl": lm[id] = 3; wm[id] = 1; break; case "dl": lm[id] = 2; wm[id] = 1; break; default: lm[id] = 1; wm[id] = 1;} valuehor[id] = rawscore(1, 0) + rawscore( -1, 0); valuevert[id] = rawscore(0, 1) + rawscore(0, -1); } private function cleanup():void { if (mode == 2 || 3 || 4 || 5) { yplace = 0; if (killsetbox=false) {issetbox = false; handstatus[id] = "idle"; } else {if (issetbox ==true) { this.visible = false; this.kanafield.visible = false; this.valuefield.visible = false; handstatus[id] = "not"; killsetbox = false; } } }} private var first:boolean = true; private function kanachange(e:set):void { if (id==handstatus.indexof(e.kanaex,0)) {kana = e.kanaex; value = e.valueex; kanafield.text = kana; valuefield.text = string(value); playerhandkana[id] = e.kanaex; playerhandvalue[id] = e.valueex;} else { kana = ""; value = 0; handstatus[id] = "not";}} private function setonbox():void {addeventlistener(set.board_set_changed, kanachange); if (mode==3) {issetbox = true; this.x = 480; this.y = 448 - (yplace * 32); handstatus[id] = "ret";} else if (mode == 4) { if (yplace == 0) {dispatchevent(new set(set.box_set_changed, kana, 0)); issetbox = true; this.x = 480; this.y = 448 - (yplace * 32); handstatus[id] = "rem";} } else if (mode == 5) { { issetbox = true; this.x = 480; this.y = 448 - (yplace * 32);} if (yplace == 0) {dispatchevent(new set(set.box_set_changed, "kanji", value)); } else if (yplace > 0) {dispatchevent(new set(set.box_set_changed, "k+", value)); } yplace += 1; }} private function takeoffbox():void { removeeventlistener(set.board_set_changed, kanachange); issetbox = false; if (mode == 3) { handstatus[id] = "idle"; issetbox=false} else if (mode ==4) { if (yplace == 1) {dispatchevent(new set(set.box_set_changed, kana, 1)); issetbox = false; handstatus[id] = "idle" } else if (mode == 5) { if (yplace == 1) {dispatchevent(new set(set.box_set_changed, "nokanji", value)); } else if (yplace > 1) {dispatchevent(new set(set.box_set_changed, "k-", value)); }} handstatus[id] = "idle"; yplace-= 1; }} private function goodx(inx:number):number {if (inx < 0) {return 0;} if (inx > (stage.stagewidth) ) {return (stage.stagewidth); }return inx;} private function goody(iny:number):number { if (iny < 0) {return 0; } if (iny > stage.stageheight) {return stage.stageheight;} return iny; } private function turn1():void {if (playerround > playernumber) {playerround = 1; round += 1; } } }}
your constructor shouldn't have return type.
try:
public function tile(i:uint,kana1:string,value1:uint, type1:uint) { id = i; kana = kana1; value = value1; type = type1; addeventlistener(event.added_to_stage, go); // function called when create new tile object }
also, potential problem in future init method doesn't have parameters throw error if event.added_to_stage
triggers init method.
try:
private function init(e:event = null):void
Comments
Post a Comment