Action Script 3 Errors 1061 and 1120 - actionscript-3

I'm new to this, not sure what I'm doing wrong, Thank you for help
Please see my code below:
protected function getXMLUrl(vid:String):String {
//return 'http://v.iask.com/v_play.php?vid='+ vid;
var rand:* = Math.random();
var f1:* = function (param1:Number) : Number {
var _loc_2:* = param1.toString(2);
var _loc_3:* = _loc_2.substring(0, _loc_2.length - 6);
return parseInt(_loc_3, 2);
};
var Str1:* = "Z6prk18aWxP278cVAH";
var Date1:* = new Date();
var Num:* = this.f1(int(Date1.time / 1000));
var str:* = vid.toString() + str1 + Num + rand.toString();
var hash:* = MD5.hash(str);
var encode:* = hash.substr(0, 16).toString() + Num.toString();
return 'http://v.iask.com/v_play.php?vid='+ vid + "&ran=" + rand + "&p=i&k=" + encode;
}
And here are the Errors I'm getting
1061: Call to a possibly undefined method f1 through a reference with static type
1120: Access of undefined property MD5.
1120: Access of undefined property str1.

Never mind, I fixed it
add
import com.adobe.crypto.MD5;
also deleted all the " :* "

Related

NativeScript JobScheduler JobService.class is undefined

I have weird error while i'm trying to create component in the JobScheduler
At the first line when setting a component value i get this error:
ERROR TypeError: Cannot read property 'MyJobService' of undefined
Both of the files are in the same folder, and its all worked yesterday.
I cleaned up the platforms folder just to be sure, because i dragged some pics to the drawble folders in the app_Resources and i had to build the project again and maybe something has changed. but it did not helped.
What can cause this problem ? am i missing something ?
JobScheduler.js :
function scheduleJob(context) {
var component = new android.content.ComponentName(context, com.tns.notifications.MyJobService.class);
const builder = new android.app.job.JobInfo.Builder(1, component);
builder.setPeriodic(15 * 60 * 1000);
builder.setOverrideDeadline(0);
const jobScheduler = context.getSystemService(android.content.Context.JOB_SCHEDULER_SERVICE);
console.log("Job Scheduled: " + jobScheduler.schedule(builder.build()));
}
module.exports.scheduleJob = scheduleJob;
MyJobService.js :
android.app.job.JobService.extend("com.tns.notifications.MyJobService", {
onStartJob: function(params) {
console.log("Job execution ...");
var utils = require("utils/utils");
var context = utils.ad.getApplicationContext();
var builder = new android.app.Notification.Builder(context);
console.log("setting notification head and body")
builder.setContentTitle("notification triggered ")
.setAutoCancel(true)
.setColor(android.R.color.holo_purple)//getResources().getColor(R.color.colorAccent))
.setContentText("body)
.setVibrate([100, 200, 100])
.setSmallIcon(android.R.drawable.btn_star_big_on);
var mainIntent = new android.content.Intent(context, com.tns.NativeScriptActivity.class);
var mNotificationManager = context.getSystemService(android.content.Context.NOTIFICATION_SERVICE);
const channelId = "my_channel_01";
const name = "Channel name";
const description = "Channel description";
const importance = android.app.NotificationManager.IMPORTANCE_LOW;
if (android.os.Build.VERSION.SDK_INT >= 26) {
console.log("api level is good",android.os.Build.VERSION.SDK_INT)
}
const mChannel = new android.app.NotificationChannel(channelId, name,importance);
mChannel.setDescription(description);
mChannel.enableLights(true);
mChannel.enableVibration(true);
mNotificationManager.createNotificationChannel(mChannel);
builder.setChannelId(channelId);
mNotificationManager.notify(1, builder.build());
return false;
},
onStopJob: function() {
console.log("Stopping job ...");
}
});

Firebase "MD5" & BloddyCrytpo's dont match

I'm trying to do a check to see if the user has a local file. If the user does, I get bloodycrypto to make a md5 out of it. Then I compare the two values. One from the firebase file's metadata and the other from the byte array of the file digested. They never match. Does Firebase do something different when trying to generate the md5 of a file I upload?
private function handleMetaSuccess(e:StorageReferenceEvent):void
{
trace("Meta succes for reference:" + this.name);
storageMetaData = e.metadata;
trace("reading file.");
fileBA = new ByteArray();
var fs:FileStream = new FileStream();
fs.open(Definitions.CACHE_DIRECTORY.resolvePath(name + ".jpg"), FileMode.READ)
fs.readBytes(fileBA);
fs.close();
var byteHash:String = MD5.hashBytes(fileBA)
trace("Local hash = " + byteHash); //93b885adfe0da089cdf634904fd59f71
trace("Network hash = " + storageMetaData.md5Hash); //bo7XPotC+T5wmAcpagnXBw==
if (byteHash != storageMetaData.md5Hash)
{
trace("Not equal. Getting file."); //Always happens
getFile();
}
else
{
loadFile();
}
}
Upon closer inspetion (thanks to Organis) firebase doesn't return a proper MD5. What is it? In my storage consol I don't see an md5 property, so is this autogenerated? The files were uploaded through my rest API based off phantom's guide.
Update: Following Organis' comment about the way Firebase handle's MD5s
var byteHash:ByteArray = new ByteArray();
byteHash.writeUTFBytes(MD5.hashBytes(fileBA));
var byteHashWithLength:ByteArray = new ByteArray();
byteHashWithLength.writeUTF(MD5.hashBytes(fileBA));
trace("Bytehash with length = " + Base64.encode(byteHashWithLength)); //ACAyMTMzYTdmYjczYTEzZDQ3ZDkzMTEyY2I1OWQyYTBmMg==
trace("Plain = " + Base64.encode(byteHash)); //OTNiODg1YWRmZTBkYTA4OWNkZjYzNDkwNGZkNTlmNzE=
trace("Storage md5 = " + storageMetaData.md5Hash); //UsoNl5sL1+aLiAhTOTBXyQ==
Trying to take the md5 I get and turn it into base64 results in consistent mismatching results. Is there an argument I am missing or applying incorrectly when I try to decode everything?
...So I would do something like
var storageHash:String = Base64.decode(storageMetaData.md5Hash).toString();
to follow your example right?
Try this code below to get your storageMetaData.md5Hash correctly decoded from Base64 :
Let me know result of trace("storage hash : " + storageHash); to check if you're getting an (expected) sequence of 32 hex values.
private function handleMetaSuccess(e:StorageReferenceEvent):void
{
trace("Meta succes for reference:" + this.name);
storageMetaData = e.metadata;
trace("reading file.");
fileBA = new ByteArray();
var fs:FileStream = new FileStream();
fs.open(Definitions.CACHE_DIRECTORY.resolvePath(name + ".jpg"), FileMode.READ)
fs.readBytes(fileBA);
fs.close();
var byteHash:String = MD5.hashBytes(fileBA); //Local hash
var ba_storageHash:ByteArray = new ByteArray();
ba_storageHash = Base64.decode(storageMetaData.md5Hash); //update ByteArray
var storageHash:String = bytesToHexString(ba_storageHash); //Hex values of bytes shown as String
trace("Network hash : " + storageMetaData.md5Hash); //bo7XPotC+T5wmAcpagnXBw==
trace("Local hash : " + byteHash); //93b885adfe0da089cdf634904fd59f71
trace("storage hash : " + storageHash); //what is result??
if (byteHash != storageHash)
{
trace("Not equal. Getting file."); //Always happens
getFile();
}
else
{
loadFile();
}
}
// # Byte values (Hex) shown as (returned) String type
private function bytesToHexString(input:ByteArray) : String
{
var strOut:String = ""; var strRead:String = "";
input.position = 0;
var intBASize:uint = input.length;
for (var i:int = 0; i < intBASize; i++)
{
strRead = input.readUnsignedByte().toString(16);
if(strRead.length < 2) { strRead = "0" + strRead; } //# do padding
strOut += strRead ;
}
return strOut.toLowerCase(); //strOut.toUpperCase();
}

Extjs 5 Uncaught TypeError: Cannot read property 'height' of undefined

I changed extjs 4.2.4 to 5.0.0 and I have this error.
Uncaught TypeError: Cannot read property 'height' of undefined
SubSectionColumn.js?_dc=1451369036732:262
loadSprites: function() {
var chart = Ext.getCmp(this.identifier);
//var xAxisPositionArray = [55,95,135,175];
var xAxisPositionArray = new Array();//[55,95,175];
var yAxisStart = 0;
var xAxisHeight = chart.surface.height
var sprite;
var fromPosition;
var toPosition;
var width;
var noOfBars;
var sectionWidth = 0;
var newWidthValue = 0;
var tmp;
var chart = Ext.getCmp(this.identifier);
var storeLen =this.storeValue.getCount();
var teststore =this.storeValue;
var maxVal = 0;
for (var i =0; i<storeLen; i++){
tmp = parseFloat(teststore.data.items[i].get('data1'));
if (tmp >maxVal){
maxVal=tmp;
}
}
if(maxVal>0){
width = this.widthValue;
noOfBars = this.storeLength;//5;
sectionWidth = parseInt(parseInt(width)/parseInt(noOfBars));
for(var j=0;j<noOfBars;j++){
newWidthValue = parseInt(newWidthValue) + parseInt(sectionWidth);
xAxisPositionArray[j] = newWidthValue;
}
var gridArray = this.gridLineArrayVal.split(",");
for(var i=0;i<xAxisPositionArray.length;i++){
fromPosition = parseInt(xAxisPositionArray[i]);
toPosition = fromPosition+1;
sprite = Ext.create('Ext.draw.Sprite', {
type: 'path',
path: "M"+fromPosition+" " + yAxisStart +"L"+toPosition+" "+xAxisHeight+" Z", //if the value is "M100 40 L150 40", it's ok.
"stroke-width": (gridArray[i]=='dotted' || gridArray[i]=='line')?"0.4":"0",
"stroke-dasharray":(gridArray[i]=='dotted')?"4,4,2.5,4,4,4":"",
//"stroke-dasharray":"20,20",
stroke: "#9f9f9f",
//style:{cursor: 'pointer'},
surface: chart.surface
});
sprite.show(true);
};
maxVal=parseFloat(maxVal)*(0.10)+parseFloat(maxVal); //Math.round(maxVal)+1;
chart.axes.getAt(0).maximum = maxVal;
}
}
chart.surface is obviously undefined, as that's where you're trying to access the height property.
In ExtJS 5, there were two big changes that are likely to be relevant here. First, they tightened up on the configuration properties. Many are now prefixed, and can not be accessed by their old names. Instead, you should use (and should have used, before) the accessor methods - e.g. chart.getSurface()
Second: The charting library used in ExtJs 4 was deprecated, and has been replaced with Sencha Charts. This brought in some significant API changes.
Without more details, it's hard to say what the root cause is, but the error is definitely to do with lack of access to the surface property.

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.

AS3 Is this code creating a MC Variable?

I've created some MC dynamicallly and did what I thought would be assigning values to variables in the MC's as I generated them e.g.
my_mc.name = "mc" + i + j;
trace("^^^^^^^^^^^^^^****************" + my_mc.name); // Works
my_mc.mcRow = j + 1; // Thinking I'm assigning values to a variable
trace("^^^^^^^^^^^^^^****************" + my_mc.mcRow); // Works
addChild(my_mc);
So, the trace outputs do what I expect, however, when I try to use/output the mcRow values later, they do not show up e.g.
var my_FC_row = (root as DisplayObjectContainer).getChildAt(r).name; // Works
var cxmy_FC_row = [my_FC_row].mcRow; // No value- does not work
var my_FC_name = (root as DisplayObjectContainer).getChildAt(r).name; // Works
var my_FC_x = (root as DisplayObjectContainer).getChildAt(r).x; // Works
var my_FC_y = (root as DisplayObjectContainer).getChildAt(r).y; // Works
cellData[r] = [my_FC_name, my_FC_x, my_FC_y, cxmy_FC_row];
trace("$$$$$$$$$$$$$$$$$$$$$ :" + r +" : "+ cellData[r]);
This code is in another function but I thought that the MC would still hold the value for mcRow.
What have I done/assumed incorrectly?
try this
var my_FC_row = (root as DisplayObjectContainer).getChildAt(r); // Works
var cxmy_FC_row = my_FC_row.mcRow; // Works