Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

TypeError: Error #2007: Parameter text must be non-null.

Community Beginner ,
Feb 29, 2016 Feb 29, 2016

i have this error and i don't know how to solve it

TypeError: Error #2007: Parameter text must be non-null.

  at flash.text::TextField/set text()

  at glossary_fla::MainTimeline/createbtn()

  at glossary_fla::MainTimeline/letterclick()

this is function createbtn

function createbtn(label:String):MovieClip

{

  var txt:TextField = new TextField();

  txt.defaultTextFormat = new TextFormat('Cooper Black',25,0xFFFFFF);

  txt.text = label;

  txt.autoSize = TextFieldAutoSize.LEFT;

  txt.background = txt.border = false;

  txt.selectable = false;

  var btn:MovieClip = new MovieClip();

  btn.mouseChildren = false;

  btn.buttonMode = true;

  btn.addChild(txt);

  btn.label = label;

  return btn;

}

and this function is letterclick

function letterclick(e:MouseEvent)

{

  myxmllist = new XMLList(myxml.word.(@clas==e.target.name).@wordname);

  for each (var word:XML in myxmllist)

  {

  btn = createbtn(myxmllist);

  btn.x = 600;

  btn.y = 130 + n;

  addChild(btn);

  n +=  50;

  btn.addEventListener(MouseEvent.CLICK,wordclick);

  i++;

  Tweener.addTween(btn, {x:100, scaleX:1, scaleY: 1, time: 2, transition:"easeOut"});

  }

}

could you help me please

TOPICS
ActionScript
1.1K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 29, 2016 Feb 29, 2016

The error is telling you that a parameter's value is null. It's pointing to the function letterclick(). I'm guessing that the problem lies in the xml file that you are using in this function. I have no way of knowing the actual problem. It could be that the xml reference has a typo, or the xml file contains no data, or that the way that you are parsing the xml has a problem, or...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Feb 29, 2016 Feb 29, 2016

i want to tell you that on stage i have button from a to z when i click any button for the first time every thing running by the right way but when i click the same button or other one this problem happen so the problem is not lies in the xml file . but by trace i know that the error happen from this statement  
btn = createbtn(myxmllist);
so think i should be delete or remove the last object of btn to can create a new one .. when i used removeChild(btn) output show from the first time

TypeError: Error #2007: Parameter child must be non-null.

  at flash.display::DisplayObjectContainer/removeChild()

  at glossary_fla::MainTimeline/letterclick()

i don't know what can i do , ...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 29, 2016 Feb 29, 2016

If the problem is with that line, then trace for the value of myxmllist and see what you get.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Feb 29, 2016 Feb 29, 2016

yes   the error is as you say
but i don't know how to solve it
this is my fla https://goo.gl/qZXG8S
if you want it

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 01, 2016 Mar 01, 2016

Your function letterClick is trying to create a list of items from the xml list. In fact there is only one item, the letter that was clicked on. So, you only need to work with that one letter. I changed the first part of the function to look like this:

myxmllist = new XMLList(myxml.word.(@clas==e.target.name).@wordname);

  btn = createbtn(myxmllist);

  btn.x = 600;

  btn.y = 130 + n;

  addChild(btn);

  n +=  50;

  btn.addEventListener(MouseEvent.CLICK,wordclick);

  Tweener.addTween(btn, {x:100, scaleX:1, scaleY: 1, time: 2, transition:"easeOut"});

and this throws up the word and then the definition onto the stage. I have no idea if this is the correct effect that you have in mind but there are no errors.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 01, 2016 Mar 01, 2016

really thank you about your trying to help me .. by searching and trace i know that i must use "i" to show all words in xml for the letter and when i click again on any other button "i" must be return to 0 .. another thing that i must remove the children of btn to prevent adding button above other but i dont know how to count the number of btn on stage
again thank you very much

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 01, 2016 Mar 01, 2016
LATEST

1. To fix the word count "i" problem just add:

     var i:int = 0;

as the first line in the letterclick function. This will reset the value of i every time the function is called.

Remove the definition of i at the top of the code, and define it inside the function where you are using it.

2. If I'm reading correctly, you want to remove the existing words and their definitions from the stage when a new letter is clicked on. So, you'll need to create two variables, one an array to hold the word objects that are written to the stage and a second variable to hold the definition object that you add to the stage. Then, when a letter is clicked on, you need to look in the array and removeChild() each of the word objects and then remove the definition object from the stage.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines