-
[RESOLVED] (NUB) setting dynamic .text and variable scope
Hello all,
First, using flash9 and ASC3.
Complete newbie to flash programming but couldn't find answers in this or the newbie forum. I am an artist but have some limited programming experience. But always seem to get caught up on simple logic issues.
I am trying to set (and keep track of) a dynamic text field in a movie clip. I am adding the movie clip from the main timeline and trying to set its properties as well.
//Main timeline code
//create key
var addkey = new key();
gameclip.addChild(addkey);
addkey.name = (j+"_"+i);
addkey.x = i*tileSize;
addkey.y = j*tileSize;
addkey.blockletter.text = game[j][i];
//this is the problem line. game[j][i] references an array of text letters. i.e "A"
trace(addkey.blockletter.text);
//Movie clip code
function initblock(letter){
blockletter.text = lettter;
blockletter.x = 10;
blockletter.y = 1;
//blockletter is the name of the dynamic text field
}
initblock("A");
So, the problem line in the main code above does not give an error and the trace confirms I am setting *a property correctly. However, it's obvious I'm not setting the dynamic text field in the addkey because it does not change.
I have also tried setting a global variable in the main timeline to hold the value for letter and reference that when I call the initblock function in the movie clip but I can't seem to create or reference global or root variables. -- I know, pretty pathetic.
Any help or logic insights would be greatly appreciated. I hope this post is appropriate for this and not the newbie forum.
-cheers
-
Hello again,
disappointed by the response to this thread.
I have resolved half of my issue. Very simple actually.
In my loop where I add the addkey movie clip with addchild(), I simply created another object a textfield, assign the .text property, and add that onto addkey. Because I named addkey during the loop process I can locate it and its children anytime in the future.
//create key
var addkey = new key();
addkey.name = (j+"_"+i);
//add text
var z = Math.round(Math.random()*25);
var tf = new TextField();
tf.text = ltr[z];
addkey.addChild(tf);
stage.addChild(addkey);
My variable scope question I will post in the newbie forum.
cheers,
Last edited by user8888; 10-23-2007 at 08:24 PM.
Reason: Voice-recognition posted too early
-
Hey 8888, I'm just now making the transition to AS3 myself, and reading the threads more to learn myself then to offer help. But here's what i know in terms of _root. and _global. They have been removed for the most part.
See here for some work arounds..
http://www.test1labs.com/?p=15
Others may have a better answer, I haven't done a search on flashkit yet.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|