**Scene 16, Layer 'js', Frame 16, Line 2, Column 151086: Syntax error: expecting semicolon before leftparen. ** - actionscript

**I have no idea what should I do for this error since I'm am really noob at codding
{
var MovieClip(this.root)
var pieces = root.pieces;
var slots = root.slots;
var restart = root.restart;
var winMessage = root.winMessage;
var positions = [];
};
root.setup = function()
{
document.body.style.backgroundColor = lib.properties.color;
createjs.Touch.enable(stage);
stage.mouseMoveOutside = true;
root.drawStart = stage.on("drawstart", root.start, null, true);
};
enter image description here

Related

i am new in action script. trying to split a sentence into words and show them in sprite.and also need which sprite i clicked

I am trying to split a sentence in to words and show them into sprite()
var sentence:String = "My name is Subhadip.";
var txt:Array = new Array();
var splittedSentence:Array = sentence.split(" ");
var myArraySprites:Array = new Array();
var myTextImage:Array = new Array();
var div = 40;
for (var i:int = 0; i < splittedSentence.length; i++)
{
var v = 300 - (div * i);
//...
txt[i] = new TextField();
txt[i].autoSize = TextFieldAutoSize.CENTER;
txt[i].text = splittedSentence[i];
var format1:TextFormat = new TextFormat();
format1.size = 24;
txt[i].setTextFormat(format1);
trace(txt[i]);
myArraySprites[i] = new Sprite();
myArraySprites[i].graphics.lineStyle(1, 0x000000, 1);
myArraySprites[i].buttonMode = true;
myArraySprites[i].graphics.beginFill( 0xfffffff );
myArraySprites[i].graphics.drawRect(50, v, 150, div);
myTextImage[i] = new BitmapData(100,v,true,0xffffff);
myTextImage[i].draw(txt[i]);
trace(myTextImage[i]);
//myArraySprites[i].graphics.beginBitmapFill(myTextImage[i]);
//myArraySprites[i].graphics.endFill();
myArraySprites[i].addChild(new Bitmap(myTextImage[i]));
addChild(myArraySprites[i]);
myArraySprites[i].addEventListener(MouseEvent.CLICK, removeThis);
}
function removeThis(e:MouseEvent):void
{
var clickTarget:int = myArraySprites.indexOf(e.currentTarget);
trace("Clicked sprite (id): " + clickTarget);
}
[enter image description here][1]
trying to split a sentence into words and show them in sprite.and also need which sprite i clicked
[1]: https://i.stack.imgur.com/RzHUQ.png
The problem is that you're dealing with screen positions in two different places:
myArraySprites[i].graphics.drawRect(50, v, 150, div);
and
myTextImage[i] = new BitmapData(100,v,true,0xffffff);
Think of it in a more object-oriented way. Each Sprite instance you want to be clickable is a single object. As such it also holds the main properties e.g. the on-screen position determined by it's x and y properties.
Each of those sprites have equal width & height, so make this a global property.
var wid:Number = 150;
var hei:Number = 40;
If we look at your .png, we can see that you want to have a single word centered inside such a sprite. To make things easier, we can use the .align property of the TextFormat class, set it to "center" and make each TextField 150 x 40 by using the wid and hei properties.
Finally each sprite's vertical screen position is shifted up by hei == 40 pixels. So let's determine a start position:
var yPos:Number = 300;
assign it to a sprite instance:
myArraySprites[i].x=50;
myArraySprites[i].y=yPos;
and decrement it by hei inside the for-loop.
Everything put together:
var yPos:Number = 300;
var wid:Number = 150;
var hei:Number = 40;
var sentence:String = "My name is Subhadip.";
var txt:TextField = new TextField();
txt.width = wid;
txt.height = hei;
var format1:TextFormat = new TextFormat();
format1.size = 24;
format1.align = "center";
var splittedSentence:Array = sentence.split(" ");
var myTextImage:Array = new Array();
for (var i:int = 0; i<splittedSentence.length; i++)
{
txt.text = splittedSentence[i];
txt.setTextFormat(format1);
myArraySprites[i] = new Sprite();
myArraySprites[i].x = 50;
myArraySprites[i].y = yPos;
myArraySprites[i].graphics.lineStyle(1, 0x000000, 1);
myArraySprites[i].buttonMode = true;
myArraySprites[i].graphics.beginFill(0xfffffff);
myArraySprites[i].graphics.drawRect(0, 0, wid, hei);
myTextImage[i] = new BitmapData(wid, hei, true, 0xffffff);
myTextImage[i].draw(txt);
myArraySprites[i].addChild(new Bitmap(myTextImage[i]));
addChild(myArraySprites[i]);
myArraySprites[i].addEventListener(MouseEvent.CLICK, removeThis);
yPos -= hei;
}

SyntaxError: Unexpected token - Google Sheets Script Editor

I want to create a master tab that takes data from other tabs. Once the data is in the master tab I want to be able to filter the information.
I've done this previously using the code that I am having issues with. I learned how to do this here: https://www.youtube.com/watch?v=rpITkG40rQs
Also the previous project I used this code for still works.
The code I am having trouble with is below. I'm getting the following error now:
Exception: The starting column of the range is too small.
getColumnValue # Copy 2 of Code.gs:59
getCombinedColumnValues # Copy 2 of Code.gs:39
(anonymous) # Copy 2 of Code.gs:16
combineData # Copy 2 of Code.gs:15
previously i got this error:
Syntax error: SyntaxError: Unexpected token ')' line: 14 file: Copy of Code.gs
line 14 is under the "labels" var and above the loop starting with lables.foreach...
function combineData() {
var masterSheet = "Master";
var ss = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(masterSheet);
var lc = ss.getLastColumn();
var lr = ss.getLastRow();
ss.getRange(2, 1, lr-1, lc).clearContent();
ss.getRange(1, 49, lr-1, lc).clearContent();
var labels = ss.getRange(1, 1, 1, lc).getValues()[0];
labels.forEach(function(label,i){
var colValues = getCombinedColumnValues(label);
ss.getRange(2, i+1, colValues.length, 1).setValues(colValues);
Logger.log(colValues);
});
}
/// note to self - the problem I was having with the document below was the 'if' statement. The tutorial only has one exclusion. I have several tables to include and exclude.
function getCombinedColumnValues(label) {
var sheets = SpreadsheetApp.getActiveSpreadsheet().getSheets()
var colValues = [];
for(k in sheets){
var sheetName = sheets[k].getSheetName();
// grabs the tabs I want.
if ((sheetName == "CBDIO Data")||(sheetName == "CCA Data")||(sheetName == "CHW Data")||(sheetName == "Mujeres en Accion Data")||(sheetName == "Padres Unidos Data")||(sheetName == "CBDIO - Form")){
var tempValue = getColumnValue(label, sheetName)
colValues = colValues.concat(tempValue);
}
};
return colValues;
}
function getColumnValue(label, sheetName) {
var ss = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(sheetName);
var colIndex = getColumnIndex(label, sheetName);
var numRow = ss.getLastRow() - 1;
var colValues = ss.getRange(2, colIndex, numRow, 1).getValues();
return colValues;
}
function getColumnIndex(label, sheetName) {
var ss = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(sheetName);
var lc = ss.getLastColumn();
var lookupRangeValues = ss.getRange(1, 1, 1, lc).getValues()[0];
var index = lookupRangeValues.indexOf(label) + 1;
return index;
}
'''

Building Multiple Tooltips From Db

I am converting my present map scripts from Google to Leaflet. I have a map with 5 layers, each with multiple locations that are stored in a Db table. I have two routines in the process. The first gathers the data from the Db and builds an XML file that is passed to the second. The second then parses the XML file and build individual L.marker content as follows:
for (var i = 0; i < numMarkers; i++) {
var mkrType = markers[i].getAttribute("type");
var mkrName = markers[i].getAttribute("name");
var mkrLat = markers[i].getAttribute("lat");
var mkrLon = markers[i].getAttribute("lon");
var mkrIcon = "files_images/mis_images/icon_tri_green.png"; break;
var mkrText = "<b>" + mkrName + "</b><br>Lat: " + mkrLat + " Lon: " + mkrLon;
L.marker([mkrLat, mkrLon], {icon: mkrIcon}).bindPopup(mkrText).addTo(cemeteries);
}
The script produces (Uncaught TypeError: t.addLayer is not a function) on the last line of the for loop (L.marker).
I figure the fault is that the loop/L.marker is within a function. If so, what and how do I pass what is need to make the code work.
TIA for any assistance
jdadwilson
My bad... Cemeteries was defined, I did not provide all of the function. Here it is...
function init_all_map(lyrActive) { 'use strict';
var cemeteries = L.layerGroup(),
churches = L.layerGroup(),
markers = L.layerGroup(),
schools = L.layerGroup(),
towns = L.layerGroup();
var overlays = { "Cemeteries": cemeteries, "Churches": churches, "Markers": markers, "Schools": schools, "Towns": towns };
var mbAttr = 'Map data © OpenStreetMap contributors, ' +
'CC-BY-SA, ' + 'Imagery © Mapbox',
mbUrl = 'https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}?access_token=pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejY4NXVycTA2emYycXBndHRqcmZ3N3gifQ.rJcFIG214AriISLbB6B5aw',
msGeo = window.SERVER_PATH + 'files_geojson/geopoly_holmes.json';
var streets = L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png'),
county = new L.GeoJSON.AJAX(window.SERVER_PATH + "files_geojson/geopoly_holmes.json", {style: {color: "DarkGray", weight: 2, fillColor: ""}} );
var baseLayers = {"Streets": streets, "County": county};
var map = L.map('map_canvas_lg', {center: [CO_CENTER_LAT, CO_CENTER_LON], zoomControl: true, zoom: 10, minZoom: 8, maxZoom: 14,
layers: [streets, county, cemeteries, churches, markers, schools, towns]});
var lyrName = ["cemeteries", "churches", "markers", "schools", "towns"];
var lyrType = ["cem", "chu", "mkr", "sch", "twn"];
var numLays = lyrType.length;
var xmlType,
thisLayer,
newIcon;
for ( i=0; i<numLays; i++ ) {
//console.log("Layer: " + lyrType[i]);
thisLayer = lyrName[i];
console.log("thisLayer: " + thisLayer);
switch(lyrType[i]) {
case "cem":
xmlType = window.SERVER_PATH + "files_xml/xml_cemeteries.php";
newIcon = window.SERVER_PATH + "files_images/mis_images/icon_tri_green.png";
break;
//
// Other cases removed for brevity
//
} // End of switch
var mkrIcon = L.icon({ iconUrl: newIcon,shadowUrl: '',iconSize: [13,13],shadowSize: [0,0],iconAnchor: [7,13],shadowAnchor: [0,0],popupAnchor: [0,0]});
var xmlData = downloadUrl(xmlType, function(data) {
var xml = xmlParse(data);
var markers = xml.getElementsByTagName("marker");
var numMarkers = markers.length;
for (var j = 0; j < numMarkers; j++) {
var mkrType = markers[j].getAttribute("type");
var mkrName = markers[j].getAttribute("name");
var mkrLat = markers[j].getAttribute("lat");
var mkrLon = markers[j].getAttribute("lon");
var mkrText = "<b>" + mkrName + "</b><br>Lat: " + mkrLat + " Lon: " + mkrLon;
L.marker([mkrLat, mkrLon], {icon: mkrIcon}).bindPopup(mkrText).addTo(**lyrName[i]**);
} // End of Marker (j) loop
}); // End of downloadUrl
lyrName[i] = L.layerGroup().addTo(map);
} // End of layer (i) loop
L.control.layers(overlays).addTo(map);
window.dispatchEvent(new Event('resize'));
}
This line...
L.marker([mkrLat, mkrLon], {icon: mkrIcon}).bindPopup(mkrText).addTo(**lyrName[i]**);
throws the following error...
TypeError: Cannot read property 'addLayer' of undefined
If I change lyrName[i] to cemeteries the layer fills as desired.
Again TIA for any assistance.
jdadwilson
Your Layer cemeteries is not defined.
You can create a LayerGroup / FeatureGroup (is the same but with more function) with var cemeteries= L.featureGroup().addTo(map). Add this Line before your loop.
And then your code should work and the markers displayed on the map
Update
You are adding the marker to a string and not to the layer object. (I don't know what **lyrName[i]** are make, but it is not working...)
Try:
var lyrName = ["cemeteries", "churches", "markers", "schools", "towns"];
var lyrObjs = [cemeteries, churches, markers, schools, towns];
var lyrType = ["cem", "chu", "mkr", "sch", "twn"];
//...
L.marker([mkrLat, mkrLon], {icon: mkrIcon}).bindPopup(mkrText).addTo(lyrObjs[i]);

Binding row value to odata model SAP UI5

I have a table with 2 columns - one where user can input a value to return and other column is a checkbox. If a user enters a value in the item row, I make the checkbox checked. If value is greater than 0 then only the checkbox is selected. My issue is with the below code, if I input a value on the 3 rd row, that checkbox is selected but alongside even the first row's checkbox is selected. I think the issue is in the stmt: tableModel.setProperty("/ItemSet/results/0/ReturnItemFlag", "X"); Because I am giving "0" the first row is also getting the value. How to I point to the correct result number.
Controller.js
qtyChange: function(oEvent) {
var a = oEvent.getSource();
var input = a.getValue()
var row = oEvent.getSource().getParent().getParent();
var index = row.getIndex();
var oTable = vc.getView().byId("takeStockHistoryDetailTable");
var selectedRowPath = oTable.getContextByIndex(index).getPath();
var tableModel = vc.getView().getModel(TAKE_STOCK_ORDER_DETAIL);
var selectedPart = tableModel.getObject(selectedRowPath);
var QtyOnHand = selectedPart.QtyOnHand;
var UnitP = selectedPart.UnitPrice;
var f = parseInt(input);
var g = parseInt(QtyOnHand);
var h = parseFloat(UnitP);
if (f > g) {
sap.m.MessageToast.show("Return quantity is more than available quantity");
a.setValue("");
} else if (f === 0 || input === "") {
selectedPart.ReturnItemFlag = 'Y';
tableModel.setProperty("/ItemSet/results/0/ReturnItemFlag", "Y");
} else {
selectedPart.ReturnItemFlag = 'X';
selectedPart.QtyToReturn = input;
var sub = input * h;
// debugger;
var sub1 = sub.toString();
selectedPart.Subtotal = sub1;
tableModel.setProperty("/ItemSet/results/0/ReturnItemFlag", "X");
tableModel.setProperty("/ItemSet/results/0/Subtotal", sub1);
}
},
This is possibly a very complicated way of working with table items.
Here is how you should work with bindingContexts.
on listItemPress Event of the table(list)
qtyChange: function(oEvent){
var oColumnListItem = oEvent.getSource().getParent();
var sPath = oColumnListItem.getBindingContextPath("yourModelName");
OR
var sPath = oColumnListItem.getBindingContext("yourModelName").getPath();
var sReturnItemFlagPath = sPath + "/ReturnItemFlag";
tableModel.setProperty(sReturnItemFlagPath,"newValue");
}
Let me know if this helps!

Printing in Openlayers 3 (pdf)

I have made a printing tools for openlayers 3 which prints in PDF format. Here is my code to print in pdf.
var dims = {
a0: [1189, 841],
a1: [841, 594],
a2: [594, 420],
a3: [420, 297],
a4: [297, 210],
a5: [210, 148]
};
var exportElement = document.getElementById('export-pdf');
exportElement.addEventListener('click', function(e) {
if (exportElement.className.indexOf('disabled') > -1) {
return;
}
exportElement.className += ' disabled';
var format = document.getElementById('format').value;
var resolution = document.getElementById('resolution').value;
var buttonLabelElement = document.getElementById('button-label');
var label = buttonLabelElement.innerText;
var dim = dims[format];
var width = Math.round(dim[0] * resolution / 25.4);
var height = Math.round(dim[1] * resolution / 25.4);
var size = /** #type {ol.Size} */ (map.getSize());
var extent = map.getView().calculateExtent(size);
map.once('postcompose', function(event) {
//var tileQueue = map.getTileQueue();
// To prevent potential unexpected division-by-zero
// behaviour, tileTotalCount must be larger than 0.
//var tileTotalCount = tileQueue.getCount() || 1;
var interval;
interval = setInterval(function() {
//var tileCount = tileQueue.getCount();
//var ratio = 1 - tileCount / tileTotalCount;
//buttonLabelElement.innerText = ' ' + (100 * ratio).toFixed(1) + '%';
//if (ratio == 1 && !tileQueue.getTilesLoading()) {
clearInterval(interval);
buttonLabelElement.innerText = label;
var canvas = event.context.canvas;
var data = canvas.toDataURL('image/jpeg');
var pdf = new jsPDF('landscape', undefined, format);
pdf.addImage(data, 'JPEG', 0, 0, dim[0], dim[1]);
pdf.save('map.pdf');
map.setSize(size);
map.getView().fitExtent(extent, size);
map.renderSync();
exportElement.className =
exportElement.className.replace(' disabled', '');
// }
}, 100);
});
map.setSize([width, height]);
map.getView().fitExtent(extent, /** #type {ol.Size} */ (map.getSize()));
map.renderSync();
}, false);
I can print in PDF when I have only OSM Layer but when I add local layers from my geoserver I can't print anything and the whole application is freezed.
Can anyone tell me what am I doing wrong here?
I am using jspdf to print pdf.
AJ
Your problem is that you load imagery from other domains, and haven't configured them for CORS. See https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image for a description on cross origin image use.
In order to get data out of the canvas, all images put into it must be from the same domain or transmitted with the appropriate Access-Control-Allow-Origin header.
I would investigate how to set up your server to serve the map imagery with those headers. You should also take a look at the crossOrigin option on your ol3 sources.
There is few solutions for CORS.
Very simple solution is to proxy OSM requests through your backend server (user <-> backend <-> OSM), but then we have little more server load.

Resources