Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 10-21-2009, 02:44 PM   #1
zsolemolina
Member
 
Join Date: Apr 2008
Posts: 67
Red face Loader don't get the complete movieclip (chat)....

Hi there!
I'm having troubles with a external movieclip(chat), using a loader to call it. I ve a Role Game and when i make click over a button, it calls this external chat and all it's ok with him but the login button.. This chat, has their own classes and packages ( really I'm reclying a code of Gil Beyruth, multiplayer game) and when I play just the chat ( localhost/chat.swf) works ok... but when I open it from my main movie ( localhost/game.swf) by means a Loader, the login button( chat) appears disabled... Any ideas?


I was reading about this on http://www.insideria.com/2008/07/the...ctionscri.html but i think it's not my case... beacause all functionalities about move, close, stop this chat inside my main movie, works ok...it's seems like the chat functions doesn't exists...
zsolemolina is offline   Reply With Quote
Old 10-21-2009, 03:23 PM   #2
EvLSnoopY
Freshman ActionScript Dev
 
EvLSnoopY's Avatar
 
Join Date: Jun 2009
Location: Edmond, OK
Posts: 345
Default

I'm having a hard time following you. Could you post up the code that is causing the problem for you?
__________________
JynxStudio
"Knowledge is power."
"Show no fear in the face of adversity."
Please use the [ as ][ /as ] tags for your code.
EvLSnoopY is offline   Reply With Quote
Old 10-21-2009, 03:39 PM   #3
zsolemolina
Member
 
Join Date: Apr 2008
Posts: 67
Default

Hi, thanks for you help!
OK..here is the code(just a bit):

About CHAT: main.as
Code:

package 
{
	import flash.events.EventDispatcher;
	import flash.events.Event;
	import flash.text.*;
	import flash.net.*;
	import flash.events.*;
	import flash.display.*;
	import flash.utils.*;
	import com.firstpixel.multiuser.*
	import com.firstpixel.utils.*
	import com.firstpixel.*;
	import com.firstpixel.multiuser.soccergame.*;
	import fl.controls.TextArea;
	import fl.controls.DataGrid;
	
	public class Chat extends MovieClip
	{
		private var lobbyRoomConnection:ServerConnection;
		private var lobby:Lobby;
		private var room:Room;
		private var connecting:Boolean = false;
		private var connected:Boolean = false;
		private var username:String;
		private var password:String;
		
		//private var loginRoom:LoginRoom;
		
		public function Chat():void
		{

			//listen for load event
			addEventListener("loadComplete",loadCompleteHandler);
			addEventListener("startLobbyEvent",onStartLobbyHandler);
			addEventListener("startGameEventChat",onStartGameHandler);
			addEventListener("onReadyToLoginGameEvent",onReadyToLoginGameHandler);
		}
		private function loadCompleteHandler(evt:Event):void
		{
			lobbyRoomConnection = new ServerConnection("lobby");
			lobbyRoomConnection.addEventListener("onLoginSuccessEvent",onLoginSuccessHandler);
			lobbyRoomConnection.addEventListener("onLoginFailedEvent",onLoginFailedHandler);
			lobbyRoomConnection.addEventListener("onLoginRejectedEvent",onLoginRejectedHandler);
			lobbyRoomConnection.addEventListener("onLoginClosedEvent",onLoginClosedLobbyHandler);

			login_mc.addEventListener("onReadyToLoginLobbyEvent",onReadyToLoginLobbyHandler);
			login_mc.addEventListener("onPasswordLobbyErrorEvent",onPasswordErrorHandler);
			login_mc.addEventListener("onUsernameLobbyErrorEvent",onUsernameErrorHandler);
		
		}
		
		private function onUsernameErrorHandler(evt:Event):void
		{
			trace("username error")
		}
		private function onPasswordErrorHandler(evt:Event):void
		{
			trace("password error")
		}
		public function onLogoutLobbyHandler(evt:Event):void{
			lobbyRoomConnection.close();
			gotoAndPlay("login")
		}
		public function onCloseLobbyToGameHandler(evt:Event):void{
			lobbyRoomConnection.close();
			dispatchEvent(new Event("onReadyToLoginGameEvent"))
		}
		public function onCloseGameToLobbyHandler(evt:Event):void{
			dispatchEvent(new Event("onReadyToLoginLobbyHandler"));
		}
		
		public function onReadyToLoginLobbyHandler(evt:Event):void
		{
			trace("READY TO LOGIN LOBBY")
			if(!connecting){
				if(evt.target is Login){
					username = Login.username;
					password = Login.password;
				}
				/*if(evt.target is Guest){
					username = Guest.username;
					password = null;
				}*/
				connecting = true;
				connected = false;
				
				lobbyRoomConnection.type = "lobby";
				lobbyRoomConnection.removeEventListener("onLoginClosedEvent",onReadyToLoginLobbyHandler);
				lobbyRoomConnection.addEventListener("onLoginClosedEvent",onLoginClosedLobbyHandler);
				//Change the host when put the app to final server
				//lobbyRoomConnection.connect("rtmp://localhost/lobby_rooms/lobby", undefined, username, password, "lobby");
				lobbyRoomConnection.connect("rtmp://10.100.160.130/Game/lobby_rooms/lobby", undefined, username, password, "lobby");

				
			}
		}
		public function onReadyToLoginGameHandler(evt:Event):void
		{
			trace("READY TO LOGIN LOBBY")
			if(!connecting){
				lobbyRoomConnection.removeEventListener("onLoginClosedEvent",onLoginClosedLobbyHandler);
				lobbyRoomConnection.addEventListener("onLoginClosedEvent",onReadyToLoginLobbyHandler);
				connecting = true;
				connected = false;
				lobbyRoomConnection.type = "room";
				//Change the host when put the app to final server
				lobbyRoomConnection.connect("rtmp://10.100.160.130/Game/lobby_rooms/"+lobby.selectedRoom.rtmp, undefined, username, password, lobby.selectedRoom.rtmp);
				
}
		}
		private function onLoginSuccessHandler(evt:Event):void
		{
			gotoAndStop(evt.currentTarget.type);
			connecting = false;
			connected = true;
		}
		private function onStartLobbyHandler(evt:Event):void
		{
			lobby = new Lobby(lobbyRoomConnection.netConnection);
			addChild(lobby);
			lobby.addEventListener("netConnectionMissing",onNetConnectionMissing);
			lobby.addEventListener("onCloseLobbyToGameEvent",onCloseLobbyToGameHandler);
			lobby.addEventListener("onLogoutLobbyEvent",onLogoutLobbyHandler);
		}		
		private function onStartGameHandler(evt:Event):void
		{
			
			lobby.removeEventListener("netConnectionMissing",onNetConnectionMissing);
			lobby.removeEventListener("onCloseLobbyToGameEvent",onCloseGameToLobbyHandler);
			lobby.removeEventListener("onLogoutLobbyEvent",onLogoutLobbyHandler);
			removeChild(lobby);
			lobby = null;
			room = new Room(lobbyRoomConnection.netConnection);
			addChild(room);
			room.addEventListener("netConnectionMissing",onNetConnectionMissing);
			room.addEventListener("onCloseGameEvent",onCloseGameToLobbyHandler);
			room.addEventListener("onLogoutGameEvent",onLogoutLobbyHandler);
			
		}		
		private function onNetConnectionMissing(evt:Event):void
		{
			connecting = false;
			connected = false
			gotoAndPlay("loaded");
		}

		private function onLoginFailedHandler(evt:Event):void
		{
			connecting = false;
			connected = false;
		}
		private function onLoginRejectedHandler(evt:Event):void
		{
			connecting = false;
			connected = false
		}
		private function onLoginClosedHandler(evt:Event):void
		{
			trace("ROOM CLOSED")
			if(lobbyRoomConnection.type=="room"){
				
				dispatchEvent(new Event("onReadyToLoginLobbyHandler"))
				gotoAndStop("lobby");
			}
			//connecting = false;
			//connected = false
			//gotoAndPlay("loaded");
		}
		
		private function onLoginClosedLobbyHandler(evt:Event):void
		{
			trace("LOGIN CLOSED EVENT")
			connecting = false;
			connected = false;
			
		}
	}
}

about Game: Main.as
Code:
package{
	import flash.events.*;
	import flash.display.*;
	import caurina.transitions.*;
	import flash.text.*;
	import flash.net.*;
	import flash.utils.*;
	import flash.events.*;
	/*import com.firstpixel.multiuser.*
	import com.firstpixel.utils.*;
	import com.firstpixel.*;
	import com.firstpixel.multiuser.soccergame.*;*/
	import fl.controls.TextArea;
	import fl.controls.DataGrid;
	import fl.events.*;
	import fl.controls.*;
	//import es.isdefe.game.Callback; 
	
	public class Main2 extends MovieClip
	{
		// Conexion
		public static var ncx:NetConnection;
public function Main():void
		{
			addEventListener("startMyGame",onStartMyGame);
		}
		
		public function onStartMyGame(evt:Event):void{
			ncx = new NetConnection();
			ncx.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler);
			ncx.connect("rtmp://10.100.160.130/Game");
			ncx.client = new Object();
			ncx.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);			
		}
		
		function asyncErrorHandler(event:AsyncErrorEvent):void { 
            trace(event.text); 
        }
		
		public function netStatusHandler(event:NetStatusEvent):void
        {
            trace("connected is: " + ncx.connected );
			trace("event.info.level: " + event.info.level);
			trace("event.info.code: " + event.info.code);
			
.......etc etce etc
later i've another code..it doesn' matter..

about FLASH movie:
Code:
var url1:URLRequest = new URLRequest("chat.swf");
chatLoader.contentLoaderInfo.addEventListener(Event.INIT, initChatAU1);
chatLoader.load(url1);
     }




function initChatAU1(e:Event) {
addChild(chatLoader);
chatLoader.content.x = 500;
chatLoader.content.y = 100;
      }

Previously i declares the var charLoader... And just test whit Complete Event...and it's the same problem..

Thanks for your help!
zsolemolina is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 03:20 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.