soy nuevo en esto de AS3 y no soy programista pero me manejo un poco en codigo.
les explico el problema, estoy tratando de hacer un juego en flash con 2 moviclips (un hombre y una mujer).
en el cual pueden jugar 2 personas, anterior mente registradas en una lista.
como asignar a un moviclips , a un jugador segun su sexo (hombre o mujer)?
y en el caso que juegen dos hombres, como puedo asginar atravez de mi sprip dar filtros al mismo moviclip?
Nota. el juego funciona, con dos moviclip y con dos personajes y me muestra los nombres de las personas que juegan.
el pero lo que necesito es asignar un moviclip a un usuario segun su sexo... mmm.... hay ideas????
los moviclips, se llaman rabbidOne (que es el hombre) y rabbidTwo (que es la mujer)
aca les dejo el codigo de mi Script.
----------------
package {
import flash.display.*;
import flash.events.*;
import flash.text.*;
import flash.utils.*;
import flash.net.XMLSocket;
import flash.system.Security;
import com.adobe.serialization.json.*;
public class Fight extends MovieClip {
private var gamerId:int = 0;
private var fightId:int = 0;
private var gamerTimer:Timer;
private var socket:XMLSocket;
public function Fight() : void {
Security.loadPolicyFile("xmlsocket");
this.socket = new XMLSocket();
this.socket.connect(0000);
this.socket.addEventListener(Event.CONNECT, OnConnect);
this.socket.addEventListener(Event.CLOSE, OnClose);
this.socket.addEventListener(DataEvent.DATA, OnData);
this.socket.addEventListener(IOErrorEvent.IO_ERROR, OnError);
this.socket.addEventListener(SecurityErrorEvent.SECURITY_ERROR, OnError);
this.gamerTimer = new Timer(5000, 1);
this.gamerTimer.addEventListener(TimerEvent.TIMER_COMPLETE, OnGamerTimerComplete);
}
public function sendBlowCommand(event:MouseEvent) : void {
if (this.gamerTimer.running == false) {
this.gamerTimer.start();
indicator.gotoAndStop('disable');
this.sendCommand('blow', this.loaderInfo.parameters);
}
}
private function OnGamerTimerComplete(event:TimerEvent) : void {
indicator.gotoAndStop('enable');
}
public function sendCommand(command:String, commandData:*) : void {
if (this.socket.connected == true) {
var data:Object = new Object();
data[command] = commandData;
this.socket.send(JSON.encode(data) + '\n');
}
}
public function OnConnect(event:Event) : void {
this.gamerId = this.loaderInfo.parameters.gamerId;
this.fightId = this.loaderInfo.parameters.fightId;
this.sendCommand('connectToFight', this.loaderInfo.parameters);
fightText.text = 'Connected. Waiting for the second player...';
}
public function OnClose(event:Event) : void {
}
// received the command from the server
private function OnData(event:DataEvent):void {
try {
var id:String;
var data:Object = JSON.decode(event.data);
for (var command:String in data) {
switch (command) {
case 'begin':
fightText.text = 'Fight!';
indicator.gotoAndStop('enable');
rabbidTwo.addEventListener(MouseEvent.CLICK, sendBlowCommand);
break;
case 'health':
for (id in data.health) {
if (Number(id) == this.gamerId) {
rabbidOneHealth.text = data.health[id];
} else {
rabbidTwoHealth.text = data.health[id];
}
}
break;
case 'name':
for (id in data.name) {
if (Number(id) == this.gamerId) {
rabbidOneName.text = data.name[id];
} else {
rabbidTwoName.text = data.name[id];
}
}
break;
case 'animate':
var randomNum:Number = Math.floor(Math.random() * 2) + 1;
for (id in data.animate) {
if (Number(id) == this.gamerId) {
if (data.animate[id] == 'strike-blow' || data.animate[id] == 'receive-blow') {
data.animate[id] += randomNum.toString();
}
rabbidOne.gotoAndPlay(data.animate[id]);
} else {
if (data.animate[id] == 'strike-blow' || data.animate[id] == 'receive-blow') {
data.animate[id] += randomNum.toString();
}
rabbidTwo.gotoAndPlay(data.animate[id]);
}
}
break;
case 'error':
fightText.text = data.error;
break;
case 'end':
fightText.text = 'Game Over';
rabbidTwo.removeEventListener(MouseEvent.CLICK, sendBlowCommand);
break;
default:
break;
}
}
} catch (error:Error) {
trace('bad');
}
}
private function OnError(event:ErrorEvent):void {
fightText.text = event.text;
fightText.textColor = 0xFF0000;
}
}
