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 ( 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 );
name_txtinput . type = "input" ;
name_txtinput . border = true ;
name_txtinput . maxChars = 10 ;
name_txtinput . setNewTextFormat (new TextFormat ( "Verdana" , 20 ));
}
Attached Files
.
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.
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
.
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" ); }; }
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!
Client Software Programmer
Selection.setFocus(_root.box.txt);
Originally Posted by
hokayli
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 ( 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 ); 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.
Originally Posted by
Alloy Bacon
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 .
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
Forum Rules
Click Here to Expand Forum to Full Width