Error #1010 in actionscript code - actionscript-3

In code:
override public function stateEventNewPlayer(param1:Player) : void
{
this.menu.chatView.log("* " + param1.name + " has joined");
this.menu.refreshPlayers();
Sounds.join.play();
dispatchEvent(new InGameChatSendMessageEvent("test"));
}
i have an error:
TypeError: Error #1010: A term is undefined and has no properties.
at gamecode.controllers::NetGameHost/onMessageReceived()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at basnet::BasNetPeer/onMessageReceived()
First three lines works correctly but when i added fourth line I get an error.
Error causes the line:
dispatchEvent(new InGameChatSendMessageEvent("test"));
Code:
override public function onMessageReceived(param1:MessageEvent) : void
{
var _loc3_:* = null as ByteArray;
var _loc4_:uint = 0;
var _loc5_:* = null as RemovePlayerAction;
super.onMessageReceived(param1);
try
{
_loc3_ = param1.data;
_loc4_ = uint(_loc3_.readUnsignedByte());
...
return;
}
break loop0;
}
Please help.
Greetings.

Set "permit debugging" to true and in the stack trace you will also see the line number to which the error happens. This helps really a lot.

Related

phpunit expectException() wrong exception name

When I run PHPUnit 6.5.13. and have a test method following this example PHPUnit Testing Exceptions Documentation
public function testSetRowNumberException()
{
$this->expectException(\InvalidArgumentException::class);
$result = $this->tableCell->setRowNumber('text');
}
that tests this method:
public function setRowNumber(int $number) : TableCell
{
if (!is_int($number)) {
throw new \InvalidArgumentException('Input must be an int.');
}
$this->rowNumber = $number;
return $this;
}
I got this failure:
Failed asserting that exception of type "TypeError" matches expected exception "InvalidArgumentException".
the question is why "TypeError" is taken to assertion and how to make assertion use InvalidArgumentException?
Got it. The thing is I used typing set to int that's why the code didn't even reach the thow command.
it works if tested method is without set typing to int:
public function setRowNumber($number) : TableCell
{
if (!is_int($number)) {
throw new \InvalidArgumentException('Input must be an int.');
}
$this->rowNumber = $number;
return $this;
}
or when the test has TypeError
public function testSetRowNumberException()
{
$this->expectException(\TypeError::class);
$result = $this->tableCell->setRowNumber('text');
}
I'll stay with the second example.

Java Service Error - webMethods

In a java service, without a function declaration, a function call is there and only compile time error comes. But the output is as expected with no run time errors. How is that possible? Can anyone please explain?
"The method functionName() is undefined" is the error it shows.
Below is the code.
public static final void documentToStringVals(IData pipeline)
throws ServiceException {
// pipeline
IDataCursor pipelineCursor = pipeline.getCursor();
String success = "false";
IData inputDoc = null;
String outputValue = "";
String headerYN = "N";
boolean headerValue = false;
String delimiter = ",";
String newline = System.getProperty("line.separator");
if (pipelineCursor.first("inputDocument") ) {
inputDoc = (IData) pipelineCursor.getValue();
}
else {
throw new ServiceException("inputDocument is a required parameter");
}
if (pipelineCursor.first("delimiter") ) {
delimiter = (String) pipelineCursor.getValue();
}
if (pipelineCursor.first("headerYN") ) {
headerYN = (String) pipelineCursor.getValue();
}
if (headerYN.equalsIgnoreCase("Y")) {
headerValue = true;
}
try {
outputValue = docValuesToString(inputDoc, headerValue, delimiter);
outputValue += newline;
success = "true";
}
catch (Exception e) {
System.out.println("Exception in getting string from document: " + e.getMessage());
pipelineCursor.insertAfter("errorMessage", e.getMessage());
}
pipelineCursor.insertAfter("success", success);
pipelineCursor.insertAfter("outputValue", outputValue);
pipelineCursor.destroy();
}
The code you posted has no reference to "functionName", so I suspect there's a reference to it either in the shared code section or in another Java service in the same folder. Given that all Java services in a folder get compiled into a single class, and therefore all those services need to be compiled together, this could cause the error message when you're compiling the service above.

actionscript 3 :error. type coercion failed

I am getting following error when trying to simulate CalendarLayoutChangeEvent on a DateField object.
cannot convert
mx.events::CalendarLayoutChangeEvent#feb667 to
mx.events.CalendarLayoutChangeEvent
I am dispatching events on swf's which are loaded at runtime.
any help will be appreciated.
private function setDateField(child:Object, dateString:String):String
{
child.selectedDate = compileDateValue(dateString,child.formatString);
var changeEvent:CalendarLayoutChangeEvent = new CalendarLayoutChangeEvent("change", true, false, null, new Event("change"));
var retval:String;
try
{
retval = String(child.dispatchEvent(changeEvent));
}
catch(e:Error)
{
trace(e);
}
return retval;
}

RED5 - cannot call RED5 method/ function from flash client Air for IOS

I have a NetConnection in flash client that connects to the RED5 server with no problems but when i want to call a RED5 method/ function i keep get this error:
I have set the nc.client = this, but still i get an error.
ReferenceError: Error #1069: Property perform not found on HUGT and there is no default value.
Error #2044: Unhandled AsyncErrorEvent:. text=Error #2095: flash.net.NetConnection was unable to invoke callback perform. error=ReferenceError: Error #1069: Property perform not found on HUGT and there is no default value.
at HUGT/setUpRed5Connection()[/Users/trikampatel/Documents/fb/HUGT.as:89]
at HUGT/onAddedToStage()[/Users/trikampatel/Documents/fb/HUGT.as:175]
The code I'm using is below:
private function setUpRed5Connection(){
nc = new NetConnection();
nc.client = this;
nc.connect("rtmp://192.168.1.4/RED5Hugt");
nc.addEventListener(NetStatusEvent.NET_STATUS,getStream);
}
public function onBWCheck(...rest):Number
{
return 0;
}
public function onBWDone(...rest):void
{
var p_bw:Number;
if (rest.length > 0){
p_bw = rest[0];
}
trace("bandwidth = " + p_bw + " Kbps.");
}
function getStream(e:NetStatusEvent):void
{
//connectCamera();
nsIn = new NetStream(nc);
nsOut = new NetStream(nc);
//vid.attachNetStream(nsIn);
//nsIn.play("tester");
//nsOut=new NetStream(nc);
//netOut.attachAudio(mic);
//nsOut.attachCamera(cam);
//nsOut.publish("tester", "live");
}
public function performSend(country:String, uid:String):void{
trace("cdcdcdcdcdcdcdcdcdcdc");
var nr:Responder = new Responder(netResponderHandler);
nc.call("perform", nr, uid, country);
}
function netResponderHandler(serverResult:Object)
{
trace("The result is " + serverResult);
}
RED5 server:
public long perform(Object[] params){
System.out.println((String)params[0] + " " + (String) params[1]);
User u = this.getCountryPerformer(country).getUser(uid);
long yt = u.ticket;
return yt;
}
UPDATE
Unusual behaviour now, i created a perform function in my action script class and the nc.call("perform", nr, val, val2) is calling the perform method in my action script class rather than the perform method in the red5 application adapter class, here is the function i created that gets called in the action script:
public function perform(obj:Object, obj2:Object){
trace("dzddzdzd");
}

error 1084 in as3: expecting rightbrace before leftbracket

cant find the error. needless to say that I am a newb. Any help would be highly apreciated
public function setDestination(param1:String, param2, param3:Boolean = true) : void
{
var _loc_4:* = {};
{}[param1] = param2;
updateTo(_loc_4, param3);
return;
}// end function
Your error is related to this line:
{}[param1] = param2;
Though I can't be sure of what was actually intended here, it may have been this:
_loc_4[param1] = param2;