0
votes

I wanted to place a textField on a movieClip so i used:

vec[0].addChild(text1);

If I use that there comes an error. Or should i make a new Vector?

TypeError: Error #2007: Parameter child must be non-null. at flash.display::DisplayObjectContainer/addChild() at FQuiz_fla::MainTimeline/frame1()

>

2
i think you can use the name property of the MovieClip, but i don't see where you want to use the instance name with the code you give.Benjamin BOUFFIER
I do not know where or how I should give it an instance name I just want all movieclips (Q1, Q2, Q3, etc) to get an instance name.user3044919
try vec[0].name = 'myInstanceName';Benjamin BOUFFIER
but if you don't know what you want to do with these instance names i don't know why you want to name your instances ...Benjamin BOUFFIER
If you know what you want you can explain it and we could help you in a better way ;)Benjamin BOUFFIER

2 Answers

0
votes
import flash.text.TextField;
var vec:Vector.<MovieClip> = new Vector.<MovieClip>
vec[0] = new Start();
var text1:TextField = new TextField();
text1.text = "ramesh";
vec[0].addChild(text1);
addChild(vec[0]);  //add one of the MovieClips to stage

This should work.

0
votes

Move your text field declaration portion to top, that is before your add child method.

import flash.display.MovieClip; import flash.events.Event; import flash.display.SimpleButton; import flash.text.TextField; import flash.events.MouseEvent;

var volgende:Volgende = new Volgende(); volgende.x = 663; volgende.y = 546; volgende.visible = true; volgende.useHandCursor = true; addChild(volgende);

var vec:Vector. = new Vector.

vec[0] = new Vraag1(); vec[1] = new Vraag2();

var tekstveld1:TextField = new TextField();

tekstveld1.antiAliasType = AntiAliasType.ADVANCED; tekstveld1.text = "" tekstveld1.type = TextFieldType.INPUT; tekstveld1.textColor = 0xEC8DAD; tekstveld1.width = 390; tekstveld1.height = 248; tekstveld1.x = 165; tekstveld1.y = 312; tekstveld1.border = false; tekstveld1.borderColor = 0xDA1C5C; tekstveld1.wordWrap = true; tekstveld1.restrict = "A-Za-z0-9";

vec[1].addChild(tekstveld1);

addChild(vec[0]); //add one of the MovieClips to stage

volgende.addEventListener(MouseEvent.CLICK, onClick);

function onClick(e:MouseEvent):void { for(var i:int = 0; i < vec.length; i++) //go through the Vector one by one { if(contains(vec[i])) //if the Object at position i in the Vector is on stage { removeChild(vec[i]); //remove the Object var next:int = i; //create a temporary holder if(next == vec.length) //check if the displayed Object was the last in the list { next = 1; //if so, set to 0 }else{ next++; //otherwise, only add 1 } addChild(vec[next]); //add the next Object to the stage. If the removed Object was the last in the Vector, it'll add the first Object in the Vector to the list break; //escape the for loop, otherwise it'll always only show the last Object }

} }

Hope it helps. Me too on mobile ;)