hi, i am trying to deal with some sprites i have created via script. each one can have draings and stuff, but in particular, all have a textfield inside.
something like (not the current code, but to give you an idea)
var _newtext:textfield = new textfield();
_newtext.name = ''textname'';
//
some_array[some_pos] = new sprite();
some_array[some_pos].addchild(_newtext);
(...)
// this gets the sprite in the array as parameter, they all have a textfield called 'textname' (not current name, but same case)
function whatever(some_sprite:sprite, etc):void {
// tried this:
some_sprite.textname.x = x_value; // gives error
// also this
var mytextfield:textfield = (textfield)some_sprite.getChildByName(''textname''); // i dont know if there is casting in as3, but it also gives error.
}
in any case, what i am trying to do is access the properties of the textfiled defined in each sprite. it is not that there is no textfield named whatever inside the sprite, i defined it and i added with addchild when i created it, same for any sprite that gets there. how do i access the textfield inside?
tnx
another one of naming and retrievinguse the getChildByName() method of your parent movieclip:
var yourtextfield:TextField = TextField(some_array[some_pos].getChildByName(''textname));
another one of naming and retrievingit worked!, though i made many naive mistakes on the same function (declaring a variable name the same as a parameter name, i dont know why flash didnt give a warning or error though, using textField instead of TextField (t instead of T),?they are both valid and reserved words, but even if they are the same -now i dont know- they are not parsed as the same), and tried both without casting and with casting, it works with casting only -now i know how to cast in as3-
No comments:
Post a Comment