checking if textfield is empty with multiline doesn''t work as3 - actionscript-3

this is my code:
stop();
var inputText:String;
var inputText2:String;
var inputText3:String;
var inputText4:String;
var inputText5:String;
var inputText6:String;
var inputText7:String;
var inputText8:String;
go.addEventListener(MouseEvent.CLICK, playBtnClickk);
function playBtnClickk(e:MouseEvent):void {
inputText = inputTXT.text;
inputText2 = inputTXT2.text;
inputText3 = inputTXT3.text;
inputText4 = inputTXT4.text;
inputText5 = inputTXT5.text;
inputText6 = inputTXT6.text;
inputText7 = inputTXT7.text;
inputText8 = inputTXT8.text;
if (
inputText2 !== "",
inputText3 !== "",
inputText4 !== "",
inputText5 !== "",
inputText6 !== "",
inputText7 !== "",
inputText8 !== "")
{ this.setChildIndex(allevelden, this.numChildren - 1); }
else{
gotoAndPlay(2);
}}
I one field isn't filled in, this.setChildIndex(allevelden, this.numChildren - 1); has to shop up, and if everything is filled in it has to go to frame 2.
all the textfields are input textfields and multilines but it doesn't work can someone help me please!!

I might be wrong but I never saw this syntax of separaring the condition on the if statement with a comma, you should separate your condintions with a double pipe for or, also your check is incorrect, try this:
if (
inputText == "" ||
inputText2 == "" ||
inputText3 == "" ||
inputText4 == "" ||
inputText5 == "" ||
inputText6 == "" ||
inputText7 == "" ||
inputText8 == "")
{ this.setChildIndex(allevelden, this.numChildren - 1); }
else{
gotoAndPlay(2);
}}
This reads: If any of your fields is empty then...

Related

PrimeFaces Extension Sheet Restrict Decimal Places For Input

I want to restrict decimal places up to 1. User shouldnt type multiple dots(1..99) and (1.99). I want 1.9 2.6 for ex. Not 2.66 then convert into 2.7 etc. I have to use pe:sheetcolumn. I tried to add p:inputnumber and other p: components than pe extension. But pe:sheetcolumn have to be. With below approach it just let user to type multiple dots and multiple decimal places. It just convert to 1 decimal after user entered value on screen with #0.0. But i want to restrict on input to type multiple decimal places than 1 and multiple dots. I thought about javascript keyup event but i think it would be bad approach. How can i achive that
<pe:sheetcolumn headerText="SOME" value="#{SOME.some}" colWidth="200"
colType="numeric" numericPattern="#0.0" >
</pe:sheetcolumn>
For example for p:inputNumber as you can see on image user cant type multiple dots and they cant add decimal places more than 6.
Example
I want to do same thing with pe:sheetColumn. How can i do that
My JSF VERSION : 2.2.1 PRÄ°MEFACES AND PRIMEFACES EXTENSION VERSION : 6.2
If you install this MonkeyPatch you can then tweak the output to do whatever your want. I am pretty sure you can get the current cell with var currentValue = this.getDataAtCell(row , col) If you add this JS to your app you can then tweak how it handles keypresses and validation.
I added this line for you
var currentValue = this.getDataAtCell(row , col); // VALUE HERE!
So you can validate whatever your want with your code and if there is already a "." don't accept another "." etc.
if (PrimeFaces.widget.ExtSheet) {
PrimeFaces.widget.ExtSheet.prototype.handleHotBeforeKeyDown = function(e) {
var selectedLast = this.getSelectedLast();
if (!selectedLast) {
return;
}
var row = selectedLast[0];
var col = selectedLast[1];
var celltype = this.getCellMeta(row, col).type;
var currentValue = this.getDataAtCell(row , col); // VALUE HERE!
var evt = e || window.event; // IE support
var key = evt.charCode || evt.keyCode || 0;
var shiftDown = e.shiftKey;
// #740 tab on last cell should focus this next component
if (this.allowTabOffSheet && key == 9) {
var lastRow = this.countRows() - 1;
var lastCol = this.countCols() - 1;
if ((!shiftDown && row === lastRow && col === lastCol) ||
(shiftDown && row === 0 && col === 0)) {
e.stopImmediatePropagation();
this.unlisten();
this.deselectCell();
//add all elements we want to include in our selection
var focusableElements = 'a:not([disabled]), button:not([disabled]), input[type=text]:not([disabled]):not([hidden]):not([aria-hidden="true"]), [tabindex]:not([disabled]):not([tabindex="-1"]):not([aria-hidden="true"])';
if (document.activeElement && document.activeElement.form) {
var focusable = Array.prototype.filter.call(document.activeElement.form.querySelectorAll(focusableElements),
function(element) {
//check for visibility while always include the current activeElement
return element.offsetWidth > 0 || element.offsetHeight > 0 || element === document.activeElement
});
var index = focusable.indexOf(document.activeElement);
if (index > -1) {
var nextElement = focusable[index + 1] || focusable[0];
nextElement.focus();
}
}
}
return;
}
// prevent Alpha chars in numeric sheet cells
if (celltype === "numeric") {
// #766 do not block if just CTRL or SHIFT key
if (key === 16 || key === 17) {
return;
}
// #739 allow navigation
var ctrlDown = evt.ctrlKey || evt.metaKey; // Mac support
if (shiftDown || ctrlDown) {
// navigation keys
if (key == 9 || (key >= 35 && key <= 40)) {
return;
}
}
// check for cut and paste
var isClipboard = false;
// Check for Alt+Gr (http://en.wikipedia.org/wiki/AltGr_key)
if (ctrlDown && evt.altKey) isClipboard = false;
// Check for ctrl+c, v and x
else if (ctrlDown && key == 65) isClipboard = true; // a (select all)
else if (ctrlDown && key == 67) isClipboard = true; // c
else if (ctrlDown && key == 86) isClipboard = true; // v
else if (ctrlDown && key == 88) isClipboard = true; // x
// allow backspace, tab, delete, enter, arrows, numbers and keypad numbers
// ONLY home, end, F5, F12, minus (-), period (.)
// console.log('Key: ' + key + ' Shift: ' + e.shiftKey + ' Clipboard: ' + isClipboard);
var isNumeric = ((key == 8) || (key == 9) || (key == 13) ||
(key == 46) || (key == 110) || (key == 116) ||
(key == 123) || (key == 188) || (key == 189) ||
(key == 190) || ((key >= 35) && (key <= 40)) ||
((key >= 48) && (key <= 57)) || ((key >= 96) && (key <= 105)));
if ((!isNumeric && !isClipboard) || shiftDown) {
// prevent alpha characters
e.stopImmediatePropagation();
e.preventDefault();
}
}
}
}

as3 - Changing position checking for in IF statement

I am trying to catch X.Y positions with an IF statement, and IF the coordinates are true I want it to go on to the next set of coordinates. In the code below I attempted my best but I keep getting the "Cannot assign to a non-reference value." Error.
public function onDd(event:TimerEvent):void
{
if (this.rootClass.world.strMapName == "test" && a1.x = a1.x = 327.1 && a1.y = 249.65)
{
a1.x = 360.7;
a1.y = 204.25;
}
else if (a1.x = 410.15 && a1.y = 204.25)
{
a1.x = 360.7;
a1.y = 204.25;
}
}
You have used a wrong comparison operator
If you want to compare two values you must use == or ===
So your code will become:
public function onDd(event:TimerEvent):void {
if (this.rootClass.world.strMapName == "test" && a1.x == 327.1 && a1.y == 249.65) {
a1.x = 360.7;
a1.y = 204.25;
}
else if (a1.x == 410.15 && a1.y == 204.25) {
a1.x = 360.7;
a1.y = 204.25;
}
}

How to hide CTRL+U View source & disable right click and text copy?

Can anyone having solution for hide CTRL+U and right click in Firefox also?
I have finally find solution for the above query. Try the below code in Firefox also it's working..
<script type='text/javascript'>
var isCtrl = false;
document.onkeyup=function(e)
{
if(e.which == 17)
isCtrl=false;
}
document.onkeydown=function(e)
{
if(e.which == 17)
isCtrl=true;
if((e.which == 85) || (e.which == 80) || (e.which == 123) || (e.which == 67) && (isCtrl == true))
{
return false;
}
}
var isNS = (navigator.appName == "Netscape") ? 1 : 0;
if(navigator.appName == "Netscape") document.captureEvents(Event.MOUSEDOWN||Event.MOUSEUP);
function mischandler(){
return false;
}
function mousehandler(e){
var myevent = (isNS) ? e : event;
var eventbutton = (isNS) ? myevent.which : myevent.button;
if((eventbutton==2)||(eventbutton==3)) return false;
}
document.oncontextmenu = mischandler;
document.onmousedown = mousehandler;
document.onmouseup = mousehandler;
</script>
<body oncontextmenu="return false;">

multiline textfield doesn't work with != as3

I wrote some code for some input text fields that need to be filled in before the playhead advances to frame 2.
This is my code:
stop();
var inputText:String;
var inputText2:String;
var inputText3:String;
var inputText4:String;
var inputText5:String;
var inputText6:String;
var inputText7:String;
var inputText8:String;
go.addEventListener(MouseEvent.CLICK, playBtnClickk);
function playBtnClickk(e:MouseEvent):void {
inputText = inputTXT.text;
inputText2 = inputTXT2.text;
inputText3 = inputTXT3.text;
inputText4 = inputTXT4.text;
inputText5 = inputTXT5.text;
inputText6 = inputTXT6.text;
inputText7 = inputTXT7.text;
inputText8 = inputTXT8.text;
if (inputText !== "",
inputText2 !== "",
inputText3 !== "",
inputText4 !== "",
inputText5 !== "",
inputText6 !== "",
inputText7 !== "",
inputText8 !== "")
{ this.setChildIndex(allevelden, this.numChildren - 1); }
else{
gotoAndPlay(2);
}}
But it doesn't work!
If I don't fill in some text this.setChildIndex(allevelden, this.numChildren - 1); - it shows up, but if I fill in all the fields it still shows up and doesn't go to frame 2.
Does someone know how to fix this?

does gmaps support callback option

i want to get the cities list around a place defined with latitude and longitude
here is the simple code i use:
JSON.stringify = JSON.stringify || function (obj) {
var t = typeof (obj);
alert(t);
if (t != "object" || obj === null) {
if (t == "string") obj = '"'+obj+'"';
return String(obj);
} else {
var n, v, json = [], arr = (obj && obj.constructor == Array);
for (n in obj) {
v = obj[n]; t = typeof(v);
if (t == "string") v = '"'+v+'"';
else if (t == "object" && v !== null) v = JSON.stringify(v);
json.push((arr ? "" : '"' + n + '":') + String(v));
}
return (arr ? "[" : "{") + String(json) + (arr ? "]" : "}");
}
}
function insertReply(content) {
var JSONString = JSON.stringify(content);
document.body.innerHTML += JSONString;
alert(JSONString);
}
var script = document.createElement('script');
var url = "http://maps.googleapis.com/maps/api/geocode/json?latlng=40.714224,-73.961452&sensor=false&callback=insertReply";
script.src = (url);
document.body.appendChild(script);
but it seems that google maps doesnt support the callback option (...&callback=insertReply)
is the a solution for that?
thank you in advance..
It's not supported.
Use the gecoding-service of the Maps-Javascript-API instead.