错误#1006:值不是

时间:2012-12-08 05:50:44

标签: flash

我正在尝试为我的一年级课程创建一个简单的单词生成器游戏。我一直收到此错误消息,但不理解generateWord()消息。

  

TypeError:错误#1006:value不是函数。在   COPYMakeAWord_fla :: MainTimeline / generateWord()

这是我正在使用的脚本:

import flash.events.MouseEvent;

wordGenerator.addEventListener(MouseEvent.MOUSE_UP,generateWord);

function generateWord(event:MouseEvent):void
{

    var prefix = new Array("bl","br","c","ch","chr","d","dr","f","fl","fr","g","gl","gr","h","j","k","kl","kr","kn","l","m","n","p","pl","pr","r","s","sn","sk","sr","sl","sh","sp","spr","sw","t","tr","th","thr","tw","v","vr","w","wr","y","z");
    var suffix = new Array("ast","awe","age","ade","abe","ape","apt","ab","ad","aff","ag","ack","an","ane","ame","am","ap","ar","ax","aw","eb","ed","ege","eke","ell","ele","em","eme","en","ene","ent","ept","ere","est","ese","ern","ert","eve","ew","ex","ext","eye","eze","ib","id","iff","ig","ik","ike","ill","im","ime","in","ine","ip","ipe","ir","ire","is","ise","ist","ing","ony","unk","ance","ull","all","ell","oll","ub","ob","ab","un","on","an","uck","it","ass","oss","orn","ard","ord","old","ot","at","ut","arm","it","ite","ive","iwe","iz","ize","ob","obe","od","ode","ioff","og","oge","ook","ood","oon","oof","ool","oom","oon","oop","oot","ooth","oonth","onk","ont","onth","one","ome","op","on","om","ope","or","or","ore","oss","ost","ot","ote","ove","ow","owe","oy","ub","ube","ud","ude","uft","ug","uge","uke","ull","ule","ult","ulp","ump","ulm","un","une","unt","ume","up","upe","upt","ure","us","use","ust","ut","ute","uve");

    var wordStart = prefix[Math.floor(Math.random() * prefix.length)];
    var wordEnd = suffix[Math.floor(Math.random() * prefix.length)];

    newText.text(wordStart+wordEnd);
}

1 个答案:

答案 0 :(得分:1)

假设 newText 是TextField,请尝试以下方法:

 newText.text = wordStart+wordEnd;

错误是有道理的,因为 .text 不是此处的函数,而是属性。