if you can color the letter also using text field no proplem to use text
create a movieclip that contains a textfield. right align the text if you're going to use right-to-left language like arabic, left align the text for left-to-right languages. assign the textfield an instance name, eg tf. assign the movieclip a linkage id, eg tf_mc.
your can then use:
// [word or phrase to be display, character index where bin should be placed for a correct answer]var wordA = [["first word",2],["second word",5]];
var index,i,mc;
// add your drag and drop listeners. bind(this) to all function calls.
// sample drop listener function dropF() is below.
step1F.bind(this)();
function step1F(){
if(!index){
index = 0;
} else {
index++;
}
if(wordA.length==index){
endF();
} else {
step2F.bind(this)();
}
}
function step2F(){
var startX = 0;
for(i=0;i<wordA[index][0].length;i++){
mc = new lib.tf_mc();
mc.name= "mc_"+i
mc.tf.text = wordA[index][0].charAt(i);
if(i==wordA[index][1]){
mc.tf.color = "#00ff00";
mc.name = "selected_"+i;
} else {
mc.tf.color = "#000000";
mc.name= "mc_"+i
}
mc.x = startX;
// below for right-to-left
startX -= mc.getBounds().width;
// below for left-to-right
// startX += mc.getBounds().width;
this.p.addChild(mc);
}
}
function dropF(){
for(i=0;i<wordA[index][0].length;i++){
if(this.bin.hitTest(this.p.getChildAt(i))){
if(this.p.getChildAt(i).name.indexOf("selected")>-1){
correctF.bind(this)();
} else {
incorrectF.bind(this)();
}
}
}
}
function correctF(){
// do whatever. when ready for next word/phrase execute cleanF.bind(this)()
}
function incorrectF(){
// do whatever else. when ready for next word/phrase execute cleanF.bind(this)()
}
function cleanF(){
for(i=this.p.numChildren;i>=0;i--){
this.p.removeChildAt(i);
}
step1F.bind(this)()
}
function endF(){
// game over
}