Adding Sprites and scrolling them
Hi all,
I just started learning AS3 :) I was just trying out something.To read values from xml and make a drop down menu. I reached only this far
Actionscript Code:
import flash.display.Sprite;
import flash.text.TextField;
import flash.events.MouseEvent;
var i:Number = 0;
var sp:Sprite = new Sprite();
var sptxt:TextField = new TextField();
stage.addEventListener(MouseEvent.MOUSE_DOWN,addMore);
function addMore(e:MouseEvent):void {
sp.name = "sp"+i;
sptxt.name = "sptxt"+i;
this.y+=10;
//sptxt.addEventListener(MouseEvent.CLICK,EditMe);
sptxt.text="this is the "+i+"th text";
addChild(sp);
sp.addChild(sptxt);
trace("sp="+sp.name);
trace("sptxt="+sptxt.name);
trace("i="+i);
i++;
}
/*
function EditMe():void {
sp.sptxt.type=TextFieldType.input();
}
*/
What I did is that,When you click on the stage It will add a new spirte, sp with name sp0,sp1 ... and adds sptxt0,sptxt1... inside sp0,sp1... respectively.I put so that each sp will come along down like a drop down.
And is a function to make the text field in sp editable.Like if i click sp0,its text,ie sp0.sptxt0 must become editable.But its not working,am getting error as Access to undefined property :(
Another problem is that am getting output as "this is 0th text" then when i click again,it erases all things and adds "this is 1th text" at y+=0.Its not showing "this is 0th text" above that line. :( ...
Please help.
Btw One more thing.I think I know how to read XML values into those sptxt0,sptxt1 etc,but how can i make them scroll? Using the Scroll() on sp? or another container is needed?