Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 765925
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T16:57:48+00:00 2026-05-14T16:57:48+00:00

I am trying to create a custom object in AS3 to pass information to

  • 0

I am trying to create a custom object in AS3 to pass information to and from a server, which in this case will be Red5. In the below screenshots you will see that I am able to send a request for an object from as3, and receive it successfully from the java server. However, when I try to cast the received object to my defined objectType using ‘as’, it takes the value of null. It is my understanding that that when using “as” you’re checking to see if your variable is a member of the specified data type. If the variable is not, then null will be returned.

This screenshot illustrates that I am have successfully received my object ‘o’ from red5 and I am just about to cast it to the (supposedly) identical datatype testObject of LobbyData:

alt text
Enlarge

However, when testObject = o as LobbyData; runs, it returns null. 🙁

alt text
Enlarge

Below you will see my specifications both on the java server and the as3 client. I am confident that both objects are identical in every way, but for some reason flash does not think so. I have been pulling my hair out for a long time, does anyone have any thoughts?

AS3 Object:

import flash.utils.IDataInput;
 import flash.utils.IDataOutput;
 import flash.utils.IExternalizable;
 import flash.net.registerClassAlias; 

 [Bindable]
 [RemoteClass(alias = "myLobbyData.LobbyData")]
 public class LobbyData implements IExternalizable
 { 

 private var sent:int; // java sentinel
 private var u:String; // red5 username
 private var sen:int; // another sentinel?
 private var ui:int;  // fb uid
 private var fn:String; // fb name
 private var pic:String; // fb pic
 private var inb:Boolean; // is in the table?
 private var t:int; // table number
 private var s:int; // seat number

 public function setSent(sent:int):void 
 {
  this.sent = sent;
 }

 public function getSent():int
 {
  return sent;
 }  

 public function setU(u:String):void
 {
  this.u = u;
 }

 public function getU():String
 {
  return u;
 }  

 public function setSen(sen:int):void
 {
  this.sen = sen;
 }

 public function getSen():int
 {
  return sen;
 }  

 public function setUi(ui:int):void
 {
  this.ui = ui;
 }

 public function getUi():int
 {
  return ui;
 }

 public function setFn(fn:String):void
 {
  this.fn = fn;
 }

 public function getFn():String
 {
  return fn;
 }

 public function setPic(pic:String):void
 {
  this.pic = pic;
 }

 public function getPic():String
 {
  return pic;
 }  

 public function setInb(inb:Boolean):void
 {
  this.inb = inb;
 }

 public function getInb():Boolean
 {
  return inb;
 }  

 public function setT(t:int):void
 {
  this.t = t;
 }

 public function getT():int
 {
  return t;
 }

 public function setS(s:int):void
 {
  this.s = s;
 }

 public function getS():int
 {
  return s;
 }

 public function readExternal(input:IDataInput):void
 {
  sent = input.readInt();
  u = input.readUTF();
  sen = input.readInt();
  ui = input.readInt();
  fn = input.readUTF();
  pic = input.readUTF();
  inb = input.readBoolean();
  t = input.readInt();
  s = input.readInt();  
 }


 public function writeExternal(output:IDataOutput):void
 {
  output.writeInt(sent);
  output.writeUTF(u);
  output.writeInt(sen);
  output.writeInt(ui);
  output.writeUTF(fn);
  output.writeUTF(pic);
  output.writeBoolean(inb);
  output.writeInt(t);
  output.writeInt(s);
 }
    }

Java Object:

    package myLobbyData;
    import org.red5.io.amf3.IDataInput;
    import org.red5.io.amf3.IDataOutput;
    import org.red5.io.amf3.IExternalizable;




    public class LobbyData implements IExternalizable
    {
 private static final long serialVersionUID = 115280920;

 private int sent; // java sentinel
 private String u; // red5 username
 private int sen; // another sentinel?
 private int ui;  // fb uid
 private String fn; // fb name
 private String pic; // fb pic
 private Boolean inb; // is in the table?
 private int t; // table number
 private int s; // seat number

 public void setSent(int sent)
 {
  this.sent = sent;
 }

 public int getSent()
 {
  return sent;
 }  

 public void setU(String u)
 {
  this.u = u;
 }

 public String getU()
 {
  return u;
 }  

 public void setSen(int sen)
 {
  this.sen = sen;
 }

 public int getSen()
 {
  return sen;
 }  

 public void setUi(int ui)
 {
  this.ui = ui;
 }

 public int getUi()
 {
  return ui;
 }

 public void setFn(String fn)
 {
  this.fn = fn;
 }

 public String getFn()
 {
  return fn;
 }

 public void setPic(String pic)
 {
  this.pic = pic;
 }

 public String getPic()
 {
  return pic;
 }  

 public void setInb(Boolean inb)
 {
  this.inb = inb;
 }

 public Boolean getInb()
 {
  return inb;
 }  

 public void setT(int t)
 {
  this.t = t;
 }

 public int getT()
 {
  return t;
 }

 public void setS(int s)
 {
  this.s = s;
 }

 public int getS()
 {
  return s;
 }



 @Override
 public void readExternal(IDataInput input) 
 {
  sent = input.readInt();
  u = input.readUTF();
  sen = input.readInt();
  ui = input.readInt();
  fn = input.readUTF();
  pic = input.readUTF();
  inb = input.readBoolean();
  t = input.readInt();
  s = input.readInt();  
 }

 @Override
 public void writeExternal(IDataOutput output)
 {
  output.writeInt(sent);
  output.writeUTF(u);
  output.writeInt(sen);
  output.writeInt(ui);
  output.writeUTF(fn);
  output.writeUTF(pic);
  output.writeBoolean(inb);
  output.writeInt(t);
  output.writeInt(s);
 }

    }

AS3 Client:

public function refreshRoom(event:Event)
{
var resp:Responder=new Responder(handleResp,null);
ncLobby.call("getLobbyData", resp, null);
}
public function handleResp(o:Object):void
{
var testObject:LobbyData=new LobbyData;    
testObject = o as LobbyData;  
trace(testObject);
}

Java Client

 public LobbyData getLobbyData(String param)
 {
LobbyData lobbyData1 = new LobbyData();
 lobbyData1.setSent(5);
 lobbyData1.setU("lawlcats");
 lobbyData1.setSen(5);
 lobbyData1.setUi(5);
 lobbyData1.setFn("lulz");
 lobbyData1.setPic("lulzagain");
 lobbyData1.setInb(true);
 lobbyData1.setT(5);
 lobbyData1.setS(5);
 return lobbyData1;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T16:57:48+00:00Added an answer on May 14, 2026 at 4:57 pm

    As you already figured out, you should use registerClassAlias as the RemoteClass works out of the box only for Flex projects (as bindable, etc).

    Be sure to call registerClassAlias before any serializing / deserializing occurs.

    Also, the debugger is showing you the actual tipe of your “o” parameter, which is object. This shows that the player is not correctly mapping the AMF serialized object’s class to any of your classes (so, by default, it goes with Object). You should see a LobbyData object in the debugger; otherwise, no matter how you cast / coerce it, it won’t work.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create a custom control - a button - which will have
I'm trying to create a custom JSP tag that would take an array object
I'm trying to create with Delphi a component inherited from TLabel, with some custom
I'm trying to create a custom object that behaves properly in set operations. I've
Hi I am trying to create a Custom Object in Salesforce.com Developer Edition, because
I'm trying to create an export Excel/CSV function that will iterate through a custom
I'm trying to create a custom query that will show the number of stories
I am trying to create a custom object that simply inherits the NSString class
I'm trying to create a new instance of a custom object inside a for
I am trying to create a new custom validation in which I can compare

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.