A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: How show Input textfield random on Stage?

  1. #1
    Junior Member
    Join Date
    Apr 2009
    Posts
    22

    How show Input textfield random on Stage?

    Hello,

    I want to make a input textfield and when you write something in it and you click a button it will appear random on stage.

    Somebody that can help me getting started with this function?
    I tried a lot of tutorials but none of them are what I want.

    Regards

    Joep

  2. #2
    Junior Member
    Join Date
    Apr 2009
    Posts
    22
    code:
    package
    {
    import flash.display.*;
    import flash.text.*;
    import flash.events.*;

    public class Opdracht2 extends MovieClip
    {
    private var _button:Sprite = new Sprite();
    private var _tfInput:TextField = new TextField();
    private var _tfOutput:TextField = new TextField();

    public function Opdracht2()
    {
    addChild(_button);
    addChild(_tfInput);
    addChild(_tfOutput);

    _tfInput.type = TextFieldType.INPUT;
    _tfInput.border = true;
    _tfInput.width = 100;
    _tfInput.height = 20;

    _tfOutput.autoSize = "left";
    _tfOutput.visible = false;

    _button.y = _tfInput.height + 5;
    _button.graphics.beginFill(0x0000FF);
    _button.graphics.drawRect(0, 0, 40, 20);
    _button.buttonMode = true;
    _button.addEventListener(MouseEvent.MOUSE_DOWN, showText);
    }

    private function showText(event:Event):void
    {
    _tfOutput.text = _tfInput.text;
    _tfOutput.visible = true;
    _tfOutput.x = Math.random() * (stage.stageWidth - _tfOutput.width)
    _tfOutput.y = Math.random() * (stage.stageHeight - _tfOutput.height)
    }
    }
    }



    This is what I got so far

    Its working but I need to get a higher amount of outputs.
    Not one time but 20 times or something like that

    Anyone?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center