A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: onRelease text input api button

  1. #1
    Junior Member
    Join Date
    Jul 2013
    Posts
    19

    onRelease text input api button

    Hi what I am trying to do is when I click on this run time button I want it to load an input text field. I don't understand why it is not loading the input text field after onRelease. Also if you know anywhere for further knowledge on this type of thing much appreciated.

    PHP Code:
    this.createEmptyMovieClip("box"1);
    box._x 170;
    box._y 170;
    with (box) {
        
    lineStyle(10x000000);
        
    beginFill(0xFFFFFF);
        
    moveTo(00);
        
    lineTo(2000);
        
    lineTo(20060);
        
    lineTo(060);
        
    lineTo(00);
        
    endFill();
        
    box.createTextField("box"this.getNextHighestDepth(), 102015030);
    box.type "static";
    box.border false;
    box.setNewTextFormat(new TextFormat("Verdana",20));
    box.text "Name: ";


    };
    box.onRollOver = function() {
        
    this._x -= this._width/2;
        
    this._y -= this._height/2;
        
    this._xscale 200;
        
    this._yscale 200;
    };
    box.onRollOut = function() {
        
    this._xscale 100;
        
    this._yscale 100;
        
    this._x += this._width/2;
        
    this._y += this._height/2;
        
        
        

    };


    box.onRelease = function() {

    this.createTextField("name_txtinput"this.getNextHighestDepth(), 105015030);
    name_txtinput.type "input";
    name_txtinput.border true;
    name_txtinput.maxChars 10;
    name_txtinput.setNewTextFormat(new TextFormat("Verdana",20));


    Attached Files Attached Files

  2. #2
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,780
    HI,

    try

    PHP Code:
    this.createEmptyMovieClip("box",1);
    box._x 170;
    box._y 170;
    with (box)
    {
        
    lineStyle(1,0x000000);
        
    beginFill(0xFFFFFF);
        
    moveTo(0,0);
        
    lineTo(200,0);
        
    lineTo(200,60);
        
    lineTo(0,60);
        
    lineTo(0,0);
        
    endFill();

        
    box.createTextField("box",this.getNextHighestDepth(),10,20,150,30);
        
    box.type "static";
        
    box.border false;
        
    box.setNewTextFormat(new TextFormat("Verdana"20));
        
    box.text "Name: ";
    }

    box.onRollOver = function()
    {
        
    this._x -= this._width 2;
        
    this._y -= this._height 2;
        
    this._xscale 200;
        
    this._yscale 200;
    };

    box.onRollOut = function()
    {
        
    this._xscale 100;
        
    this._yscale 100;
        
    this._x += this._width 2;
        
    this._y += this._height 2;
    };

    box.onRelease = function()
    {
        
    _root.createTextField("name_txtinput",this.getNextHighestDepth(),box._x 160,box._y 60,150,30);
        
    name_txtinput.type "input";
        
    name_txtinput.border true;
        
    name_txtinput.maxChars 10;
        
    name_txtinput.setNewTextFormat(new TextFormat("Verdana"20));
    }; 
    although it will not work as you want due to the button losing focus when textfield is created, test it.

  3. #3
    Junior Member
    Join Date
    Jul 2013
    Posts
    19
    Thank you for your help, I removed the onRollOut, onRollOver to quick fix the next problem and some extra stuff here, I now added a another button that shows up with the text field but this new button is not activated as a button for some odd reason. This is the last main problem that I have left for my project. I added a getURL as a quick tester for the button issue.

    PHP Code:
    this.createEmptyMovieClip("box",1);
    box._x 170;
    box._y 170;
    with (box)
    {
        
    lineStyle(1,0x000000);
        
    beginFill(0xFFFFFF);
        
    moveTo(0,0);
        
    lineTo(200,0);
        
    lineTo(200,60);
        
    lineTo(0,60);
        
    lineTo(0,0);
        
    endFill();

        
    box.createTextField("box",this.getNextHighestDepth(),0,15,150,30);
        
    box.type "static";
        
    box.border false;
        
    box.setNewTextFormat(new TextFormat("Verdana"20));
        
    box.text "Name: ";
    }






    box.onRelease = function()
    {
        
    _root.createTextField("name_txtinput",this.getNextHighestDepth(),box._x 0,box._y 80,150,30);
        
    name_txtinput.type "input";
        
    name_txtinput.border true;
        
    name_txtinput.maxChars 10;
        
    name_txtinput.setNewTextFormat(new TextFormat("Verdana"20));




    _root.createEmptyMovieClip("sub",2);
    sub._x 170;
    sub._y 300;
    with (sub)
    {
        
    lineStyle(1,0x000000);
        
    beginFill(0xFFFFFF);
        
    moveTo(0,0);
        
    lineTo(200,0);
        
    lineTo(200,60);
        
    lineTo(0,60);
        
    lineTo(0,0);
        
    endFill();

        
    sub.createTextField("sub",this.getNextHighestDepth(),0,15,150,30);
        
    sub.type "static";
        
    sub.border false;
        
    sub.setNewTextFormat(new TextFormat("Verdana"20));
        
    sub.text "sub: ";
    }
        
    }





    sub.onRelease = function()
    {
     
    getURL("http://www.google.com""_blank");
        

    }; 

    Thanks
    Attached Files Attached Files

  4. #4
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,780
    Hi,

    You are giving the sub button code before it exists.

    try

    PHP Code:
    this.createEmptyMovieClip("box",1);
    box._x 170;
    box._y 170;
    with (box)
    {
        
    lineStyle(1,0x000000);
        
    beginFill(0xFFFFFF);
        
    moveTo(0,0);
        
    lineTo(200,0);
        
    lineTo(200,60);
        
    lineTo(0,60);
        
    lineTo(0,0);
        
    endFill();

        
    box.createTextField("box",this.getNextHighestDepth(),0,15,150,30);
        
    box.type "static";
        
    box.border false;
        
    box.setNewTextFormat(new TextFormat("Verdana"20));
        
    box.text "Name: ";
    }

    box.onRelease = function()
    {
        
    _root.createTextField("name_txtinput",this.getNextHighestDepth(),box._x 0,box._y 80,150,30);
        
    name_txtinput.type "input";
        
    name_txtinput.border true;
        
    name_txtinput.maxChars 10;
        
    name_txtinput.setNewTextFormat(new TextFormat("Verdana"20));

        
    _root.createEmptyMovieClip("sub",2);
        
    sub._x 170;
        
    sub._y 300;
        
    with (sub)
        {
            
    lineStyle(1,0x000000);
            
    beginFill(0xFFFFFF);
            
    moveTo(0,0);
            
    lineTo(200,0);
            
    lineTo(200,60);
            
    lineTo(0,60);
            
    lineTo(0,0);
            
    endFill();

            
    sub.createTextField("sub",this.getNextHighestDepth(),0,15,150,30);
            
    sub.type "static";
            
    sub.border false;
            
    sub.setNewTextFormat(new TextFormat("Verdana"20));
            
    sub.text "sub: ";
        }

        
    activateSub();
    };

    function 
    activateSub()
    {
        
    sub.onRelease = function()
        {
            
    getURL("http://www.google.com""_blank");
        };


  5. #5
    Junior Member
    Join Date
    Jul 2013
    Posts
    19
    Wow thanks! I can now get on with my project, I'll make sure to keep that in mind if i ever run into anything similar, Thanks so much!

  6. #6
    Client Software Programmer AS3.0's Avatar
    Join Date
    Apr 2011
    Posts
    1,404
    Selection.setFocus(_root.box.txt);

  7. #7
    Member
    Join Date
    Sep 2014
    Posts
    75
    Quote Originally Posted by hokayli View Post
    Hi what I am trying to do is when I click on this run time button I want it to load an input text field. I don't understand why it is not loading the input text field after onRelease. Also if you know anywhere for further knowledge on this type of thing much appreciated.

    PHP Code:
    this.createEmptyMovieClip("box"1);
    box._x 170;
    box._y 170;
    with (box) {
        
    lineStyle(10x000000);
        
    beginFill(0xFFFFFF);
        
    moveTo(00);
        
    lineTo(2000);
        
    lineTo(20060);
        
    lineTo(060);
        
    lineTo(00);
        
    endFill();
        
    box.createTextField("box"this.getNextHighestDepth(), 102015030);
    box.type "static";
    box.border false;
    box.setNewTextFormat(new TextFormat("Verdana",20));
    box.text "Name: ";


    };
    box.onRollOver = function() {
        
    this._x -= this._width/2;
        
    this._y -= this._height/2;
        
    this._xscale 200;
        
    this._yscale 200;
    };
    box.onRollOut = function() {
        
    this._xscale 100;
        
    this._yscale 100;
        
    this._x += this._width/2;
        
    this._y += this._height/2;
        
        
        

    };


    box.onRelease = function() {

    this.createTextField("name_txtinput"this.getNextHighestDepth(), 105015030);
    name_txtinput.type "input";
    name_txtinput.border true;
    name_txtinput.maxChars 10;
    name_txtinput.setNewTextFormat(new TextFormat("Verdana",20));



    Hi,

    Just a minor change to your original code and it will work.
    1. In the (onRelease) event; you need to add the keyword (this) before the instance name of the input text field.
    2. You need also to use the (setFocus) keyword as Alloy Bacon stated, above, in his post.

    Quote Originally Posted by Alloy Bacon View Post
    Selection.setFocus(_root.box.txt);
    So your code will be as:

    this.createEmptyMovieClip("box", 1);
    box._x = 170;
    box._y = 170;
    with (box) {
    lineStyle(1, 0x000000);
    beginFill(0xFFFFFF);
    moveTo(0, 0);
    lineTo(200, 0);
    lineTo(200, 60);
    lineTo(0, 60);
    lineTo(0, 0);
    endFill();
    box.createTextField("box", this.getNextHighestDepth(), 10, 20, 150, 30);
    box.type = "static";
    box.border = false;
    box.setNewTextFormat(new TextFormat("Verdana", 20));
    box.text = "Name: ";
    }
    box.onRollOver = function() {
    this._x -= this._width/2;
    this._y -= this._height/2;
    this._xscale = 200;
    this._yscale = 200;
    };
    box.onRollOut = function() {
    this._xscale = 100;
    this._yscale = 100;
    this._x += this._width/2;
    this._y += this._height/2;
    };
    box.onRelease = function() {
    this.createTextField("name_txtinput", this.getNextHighestDepth(), 10, 50, 150, 30);
    this.name_txtinput.type = "input";
    this.name_txtinput.border = true;
    this.name_txtinput.maxChars = 10;
    this.name_txtinput.setNewTextFormat(new TextFormat("Verdana", 20));
    Selection.setFocus(this.name_txtinput);
    };

    Regards!
    Last edited by Dr_flash; 12-21-2015 at 04:41 PM.

  8. #8
    Junior Member
    Join Date
    Jul 2013
    Posts
    19
    This is astonishing! This project will end up being perfect. I really appreciate all the help!
    Thank you all so much!

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