Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 05-21-2012, 06:16 AM   #1
actoinscript_noob
*action
 
Join Date: May 2012
Posts: 2
Default Dynamic Text Box Help

Hi,

As my username suggests i am a total actionscript noob and while im sure i could find answers to my questions somewhere on google it would be better to get involved in a forum.


I have a selection of numbers on screen in normal text boxes, when one is clicked i need the number in that text box to appear in an empty dynamic text box but i have no idea how to do that. Any help would be awesome.
actoinscript_noob is offline   Reply With Quote
Old 05-21-2012, 06:38 AM   #2
Sonny
Senior Member
 
Join Date: Aug 2010
Location: Sydney,Australia
Posts: 132
Default

There you go
Quote:
import flash.display.MovieClip;
import flash.text.TextField;
import flash.events.Event;
import flash.geom.Rectangle;

var TEXT_WIDTH :Number = 30;
var TEXT_COUNT :Number = 3;

//The clicked text fields text coems here
var target:TextField = new TextField();
target.name = "target";
target.text = "target";
target.x = (TEXT_COUNT+1)*TEXT_WIDTH;
stage.addChild(target);

//create text fields
for(var i=0; i<TEXT_COUNT ; i ++){
var tf:TextField = new TextField();
tf.name = "txtFld"+i;
tf.text = i;
tf.x = i * 30 + 10;
tf.addEventListener(MouseEvent.CLICK,handleTextCli ck,false,0,true);
tf.width = TEXT_WIDTH;
stage.addChild(tf);
}

//if say 3 text fields tf1 , tf2 , tf3 exist on stage just reference it by name instead of creating dynamically :P



//click click click away
function handleTextClick(e:MouseEvent){

target.text = (e.target as TextField).text;
}
Sonny is offline   Reply With Quote
Old 05-21-2012, 06:51 AM   #3
actoinscript_noob
*action
 
Join Date: May 2012
Posts: 2
Default

Why is it that complicated?

Can't you just make a function that says when one text box is clicked, make the other text in the dynamic text box the same.
actoinscript_noob is offline   Reply With Quote
Old 05-21-2012, 07:15 AM   #4
Sonny
Senior Member
 
Join Date: Aug 2010
Location: Sydney,Australia
Posts: 132
Default

Like i said if you have the textfields on the stage already and not dynamically adding it use something like

Quote:
tf1.addEventListener(MouseEvent.CLICK,handleTextCl ick,false,0,true);
tf2.addEventListener(MouseEvent.CLICK,handleTextCl ick,false,0,true);
tf3.addEventListener(MouseEvent.CLICK,handleTextCl ick,false,0,true);
//click click click away
function handleTextClick(e:MouseEvent){

target.text = (e.target as TextField).text;
}
That should work
Sonny is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 05:02 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.