When I export my application to device central I get this error constantly popping up in the output window "TypeError: Error #1009: Cannot access a property or method of a null object reference. atsquareslide_fla::MainTimeline/test()
This is the code that I have right now:
` import flash.events.Event;
import flash.events.TouchEvent;
import flash.ui.Multitouch;
import flash.ui.MultitouchInputMode;
stage.addEventListener(Event.ENTER_FRAME,loop);
function loop(e:Event)
{
rock1.rotation +=10;
rock2.rotation +=10;
rock3.rotation +=10;
rock4.rotation +=10;
rock5.rotation +=10;
widerock.rotation +=10;
rock1.y +=10;
rock2.y +=10;
rock3.y +=10;
rock4.y +=10;
rock5.y +=10;
widerock.y +=10;
if (rock1.y >= 872.9)
{
rock1.y = -46.75;
}
if (rock2.y >= 872.9)
{
rock2.y = -84.75;
}
if (rock3.y >= 872.9)
{
rock3.y = -69.75;
}
if (rock4.y >= 872.9)
{
rock4.y = -230.9;
}
if (rock5.y >= 872.9)
{
rock5.y = -230.9;
}
if (widerock.y >= 872.9)
{
widerock.y = -547.8;
}
}`
Something is obviously wrong with rock one but I have no idea what it is or how to fix it.
Please help!
Try with this event
It fires when everything is added to the stage.
Related
I write a piece of code, then compile it with no errors. but when I run, it throws an exception (java.lang.NoClassDefFoundError: TesKt$test$1$1).
Is this a language bug?
private fun test(block:()->Unit) = arrayOf(1).map {
object {
fun print() {
println("Hello print")
block()
}
}
}
fun main(args: Array<String>) {
val array = test{println("Hello main")}
array[0].print()
}
I'm going to conclude that it's a bug in the Kotlin compiler. I played a lot with this code and looked into the compiled bytecode. It seems the compiler is losing some information about the anonymous class which is defined by object.
If we add a type to that object, then it works fine:
interface Printable {
fun print()
}
private fun test(block:()->Unit): List<Printable> {
return arrayOf(1).map {
object: Printable {
override fun print() {
println("Hello print")
block()
}
}
}
}
fun main(args: Array<String>) {
val array = test{println("Hello main")}
array[0].print()
}
As you can see, I only defined a simple Printable interface and annotated the anonymous class with this interface.
Let's call your code: version A, and this code of mine: Version B.
I compiled code A and then decompiled it to Java. Here's the result:
import TestKt.test.1.1;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import kotlin.Metadata;
import kotlin.Unit;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.internal.Intrinsics;
import org.jetbrains.annotations.NotNull;
#Metadata(
mv = {1, 1, 15},
bv = {1, 0, 3},
k = 2,
d1 = {"\u0000#\n\u0000\n\u0002\u0010\u0002\n\u0000\n\u0002\u0010\u0011\n\u0002\u0010\u000e\n\u0002\b\u0002\n\u0002\u0010 \n\u0002\b\u0002\n\u0002\u0018\u0002*\u0001\b\u001a\u0019\u0010\u0000\u001a\u00020\u00012\f\u0010\u0002\u001a\b\u0012\u0004\u0012\u00020\u00040\u0003¢\u0006\u0002\u0010\u0005\u001a\u001c\u0010\u0006\u001a\b\u0012\u0004\u0012\u00020\b0\u00072\f\u0010\t\u001a\b\u0012\u0004\u0012\u00020\u00010\nH\u0002"},
d2 = {"main", "", "args", "", "", "([Ljava/lang/String;)V", "test", "", "TestKt$test$1$1", "block", "Lkotlin/Function0;"}
)
public final class TestKt {
/*#19:*/private static final List<1> test(Function0<Unit> block) {
Object[] $this$map$iv = new Integer[]{1};
int $i$f$map = false;
Collection destination$iv$iv = (Collection)(new ArrayList($this$map$iv.length));
int $i$f$mapTo = false;
Integer[] var6 = $this$map$iv;
int var7 = $this$map$iv.length;
for(int var8 = 0; var8 < var7; ++var8) {
Object item$iv$iv = var6[var8];
int it = ((Number)item$iv$iv).intValue();
int var11 = false;
/*#31:*/ TestKt.test..inlined.map.lambda.1 var13 = new TestKt.test..inlined.map.lambda.1(block);
destination$iv$iv.add(var13);
}
return (List)destination$iv$iv;
}
public static final void main(#NotNull String[] args) {
Intrinsics.checkParameterIsNotNull(args, "args");
List array = test((Function0)TestKt.main.array.1.INSTANCE);
/*#41:*/((1)array.get(0)).print();
}
}
And this is the result of the same process for code B:
import TestKt.test..inlined.map.lambda.1;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import kotlin.Metadata;
import kotlin.Unit;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.internal.Intrinsics;
import org.jetbrains.annotations.NotNull;
#Metadata(
mv = {1, 1, 15},
bv = {1, 0, 3},
k = 2,
d1 = {"\u0000\"\n\u0000\n\u0002\u0010\u0002\n\u0000\n\u0002\u0010\u0011\n\u0002\u0010\u000e\n\u0002\b\u0002\n\u0002\u0010 \n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\u001a\u0019\u0010\u0000\u001a\u00020\u00012\f\u0010\u0002\u001a\b\u0012\u0004\u0012\u00020\u00040\u0003¢\u0006\u0002\u0010\u0005\u001a\u001c\u0010\u0006\u001a\b\u0012\u0004\u0012\u00020\b0\u00072\f\u0010\t\u001a\b\u0012\u0004\u0012\u00020\u00010\nH\u0002"},
d2 = {"main", "", "args", "", "", "([Ljava/lang/String;)V", "test", "", "LPrintable;", "block", "Lkotlin/Function0;"}
)
public final class TestKt {
/*#19:*/private static final List<Printable> test(Function0<Unit> block) {
Object[] $this$map$iv = new Integer[]{1};
int $i$f$map = false;
Collection destination$iv$iv = (Collection)(new ArrayList($this$map$iv.length));
int $i$f$mapTo = false;
Integer[] var6 = $this$map$iv;
int var7 = $this$map$iv.length;
for(int var8 = 0; var8 < var7; ++var8) {
Object item$iv$iv = var6[var8];
int it = ((Number)item$iv$iv).intValue();
int var11 = false;
/*#31:*/ 1 var13 = new 1(block);
destination$iv$iv.add(var13);
}
return (List)destination$iv$iv;
}
public static final void main(#NotNull String[] args) {
Intrinsics.checkParameterIsNotNull(args, "args");
List array = test((Function0)TestKt.main.array.1.INSTANCE);
/*#41:*/((Printable)array.get(0)).print();
}
}
As you can see, the only differences are in the first line, as well as line numbers 19, 31 and 41 (commented like #19: and so on).
In code A a type (strangely) with the name of 1 is expected. But this type 1, which is packaged as TestKt.test.1.1, is not found and so you got your error (NoClassDefFoundError: TesKt$test$1$1).
Inn code B, however, a more clear type of Printable is expected and found.
If the compiler had compiled the very first line of code A just like code B (import TestKt.test..inlined.map.lambda.1; instead of import TestKt.test.1.1;) then your code would have worked.
My main process:
public void quoteStartReceive()
{
Thread thdWrite = new Thread(new ThreadStart(DoParseGUIDisplay));
thdWrite.IsBackground = true;
thdWrite.Start();
}
My thread function:
void DoParseGUIDisplay()
{
for (int i = 0; i < 1024; i++)
{
if (myQueue.Count > 0)
{
string strOut = myQueue.Dequeue().ToString();
Tick tick = new Tick(strOut);
if (tick.m_last != "")
{
string msg = "Update Text";
if (this.textBox1.InvokeRequired)
{
this.textBox1.BeginInvoke((MethosInvoker)delegate () {this.textBox1.Text = msg; };
}
else
{
this.textBox1.Text = msg;
}
}
}
}
}
No matter I tried to use Invoke() or BeginInvoke(), I cannot update the text in textBox1.
I also tried another way:
public delegate void UpdateTextCallback(string text);
It still cannot help me to update my textBox1.
Help me to find out what stuff I missed. Thanks.
put an argument before the thread:
Application.DoEvents();
and it should be put after the m_last was updated.
#template-productlist-id = 1;
& when (#template-productlist-id = 0) {
import "product-lists/product-list0.less";
}
& when (#template-productlist-id > 0) {
import "product-lists/product-list.less";
}
But it doesn't seem to be working. Still importing 2 files. How can I achieve that?
you code is not valid Less, try:
you should assign variables with a colon (:)
your import statement should start with a at (#)
.
#template-productlist-id: 0;
.import() {
& when (#template-productlist-id = 0) {
#import "product-lists/product-list0.less";
}
& when (#template-productlist-id > 0) {
#import "product-lists/product-list.less";
}
}
.import();
Or indeed also the following Less code will give the expected result:
#template-productlist-id: 0;
& when (#template-productlist-id = 0) {
#import "product-lists/product-list0.less";
}
& when (#template-productlist-id > 0) {
#import "product-lists/product-list.less";
}
I am working on a Web App on grails and I am using Clickatell as the Web API.
I have these codes on an SMSNotifier.groovy class.
Yet, I encounter the MissingPropertyException
groovy.lang.MissingPropertyException: No such property: POST for class: utils.SMSNotifier
at utils.SMSNotifier.sendClickatellSms(SMSNotifier.groovy:54)
The codes which is inside the SMSNotifier class which has errors, are the following:
def sendClickatellSms(def number, def text)
{
def http = new HTTPBuilder('http://api.clickatell.com/')
http.contentType = TEXT
EncoderRegistry encoders = new EncoderRegistry();
encoders.setCharset('ISO-8859-1') http.setEncoderRegistry(encoders)
http.request( POST )
{
uri.path = 'http://sendmsg'
requestContentType = URLENC
if (number.substring(0, 1) == '+')
{
// Remove a leading plus sign number = number.substring(1)
}
body = [ api_id: '3442677', user: 'iTech013', password: '', from: '+639277705918', to: number, text: text, concat: '3', callback: '2', deliv_ack: '1' ]
response.success = { resp, reader -> def msg = reader.text if (msg.substring(0, 2) == 'ID') { return 0 } else if (msg.substring(0, 3) == 'ERR') { log.error("Clickatell " + msg) return msg.substring(5, .toInteger() } else { return 1 }
} response.failure = { resp -> log.error("Failed to contact Clickatell: ${resp.statusLine}") return 1 } } }
The SMSNotifier.groovy file:
package utils
import org.itech.klinikav2.domain.Patient import org.itech.klinikav2.enums.NotificationType;
import groovyx.net.http.EncoderRegistry
import groovyx.net.http.HTTPBuilder
import static groovyx.net.http.Method.GET
import static groovyx.net.http.ContentType.TEXT import grails.persistence.Event
/** * #author Randy * */
class SMSNotifier
{
//this method is to send a message with a patient parameter and message
public static String chooseMessage(NotificationType notifType, Patient patient)
{
def message= "Greetings! You will have a follow-up appointment tomorrow." def doctor= "Doctor: " def time= "Time: "
def p=patient
if (notifType.equals(NotificationType.FOLLOW_UP_APPOINTMENT))
{
message= "Greetings! You will have a follow-up appointment tomorrow."
return message }
else if (notifType.equals(NotificationType.BALANCE))
{
message= "Greetings! Just reminding you of your balance for appointment payment."
return message }
}
def sendToList(ArrayList<Patient> patients, NotificationType notifType)
{
def patientList= patients for (int i=0; i< patientList.size(); i++)
{ def patient = patientList.get(i)
def message = chooseMessage(notifType, patient)
sendClickatellSms(patient.mobileNumber, message) }
}
def sendClickatellSms(def number, def text)
{
def http = new HTTPBuilder('http://api.clickatell.com/')
http.contentType = TEXT EncoderRegistry encoders = new EncoderRegistry();
encoders.setCharset('ISO-8859-1') http.setEncoderRegistry(encoders)
http.request(POST)
{
uri.path = 'http://sendmsg'
requestContentType = URLENC
if (number.substring(0, 1) == '+')
{ // Remove a leading plus sign
number = number.substring(1)
}
body = [ api_id: '3442677', user: 'iTech013', password: 'ingenium123..', from: '+639277705918', to: number, text: text, concat: '3', callback: '2', deliv_ack: '1' ]
response.success =
{ resp, reader -> def msg = reader.text if (msg.substring(0, 2) == 'ID') { return 0 }
else if (msg.substring(0, 3) == 'ERR')
{
log.error("Clickatell " + msg)
return msg.substring(5, .toInteger() }
else { return 1 }
}
response.failure = { resp -> log.error("Failed to contact Clickatell: ${resp.statusLine}") return 1 } } }
}
I called this method through the index() method of a Controller class. These are the codes:
def index()
{
def sms = new SMSNotifier()
def result= sms.sendClickatellSms("09277705918", "Hi!")
if(result==1) { render "success" }
else{ render "sorry" }
}
I left the password space blank, but i put the actual password on my actual codes.
I think the answer is simple, I am just starting with APIs so, every bit of knowledge and help on this matter is highly appreciated!
Thank you in advance! :)
import static groovyx.net.http.Method.*
Missing import for POST.
I have two air applications and installed them in desktop and executed them and two air processes are listed in taskbar manager.Now how can I execute some method of one air application from another air application?
Use LocalConnection.
You can Host a Connection in one AIR application and connect from the the other AIR guy... From there - you can call methods.
BEWARE: LocalConnection can be a little tricky and odd (for example, connections are global and the names can't overlap).
From the Example Doc listed above....
// Code in LocalConnectionSenderExample.as
package {
import flash.display.Sprite;
import flash.events.MouseEvent;
import flash.net.LocalConnection;
import flash.text.TextField;
import flash.text.TextFieldType;
import flash.events.StatusEvent;
import flash.text.TextFieldAutoSize;
public class LocalConnectionSenderExample extends Sprite {
private var conn:LocalConnection;
// UI elements
private var messageLabel:TextField;
private var message:TextField;
private var sendBtn:Sprite;
public function LocalConnectionSenderExample() {
buildUI();
sendBtn.addEventListener(MouseEvent.CLICK, sendMessage);
conn = new LocalConnection();
conn.addEventListener(StatusEvent.STATUS, onStatus);
}
private function sendMessage(event:MouseEvent):void {
conn.send("myConnection", "lcHandler", message.text);
}
private function onStatus(event:StatusEvent):void {
switch (event.level) {
case "status":
trace("LocalConnection.send() succeeded");
break;
case "error":
trace("LocalConnection.send() failed");
break;
}
}
private function buildUI():void {
const hPadding:uint = 5;
// messageLabel
messageLabel = new TextField();
messageLabel.x = 10;
messageLabel.y = 10;
messageLabel.text = "Text to send:";
messageLabel.autoSize = TextFieldAutoSize.LEFT;
addChild(messageLabel);
// message
message = new TextField();
message.x = messageLabel.x + messageLabel.width + hPadding;
message.y = 10;
message.width = 120;
message.height = 20;
message.background = true;
message.border = true;
message.type = TextFieldType.INPUT;
addChild(message);
// sendBtn
sendBtn = new Sprite();
sendBtn.x = message.x + message.width + hPadding;
sendBtn.y = 10;
var sendLbl:TextField = new TextField();
sendLbl.x = 1 + hPadding;
sendLbl.y = 1;
sendLbl.selectable = false;
sendLbl.autoSize = TextFieldAutoSize.LEFT;
sendLbl.text = "Send";
sendBtn.addChild(sendLbl);
sendBtn.graphics.lineStyle(1);
sendBtn.graphics.beginFill(0xcccccc);
sendBtn.graphics.drawRoundRect(0, 0,
(sendLbl.width + 2 + hPadding + hPadding), (sendLbl.height + 2), 5, 5);
sendBtn.graphics.endFill();
addChild(sendBtn);
}
}
}
// Code in LocalConnectionReceiverExample.as
package {
import flash.display.Sprite;
import flash.net.LocalConnection;
import flash.text.TextField;
public class LocalConnectionReceiverExample extends Sprite {
private var conn:LocalConnection;
private var output:TextField;
public function LocalConnectionReceiverExample() {
buildUI();
conn = new LocalConnection();
conn.client = this;
try {
conn.connect("myConnection");
} catch (error:ArgumentError) {
trace("Can't connect...the connection name is already
being used by another SWF");
}
}
public function lcHandler(msg:String):void {
output.appendText(msg + "\n");
}
private function buildUI():void {
output = new TextField();
output.background = true;
output.border = true;
output.wordWrap = true;
addChild(output);
}
}
}