Page 1 of 1

Variable ObjectMessageRequest is not defined.

Posted: 10 Feb 2012, 03:50
by Lokos
Hi all,

Well, since its my first post quick Intro : I've been using the smartfox Tools and applications for now a year, and Im loving it, nice to use, and the docs are greatly detailed.

Only now i have a little problem i haven't been able to get myself rid of now. Well my game was working fine until yesterday when i couldnt send any request
through ObjectMessageRequest for i would get this error :

Code: Select all

ReferenceError: Error #1065: Variable ObjectMessageRequest is not defined.
	at com.scenes::GameScene/handleObject()
	at com.scenes::GameScene/runGame()
UPDATE : I have checked the Strict Mode and this is the new Error code i get at Debug :

Code: Select all

ReferenceError: Error #1065: Variable com.smartfoxserver.v2.requests::ObjectMessageRequest is not defined.
	at com.scenes::GameScene/handleObject()
	at com.scenes::GameScene/runGame()

Could it imply that the API I have possess a flaw in the declaration of the ObjectMessageRequest constructo
r ?

Now I have applied all the solutions I could think of such as verifying all my classes declarations, and

Code: Select all

import com.smartfoxserver.v2.requests.*;
is definitively present. It does not come from a typo error since all the rest of my script runs fine only when it comes to movement of the character, done by mouse, where the pathfinder works but impossible to send any data to the server because of the above cited problem.

Code: Select all

		private function handleObject(ob:*, type:String) {
			var sfmov:ISFSObject = new SFSObject();
			var moveOb:Object = new Object();
			
			switch (type)
			{
				case "Send" :
					sfmov.putInt("px", ob.px);
					sfmov.putInt("py", ob.py);
					sfmov.putInt("dirx", ob.dirx);
					sfmov.putInt("diry", ob.diry);
					sfmov.putInt("sprNum", ob.sprNum);
					sfmov.putIntArray("anim", ob.anim);
					refDocument.smartFox.send(new ObjectMessageRequest(sfmov));
					break;
					
				case "Receive" :
					moveOb.px = ob.getInt("px");
					moveOb.py = ob.getInt("py");
					moveOb.dirx = ob.getInt("dirx");
					moveOb.diry = ob.getInt("diry");
					moveOb.sprNum = ob.getInt("sprNum");
					moveOb.anim = ob.getIntArray("anim");
					return moveOb;
			}
		
}
I verified every file i have in my project and they all possess the necessary Public tag. After further research I have come to the conclusion that maybe, in my SWC the ObjectMessageRequest is not declared as Public, which is preposterous, since if it was the case, i wouldnt be alone having this problem. I have tried downloading several others version of the AS3 api, and found the same problem which leads me to think that I may have either a code problem, or the migration from CS4 to CS5 has not gone down as smoothly as I had hoped and something went wrong somewhere, but I can't still pinpoint it.


Does anybody has an idea on the how to fix this please ? Thank you very much for your time and attention!

_____________________
I want to mention too that i have the latest RC3 patch as well as the latest AS3 API patch.

Posted: 11 Feb 2012, 13:03
by rjgtav
Hi.

Well, I'm not managing to reproduce that error... I created a simple app, and it works... I'm using the 0.9.17 API (retrieved from smartfox.version property). Here's my app:

Code: Select all

import com.smartfoxserver.v2.SmartFox;
import flash.text.TextField;
import flash.text.TextFormat;
import flash.utils.getTimer;
import com.smartfoxserver.v2.core.SFSEvent;
import com.smartfoxserver.v2.requests.LoginRequest;
import com.smartfoxserver.v2.requests.LogoutRequest;
import flash.utils.Timer;
import flash.events.TimerEvent;
import com.smartfoxserver.v2.requests.ObjectMessageRequest;
import com.smartfoxserver.v2.entities.data.ISFSObject;
import com.smartfoxserver.v2.entities.data.SFSObject;
import com.smartfoxserver.v2.requests.JoinRoomRequest;

const SERVER_IP:String = "127.0.0.1"
const SERVER_PORT:int = 9933
const ZONE_NAME:String = "SimpleChat"

var timer:Timer;

var logTxt:TextField = new TextField();
logTxt.width = logTxt.height = 300;
logTxt.wordWrap = true;
logTxt.multiline = true;
logTxt.selectable = false;
logTxt.defaultTextFormat = new TextFormat("arial", 12, 0);
addChild(logTxt);

var smartfox:SmartFox = new SmartFox();
smartfox.addEventListener(SFSEvent.CONNECTION, onConnection);
smartfox.addEventListener(SFSEvent.CONNECTION_LOST, onConnectionLost);
smartfox.addEventListener(SFSEvent.LOGIN, onLogin);
smartfox.addEventListener(SFSEvent.LOGIN_ERROR, onLoginError);
smartfox.addEventListener(SFSEvent.ROOM_JOIN, onJoinRoom);

log("[API Version: "+smartfox.version+"]")
log("Connecting...")
smartfox.connect(SERVER_IP, SERVER_PORT);

function onConnection(e:SFSEvent){
	log("=== CONNECTED ===")
	smartfox.send(new LoginRequest("", "", ZONE_NAME));
}

function onConnectionLost(e:SFSEvent){8
	log("=== DISCONNECTED ===");
	log("reason: " + e.params.reason);
}

function onLogin(e:SFSEvent){
	log("> Logged in!");
	smartfox.send(new JoinRoomRequest("The Lobby"));
}

function onJoinRoom(e:SFSEvent){
	log("> Joined Room: "+e.params.room.name)
	startObjectMessageTimer();
}

function onLoginError(e:SFSEvent){
	log("> Loggin Failed!: " + e.params.errorMessage);
}

function startObjectMessageTimer(){
	timer = new Timer(1000, 0);
	timer.addEventListener(TimerEvent.TIMER, sendObjectMessage);
	timer.start();
}

function sendObjectMessage(e:TimerEvent){
	var obj:ISFSObject = new SFSObject();
	log("sending object message")
	smartfox.send(new ObjectMessageRequest(obj));
}

function log(msg:String){
	logTxt.htmlText += "[" + getTimer() + "] " + msg + "<br>";
	logTxt.scrollV = logTxt.maxScrollV;
}

Posted: 13 Feb 2012, 16:11
by Lokos
Hi rjgtav, thank you very much for your input.

I have used your sample program, and since then put it as
a favorite for Smartfox commands testing. Thank you it is very useful.
Indeed i have been able to send several ObjectMessageRequest through
your application. Therefore I have been able to draw the conclusion that
my suspicions were founded, I have a corrupted project.

The story is simple I had backed up the class files since the CS4 Era on a remote server but had forgotten to back the .fla project itself. Therefore i found myself obliged to use a decompiler on my latest working swf in order to obtain back all my components, assets and files in order not to start from scratch. But it seems that the Flash CS5 project I have been able to create based on the classes I had and the decompiled components have been providing this error.

Funny enough, I have been able to debug everything expect that up to now. Therefore I have been up to now restarting from scratch at the exeption that now, I will not use any ObjectMessageRequest anymore for the character movement but a server-side extension that will handle the
pathfinding and movement protocols and send it back to the client.

It was my plan from the beginning but I wanted it to work first on client-side before going to it. Only with the past few days frustration on not being able to get rid of that reference error. I will speed up the process and go directly onto Server side extension codding.

Of course, i'll still be trying to debug the reference error so that I may post a solution. My last solution will be to apply the method explained here : .http://stackoverflow.com/questions/6282 ... y-debugger (Disclaimer: I do not know if external links are allowed.)Thank you again for your help and attention !
________________________________________
PS: Sorry for the long text. I could have maybe trimmed it down, but im not good at doing so.

Posted: 13 Feb 2012, 18:15
by rjgtav
Hmm... Interesting... Never got into those errors (hopefully)... Well, good luck with that, and if you find a solution, don't forget to share it :P

Happy coding :)