AS3 AIR - black screen when packaged - actionscript-3

When I run the application from Flash Develop everything is fine, both in Debug and Release.
After the application is packaged and installed, I just get a black screen when run.
However if I add a 'debug' file to applicationDirecty\META-INF\AIR\debug the application runs normally.
What could be causing this? and how can it be solved?

A debugging utility seemed to be causing the problem in the release build... removing calls to this solved the issue.
/** Gets the name of the function which is calling */
public function Log(prefix:String = "", suffix:String = "", params:* = null):void
{
var error:Error = new Error();
var stackTrace:String = error.getStackTrace(); // entire stack trace
var startIndex:int = stackTrace.indexOf("at ", stackTrace.indexOf("at ") + 1); //start of second line
var endIndex:int = stackTrace.indexOf("()", startIndex); // end of function name
var lastLine:String = stackTrace.substring(startIndex + 3, endIndex);
var functionSeperatorIndex:int = lastLine.indexOf('/');
var ClassSeperatorIndex:int = lastLine.indexOf(':');
var objectName:String = lastLine.substring(ClassSeperatorIndex+2, functionSeperatorIndex);
var functionName:String = lastLine.substring(functionSeperatorIndex + 1, lastLine.length);
trace(prefix +" " + "[" + objectName + "]" + " > " + functionName + " " + suffix);
}

Open Run.bat and replace
set OPTIONS=-connect %DEBUG_IP%
with
set DEBUG_IP=%DEBUG_IP%

Related

How to Update Firebase Value Using an HTML Button Value?

So I figured out how to update the value of the database, but the another problem came up. When I'm trying to update the value of a certain in the table, the output is that it updated all the values. I'm not getting the correct key when a certain button is pressed for the update. Can you guys help me with this?
My .html file
var rootRef = firebase.database().ref().child("REPORTS").child('05-21-2017');
rootRef.on("child_added", function(snapshot){
var date = snapshot.child("dateAndTime").val();
var lat = snapshot.child("latitude").val();
var long = snapshot.child("longitude").val();
var link = snapshot.child("link").val();
var report = snapshot.child("report").val();
var status = snapshot.child("status").val();
var needs = snapshot.child("needs").val();
var key = snapshot.key;
console.log(key);
var updateData = "updateData()";
$("#table_body").append("<tr id='"+snapshot.key+"'><td>"+snapshot.key+"</td><td>" +date+"</td><td>"+report+"</td><td>"+lat+"</td><td>"+long+"</td><td>"+status+"</td><td>"+needs+"</td><td><button onclick = "+updateData+">update</button></td></tr>");
});
My .js file
function updateData(key) {
var rootRef = firebase.database().ref().child("REPORTS").child('05-21-2017');
rootRef.on("child_added", function(snapshot){
var rootRef2 = firebase.database().ref().child("REPORTS").child('05-21-2017/'+snapshot.key);
console.log(rootRef2);
rootRef2.update({status: "Ongoing"});
console.log("success");
});
}
Here is what my table looks like
I want to change a particular table when i click the update button. Please help me, badly needed.
const ulTable = document.getElementById('tabla');
//Create references
const dbRefObject = firebase.database().ref().child('Users');
//Sync table changes
dbRefObject.on('child_added', snap => {
var gear = snap.child('Gear').val();
var level = snap.child('Level').val();
var strength = snap.child('Strength').val();
$(ulTable).append("<tr id="+snap.key+"><td>" + gear + "</td><td>" + level + "</td><td>" + strength + "</td></tr>");
}); //child_added
dbRefObject.on('child_changed', snap => {
var gear = snap.child('Gear').val();
var level = snap.child('Level').val();
var strength = snap.child('Strength').val();
$("#"+snap.key).html("<td>" + gear + "</td><td>" + level + "</td><td>" + strenght + "</td>");
}); //child_changed
dbRefObject.on('child_removed', snap => {
var gear = snap.child('Gear').val();
var level = snap.child('Level').val();
var strength = snap.child('Strength').val();
$("#"+snap.key).html("<td>" + gear + "</td><td>" + level + "</td><td>" + strenght + "</td>").remove();
});
My DB is:
Users -> (Gear, Level, Strength)

AS3 timer is faster than php

Im trying too load new messages every second, but new messages are doubled everytime they are loaded, I suppose because the timer is completed before the php is executed?
so I tried to add
if (checker != "" + idstored + "done") {
checker = "" + idstored + "done";
so that once the timer completes, it changes the checker so that when the timer restarts and finishes again it would not execute again... but it stopped checking for all new messages... any tips??
var count:Timer = new Timer(1000, 1);
count.addEventListener(TimerEvent.TIMER_COMPLETE, onTimerComplete);
count.start();
var checker;
function onTimerComplete(event:TimerEvent):void{
if (checker != "" + idstored + "done") {
checker = "" + idstored + "done";
var variables_cc:URLVariables = new URLVariables();
var varSend_cc:URLRequest = new URLRequest("chat.php");
varSend_cc.method = URLRequestMethod.POST;
varSend_cc.data = variables_cc;
var varLoader_cc:URLLoader = new URLLoader;
varLoader_cc.dataFormat = URLLoaderDataFormat.VARIABLES;
varLoader_cc.addEventListener(Event.COMPLETE, completeHandler_cc);
function completeHandler_cc(event:Event):void{
if (event.target.data.statusline == "is_new") {
stored_id_txt.text = "" + event.target.data.stored_id;
status_txt.text = "" + event.target.data.statusline;
returnline.text = "" + event.target.data.returnBody;
checker.text = checker;
splitByDelimiter(event.target.data.returnBody);
idstored = event.target.data.stored_id;
checker = "refresh";
}
}}
// ready the last_refresh_time variable for sending to PHP
variables_cc.requester = "chat_check";
variables_cc.stored_id = idstored;
varLoader_cc.load(varSend_cc);
count.reset();
count.start();
}
You get errors becouse you sometimes try to start new download when the previous is not finished. It's not wise to do something latency dependent every 1 second real time. You need to start something, wait for it to finish, and then start it again.
removeEventListener of the timer after it launches (inside onTimerComplete function) and stop the timer and reset it. qddEventListener to the timer and start it after the data is downloaded (inside completeHangler_cc function).

getRange(),setFormulas doesn't want to work

I have the following code and when I run it I get the right number of items in sheetFormulas (4), and the array values look correctly formed.
However, I get an error right after the sheetFormulas Browser.msgBox pops up, indicating the getRange().setFormulas line has an issue, but I can't see what it is.
function test(){
var ss = SpreadsheetApp.getActiveSpreadsheet();
var testingTarget = ss.getSheetByName("Testing");
var sheetFormulas = new Array();
for (l=0;l<10;l++) {
sheetRowCount = l + 2;
var monthlyTotalCompanyCosts = '=F' + sheetRowCount + '/$F$29*$I$14';
var monthlyTotalCompanyCostsPerEa = '=IFERROR(H' + sheetRowCount + '/C' + sheetRowCount + ')';
var monthlyMargin = '=D' + sheetRowCount + '-F' + sheetRowCount;
var monthlyMarginPctg = '=IFERROR(J' + sheetRowCount + '/D' + sheetRowCount + ')';
sheetFormulas.push(monthlyTotalCompanyCosts,monthlyTotalCompanyCostsPerEa,monthlyMargin,monthlyMarginPctg);
Browser.msgBox("sheetFormulas.length is: " + sheetFormulas.length);
Browser.msgBox("sheetFormulas is: " + sheetFormulas);
testingTarget.getRange(sheetRowCount,8,1,4).setFormulas(sheetFormulas);
sheetFormulas = [];
}
}
Any help is appreciated,
Phil
First, sheetFormulas has to be a 2D array. So try doing
/* Notice the [] around sheetFormulas */
testingTarget.getRange(sheetRowCount,8,1,4).setFormulas([sheetFormulas]);
If you still see other problems, then put your code inside a try{}catch{} block and print out the exception in the catch block.
I also suggest that you print out the formula using Logger.log() before setting it on the spreadsheet.

Update jqGrid table with the results of Fusion Tables query in a Google Maps v3 page

I am looking to understand how to update a jqGrid table from Fusion Tables (FT) -
at the moment I can search or scroll on a Google Map, send an event listener that compiles a FT query of the spatial bounds of the viewport/map, to get a new set of results.
I want to use the new FT query string (or could use the Google code to retrieve the data - query.send(getData);) to update the jqGrid table with the new values.
Before I started using jqGrid, I tried/suceeded with the Google Visualisation API, and some of that code is below. Could anyone suggest how to move from table.draw, to loading/reloading a jqGrid table? Thanks a lot in advance.
function tilesLoaded() {
google.maps.event.clearListeners(map, 'tilesloaded');
google.maps.event.addListener(map, 'zoom_changed', getSpatialQuery);
google.maps.event.addListener(map, 'dragend', getSpatialQuery);
getSpatialQuery();
}
function getSpatialQuery() {
sw = map.getBounds().getSouthWest();
ne = map.getBounds().getNorthEast();
var spatialQuery = "ST_INTERSECTS(latitude, RECTANGLE(LATLNG(" + sw.lat() + "," + sw.lng() + "), LATLNG(" + ne.lat() + "," + ne.lng() + ")))";
changeDataTable(spatialQuery);
}
function changeDataTable(spatialQuery) {
var whereClause = "";
if(spatialQuery) {
whereClause = " WHERE " + spatialQuery;
}
var queryText = encodeURIComponent("SELECT 'latitude', 'longitude', 'name' FROM xxxxxxxx" + whereClause + " LIMIT 50");
var query = new google.visualization.Query('http://www.google.com/fusiontables/gvizdata?tq=' + queryText);
query.send(getData);
}
function getData(response) {
var table = new google.visualization.Table(document.getElementById('visualization'));
table.draw(response.getDataTable(), {showRowNumber: true});
}
Oh, and I used Oleg's code jqGrid returns blank cells as a basis for just seeing if I could get a simple multi-select table to pull data from my FT - that worked fine with the simple mod of
url: 'http://www.google.com/fusiontables/api/query?sql=' +
In case this helps someone, I've taken some of the code I came up with and pasted it below:
// You can get the map bounds via then pass it via a function (below is hacked from several functions
sw = map.getBounds().getSouthWest();
ne = map.getBounds().getNorthEast();
var whereClause = "ST_INTERSECTS(latitude, RECTANGLE(LATLNG(" + sw.lat() + "," + sw.lng() + "), LATLNG(" + ne.lat() + "," + ne.lng() + ")))";
//construct the URL to get the JSON
var queryUrlHead = 'http://www.google.com/fusiontables/api/query?sql=';
var queryUrlTail = '&jsonCallback=?'; //
var queryOrderBy = ' ORDER BY \'name\' ASC';
var queryMain = "SELECT * FROM " + tableid + whereClause + queryOrderBy + " LIMIT 100";
var queryurl = encodeURI(queryUrlHead + queryMain + queryUrlTail);
//use the constructed URL to update the jqGrid table - this is the part that I didn't know in my above question
$("#gridTable").setGridParam({url:queryurl});
$("#gridTable").jqGrid('setGridParam',{datatype:'jsonp'}).trigger('reloadGrid');

Problems Displaying Profile Picture in Flash swf

I followed this tutorial Loading Facebook Profile Picture Into Flash SWF Using Graph API to get the users profile picture to show in my flash game, but I'm having some issues.
import com.facebook.graph.Facebook;
import com.facebook.graph.data.FacebookSession;
import com.facebook.graph.net.FacebookRequest;
import flash.events.Event;
import flash.events.IOErrorEvent;
//place your APP ID here
const APP_ID:String = "app_id";
//Initialize facebbok library
Facebook.init(APP_ID, HandleLogin);
function HandleLogin(response:Object, fail:Object):void
{
if(Facebook.getSession().accessToken)
{
LoadMyInfo();
LoadMyPicture();
}
}
function LoadMyInfo():void
{
Facebook.api("/me", MyInfoLoaded);
}
function MyInfoLoaded(response:Object, fail:Object):void
{
nameTextField.text = response.name;
}
function LoadMyPicture():void
{
debug.text = "Entered loadMyPicture() function ";
var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, MyPictureLoaded, false, 0, true);
var request:URLRequest = new URLRequest("facebookProxy.php");
var variables:URLVariables = new URLVariables();
variables.path = Facebook.getImageUrl(String(Facebook.getSession().uid), 'large');
debug.appendText(" \nvariables.path: " + String(variables.path));
request.data = variables;
debug.appendText(" \nrequest.data: " + String(request.data))
loader.load(request);
debug.appendText(" \n" + String(loader.load(request)));
}
function MyPictureLoaded(event:Event):void
{
debug.appendText(" \nEntering MyPictureLoaded");
var loader:Loader = event.target.loader;
loader.contentLoaderInfo.removeEventListener(Event.COMPLETE, MyPictureLoaded);
loader.contentLoaderInfo.removeEventListener(IOErrorEvent.IO_ERROR, MyPictureLoadError);
var bitmap = Bitmap(loader.content);
bitmap.smoothing = true;
//Note: picturePlaceholder is just a blank movie clip on the Stage
bitmap.x = picturePlaceHolder.x;
bitmap.y = picturePlaceHolder.y;
bitmap.width = picturePlaceHolder.width;
bitmap.height = picturePlaceHolder.height;
picturePlaceHolder.addChild(bitmap);
debug.appendText(" \nBitmap is null: " + String(bitmap == null) +
" \nBitmap X: " + String(bitmap.x) + " Bitmap Y: " + String(bitmap.y) +
" \nBitmap width: " + String(bitmap.width) +
" \nBitmap height: " + String(bitmap.height))
}
function MyPictureLoadError(e:IOErrorEvent):void
{
debug.appendText("Loading Error");
}
This is what my code looks like after following the tutorials on the link above. With the debug I noticed that the function MyPictureLoaded is never called.
They never specified where I would call the function LoadMyPicture. I assumed it would go together with LoadMyInfo so I placed it there. They have a working example but no source code, so I'm hope someone here would shed some light on this.
EDIT 1
Here is what it looks like when I put it up on facebook. The last line debug.appendText(" \n" + String(loader.load(request))); is outputting undefined. I also made a change in the variables.path = Facebook.getImageUrl(String(Facebook.getSession().uid), 'large'); I added (String(), 'large') because in the docs it saying to pass strings into there. Edit: I realized adding String() is pointless.
var request:URLRequest = new URLRequest("facebookProxy.php");
Did you do the part of the tutorial that writes a server-side PHP proxy loader on your server?
If you don't have a file named facebookProxy.php on your server where you run this it won't work (the code is requesting "./facebookProxy.php" which probably doesn't exist). If you want to run this in the debugger on your local machine, you will need to make that file in the same directory as your swf and make sure you have apache/php running on your localhost.
If that's too much work for you, I would suggest following some of the examples from the API' project page: http://code.google.com/p/facebook-actionscript-api/downloads/detail?name=GraphAPI_Examples_1_6.zip&can=2&q=