need help to find the write code ..

  • lazer
  • Novice
  • Novice
  • lazer
  • Posts: 16

Post 3+ Months Ago

hi there

i want ur help with a simple thing :

i want to put two text box ( which is type input ) in my flash and i want to let the user write 2 values in the 1st box and 2nd box and the result appear in the 3rd text box . what is the code to do that :oops:
  • digitalMedia
  • a.k.a. dM
  • Genius
  • User avatar
  • Posts: 5148
  • Loc: SC-USA

Post 3+ Months Ago

Code: [ Select ]
btn.onRelease = function() {
    output.text = input1.text+input2.text;
};
  1. btn.onRelease = function() {
  2.     output.text = input1.text+input2.text;
  3. };


You needed help with this? :scratchhead:
  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13504
  • Loc: Florida

Post 3+ Months Ago

Is this meant to be a calc, or do you just need to join strings ? (which dM has pretty much wrapped up :P )
  • lazer
  • Novice
  • Novice
  • lazer
  • Posts: 16

Post 3+ Months Ago

no u misunderstand me the ideas is

to calculate to values EX: 2+2=4 :)

another thing is that when the user puts a value more than 10 it prevents him from enter it or the box becomes 0 .
  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13504
  • Loc: Florida

Post 3+ Months Ago

Ok, you'll have 3 text boxes as you know, set them up like so,

1) type is "input", INSTANCENAME (not variable) is "box1", max chars is "2"
2) type is "input", INSTANCENAME (not variable) is "box2", max chars is "2"
3) type is "dynamic", INSTANCENAME (not variable) is "box3", //edit - forgot dynamic doesn't have max chars *oops

Then you'll have your button, I've used the instancename "calc" here.

On the same timeline as theese textboxes & button you'll have actionscript like so,
Code: [ Select ]
//allow only numbers to be entered
box1.restrict=box2.restrict = "0-9";

//reset to zero if number is > 10
box1.onChanged=box2.onChanged = function(){
    if(parseInt(this.text) > 10){
        this.text = 0;
    }
}

//add values & display in box3 when "calc" button is released
calc.onRelease = function(){
    box3.text = parseInt(box1.text) + parseInt(box2.text);
}
  1. //allow only numbers to be entered
  2. box1.restrict=box2.restrict = "0-9";
  3. //reset to zero if number is > 10
  4. box1.onChanged=box2.onChanged = function(){
  5.     if(parseInt(this.text) > 10){
  6.         this.text = 0;
  7.     }
  8. }
  9. //add values & display in box3 when "calc" button is released
  10. calc.onRelease = function(){
  11.     box3.text = parseInt(box1.text) + parseInt(box2.text);
  12. }
  • lazer
  • Novice
  • Novice
  • lazer
  • Posts: 16

Post 3+ Months Ago

thnax pal u r the best

Post Information

  • Total Posts in this topic: 6 posts
  • Users browsing this forum: No registered users and 7 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.