Copy link to clipboard
Copied
Greetings, I'm currently trying to code a Keyboard screen display here. The only thing I'm having trouble with is the input's text field which is my own input text I created: this._input._field.text:
class Keyboard extends MovieClip
{
var remote;
var _field;
var _input;
var _a;
var _b;
var _c;
var _d;
var _e;
var _f;
var _g;
var _h;
var _i;
var _j;
var _k;
var _l;
var _m;
var _n;
var _o;
var _p;
var _q;
var _r;
var _s;
var _t;
var _u;
var _v;
var _w;
var __x;
var __y;
var _z;
var _one;
var _two;
var _three;
var _four;
var _five;
var _six;
var _seven;
var _eight;
var _nine;
var _zero;
var _start;
var profileBuildAlert;
static var _instance;
function Keyboard()
{
super();
this.init();
}
function init()
{
this.remote = platform.nintendo.wii.WiiRemote.getInstance(platform.nintendo.wii.WiiRemote.REMOTE_1);
this.profileBuildAlert._visible = false;
this.profileBuildAlert.enabled = false;
this._start._visible = false;
this._start.enabled = false;
this.buildKeyboard();
}
function buildKeyboard()
{
var shim = this;
var buttons = [{button:this._one, label:"1"}, {button:this._two, label:"2"}, {button:this._three, label:"3"}, {button:this._four, label:"4"}, {button:this._five, label:"5"}, {button:this._six, label:"6"}, {button:this._seven, label:"7"}, {button:this._eight, label:"8"}, {button:this._nine, label:"9"}, {button:this._zero, label:"0"}, {button:this._a, label:"A"}, {button:this._b, label:"B"}, {button:this._c, label:"C"}, {button:this._d, label:"D"}, {button:this._e, label:"E"}, {button:this._f, label:"F"}, {button:this._g, label:"G"}, {button:this._h, label:"H"}, {button:this._i, label:"I"}, {button:this._j, label:"J"}, {button:this._k, label:"K"}, {button:this._l, label:"L"}, {button:this._m, label:"M"}, {button:this._n, label:"N"}, {button:this._o, label:"O"}, {button:this._p, label:"P"}, {button:this._q, label:"Q"}, {button:this._r, label:"R"}, {button:this._s, label:"S"}, {button:this._t, label:"T"}, {button:this._u, label:"U"}, {button:this._v, label:"V"}, {button:this._w, label:"W"}, {button:this.__x, label:"X"}, {button:this.__y, label:"Y"}, {button:this._z, label:"Z"}];
for (var i = 0; i < buttons.length; i++)
{
var button = buttons[i].button;
var label = buttons[i].label;
button._field.text = label;
button.onRelease = function()
{
shim.remote.startVibrate(50,200,3);
shim.displayInInput(this._field.text);
};
button.onRollOver = function()
{
shim.remote.startVibrate(50,200,3);
this._field._width = 30.35;
this._field._height = 43.35;
this._field._x = 4.25;
this._field._y = -1.15;
this.icon._width = 45;
this.icon._height = 45;
this.icon._x = -2;
this.icon._y = -2;
};
button.onReleaseOutside = button.onRollOut = function ()
{
shim.remote.startVibrate(50,200,3);
this._field._width = 28;
this._field._height = 40;
this._field._x = 5.75;
this._field._y = 0.75;
this.icon._width = 41.5;
this.icon._height = 41.5;
this.icon._x = 0;
this.icon._y = 0;
};
}
}
function displayInInput(input)
{
this._input._field.text = input;
if (this._input._field.text.length > 0)
{
this._start._visible = true;
this._start.enabled = true;
}
}
}
on the displayInInput text function, if I do: this._input._field.text = input; Clicking on any number or letter button will display only one letter or number in the _input._field.text, but if I do: += input, the _input._field.text won't display anything. What I want fix and the correction here in my code is when users click letters or numbers or both, then they both get displayed in the _input._field.text like this:
for example, if I want to type in: SAMPLE, I would click on the S,A,M,P,L, and E buttons. Finally the _input._field.text says: SAMPLE, not a just single letter or a number in the input.
1 Correct answer
class Keyboard extends MovieClip
{
var remote;
var _field;
var _input;
var _a;
var _b;
var _c;
var _d;
var _e;
var _f;
var _g;
var _h;
var _i;
var _j;
var _k;
var _l;
var _m;
var _n;
var _o;
var _p;
var _q;
var _r;
var _s;
var _t;
var _u;
var _v;
var _w;
var __x;
var __y;
var _z;
var _one;
var _two;
var _three;
var _four;
var _five;
var _six;
var _seven;
var _eight;
var _nine;
var _zero;
var _start;
var profileBuildAlert;
static var _instance;
function
...
Copy link to clipboard
Copied
I already fixed it.
Copy link to clipboard
Copied
post your fix
Copy link to clipboard
Copied
class Keyboard extends MovieClip
{
var remote;
var _field;
var _input;
var _a;
var _b;
var _c;
var _d;
var _e;
var _f;
var _g;
var _h;
var _i;
var _j;
var _k;
var _l;
var _m;
var _n;
var _o;
var _p;
var _q;
var _r;
var _s;
var _t;
var _u;
var _v;
var _w;
var __x;
var __y;
var _z;
var _one;
var _two;
var _three;
var _four;
var _five;
var _six;
var _seven;
var _eight;
var _nine;
var _zero;
var _start;
var profileBuildAlert;
static var _instance;
function Keyboard()
{
super();
this.init();
}
function init()
{
this.remote = platform.nintendo.wii.WiiRemote.getInstance(platform.nintendo.wii.WiiRemote.REMOTE_1);
this.profileBuildAlert._visible = false;
this.profileBuildAlert.enabled = false;
this._start._visible = false;
this._start.enabled = false;
this.buildKeyboard();
}
function buildKeyboard()
{
var shim = this;
var buttons = [{button:this._one, label:"1"}, {button:this._two, label:"2"}, {button:this._three, label:"3"}, {button:this._four, label:"4"}, {button:this._five, label:"5"}, {button:this._six, label:"6"}, {button:this._seven, label:"7"}, {button:this._eight, label:"8"}, {button:this._nine, label:"9"}, {button:this._zero, label:"0"}, {button:this._a, label:"A"}, {button:this._b, label:"B"}, {button:this._c, label:"C"}, {button:this._d, label:"D"}, {button:this._e, label:"E"}, {button:this._f, label:"F"}, {button:this._g, label:"G"}, {button:this._h, label:"H"}, {button:this._i, label:"I"}, {button:this._j, label:"J"}, {button:this._k, label:"K"}, {button:this._l, label:"L"}, {button:this._m, label:"M"}, {button:this._n, label:"N"}, {button:this._o, label:"O"}, {button:this._p, label:"P"}, {button:this._q, label:"Q"}, {button:this._r, label:"R"}, {button:this._s, label:"S"}, {button:this._t, label:"T"}, {button:this._u, label:"U"}, {button:this._v, label:"V"}, {button:this._w, label:"W"}, {button:this.__x, label:"X"}, {button:this.__y, label:"Y"}, {button:this._z, label:"Z"}];
for (var i = 0; i < buttons.length; i++)
{
var button = buttons[i].button;
var label = buttons[i].label;
button._field.text = label;
button.onRelease = function()
{
var clickedChar = this._field.text;
if (shim._input._field == undefined)
{
return undefined;
}
if (shim._input._field.text == undefined)
{
shim._input._field.text = "";
}
shim._input._field.text += clickedChar;
shim._input._field.visible = true;
shim._input._field.autoSize = true;
if (shim._input._field.text.length > 0)
{
shim._start._visible = true;
shim._start.enabled = true;
}
};
button.onRollOver = function()
{
shim.remote.startVibrate(50,200,3);
this._field._width = 30.35;
this._field._height = 43.35;
this._field._x = 4.25;
this._field._y = -1.15;
this.icon._width = 45;
this.icon._height = 45;
this.icon._x = -2;
this.icon._y = -2;
};
button.onReleaseOutside = button.onRollOut = function ()
{
shim.remote.startVibrate(50,200,3);
this._field._width = 28;
this._field._height = 40;
this._field._x = 5.75;
this._field._y = 0.75;
this.icon._width = 41.5;
this.icon._height = 41.5;
this.icon._x = 0;
this.icon._y = 0;
};
}
}
function displayInInput(input)
{
if (this._input._field.text == undefined)
{
this._input._field.text = "";
}
this._input._field.text += input;
if (this._input._field.text.length > 0)
{
this._start._visible = true;
this._start.enabled = true;
}
}
}
All you have to do is to make these are set to true:
autoSize
enabled

