Copy link to clipboard
Copied
Hello guys I am working on a game but i get 1009 error
My Source Code:
package {
import flash.display.MovieClip
import flash.display.StageDisplayState;
import caurina.transitions.*;
import playerio.*
import flash.display.Loader;
import flash.events.MouseEvent;
import flash.events.KeyboardEvent;
import flash.events.Event;
import flash.display.*;
import flash.events.*;
import flash.media.*;
import flash.net.*;
import flash.text.*;
import flash.system.Security;
import flash.system.SecurityDomain;
//import flash.security.*;
import flash.display.Stage;
import flash.display.*;
import flash.events.*;
import flash.ui.*;
import flash.net.*;
import flash.utils.*;
import flash.system.*;
import flash.filters.*;
import flash.text.*;
import flash.media.*;
import flash.text.TextField;
import flash.utils.Timer;
import flash.events.TimerEvent;
import flash.ui.Keyboard;
import fl.transitions.Tween;
import fl.transitions.easing.*;
import flash.accessibility.Accessibility;
import flash.system.Security;
import com.freeactionscript.Scrollbar;
import flash.system.Security;
//import fl.controls.Button;
import flash.errors.MemoryError;
import flash.net.URLLoader;
import com.greensock.easing.Back;
import flash.external.*;
public class MyGame extends MovieClip{
private var TheClient;
private var TheConnection;
//private var loginsystem:Login;
function MyGame(){
stop();
PlayerIO.connect(
stage, //Referance to stage
"hill-climb-2-vdpuvptdpkesxpohf8sdiq", //Game id (Get your own at playerio.com)
"public", //Connection id, default is public
"user", //Username
"", //User auth. Can be left blank if authentication is disabled on connection
null, //Current PartnerPay partner.
handleConnect, //Function executed on successful connect
handleError //Function executed if we recive an error
//});
);
}
private function handleConnect(client:Client):void{
trace("Sucessfully connected to player.io");
//Set developmentsever (Comment out to connect to your server online)
client.multiplayer.developmentServer = "localhost:8184";
//Create pr join the room test
//username = username.text;
//password = password.text;
client.multiplayer.createJoinRoom(
"test", //Room id. If set to null a random roomid is used
"MyCode", //The game type started on the server
true, //Should the room be visible in the lobby?
{}, //Room data. This data is returned to lobby list. Variabels can be modifed on the server
{}, //User join data
handleJoin, //Function executed on successful joining of the room
handleError //Function executed if we got a join error
);
}
private function handleJoin(connection:Connection):void{
trace("Sucessfully connected to the multiplayer server");
//Add disconnect listener
connection.addDisconnectHandler(handleDisconnect);
//Add listener for messages of the type "hello"
connection.addMessageHandler("hello", function(m:Message){
trace("Recived a message with the type hello from the server");
gotoAndStop("log");
//startgame();
trace("loading buttons");
//inventory_btn.addEventListener(MouseEvent.CLICK, openInventory);
trace("loaded1");
register.addEventListener(MouseEvent.CLICK, lauchRocket2);
trace("loaded2");
function openInventory(event:MouseEvent):void {
TheConnection.send("login", username.text, pass.text);
}
function lauchRocket2(event:MouseEvent) {
gotoAndStop(4);
//reg.addEventListener(MouseEvent.CLICK,regi);
function regi(event:MouseEvent) {
TheConnection.send("reg", user.text, pass.text);
}
reg.addEventListener(MouseEvent.CLICK,regi);
}
})
connection.addMessageHandler("loggedin", function(m:Message)
{
gotoAndStop(5);
//}
})
connection.addMessageHandler("registered", function(m:Message)
{
gotoAndStop(5);
//}
})
//})
//Add message listener for users joining the room
connection.addMessageHandler("UserJoined", function(m:Message, userid:uint){
trace("Player with the userid", userid, "just joined the room");
})
//Add message listener for users leaving the room
connection.addMessageHandler("UserLeft", function(m:Message, userid:uint){
trace("Player with the userid", userid, "just left the room");
})
//Listen to all messages using a private function
connection.addMessageHandler("*", handleMessages)
}
private function handleMessages(m:Message){
trace("Recived the message", m)
}
private function handleDisconnect():void{
trace("Disconnected from server")
}
private function handleError(error:PlayerIOError):void{
trace("got",error)
gotoAndStop(3);
}
}
}
Error Line : 107 , 109
Can anyone help me please.
Ok I fixed it. The thing I did is move all of the objects codes and buttons to new files, and this didnt give me any error.
Copy link to clipboard
Copied
line 107 contains a reference to a non-existent object.
Copy link to clipboard
Copied
All of the buttons exist. All got the same instance names as in the code. When I Use "addChild" thingy it works, But I want it without that.
Copy link to clipboard
Copied
Ok I fixed it. The thing I did is move all of the objects codes and buttons to new files, and this didnt give me any error.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now