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 6102011
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:33:56+00:00 2026-05-23T13:33:56+00:00

I have a java socket server that sends an Animal object to the Flash

  • 0

I have a java socket server that sends an Animal object to the Flash client when it connects.
The object is sent like this:

Amf3Output amf3Output = new Amf3Output(SerializationContext.getSerializationContext());
amf3Output.setOutputStream(userSocket.getOutputStream());
amf3Output.writeObject(animal);

And the code on flash side is:

var object:Object = socket.readObject();
trace(object);
trace(object as Animal);

However when the second trace gives me a null

I have checked that java sends out 31 bytes and Flash receives 31 bytes.

I think it might be that my Java and AS3 classes don’t match some AMF requirement.

Java class:

package main;

public class Animal {

   public String name;
   public int age;
}

AS3 class:

package  
{

    [Bindable]
    [RemoteClass(alias="main.Animal")]
    public class Animal 
    {
        public var name:String;
        public var age:int;

    }

}
  • 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-23T13:33:57+00:00Added an answer on May 23, 2026 at 1:33 pm

    I’m not familiar with Java and the AMF serializers/deserializers available for it, but sending typed objects over sockets is indeed supported in flash, and works properly if you send the right data. Below is an example of a socket server in ruby communicating with a Flash application. I’m using RocketAMF to send an AMF3 object over the socket to a client after it connects.

    SocketTest.as:

    package {
        import flash.display.Sprite;
        import flash.net.registerClassAlias;
        import org.rackAMF.*;
        import flash.net.Socket;
        import flash.events.*;
    
        public class SocketTest extends Sprite {
            private var socket:Socket;
    
            public function SocketTest() {
                registerClassAlias('Animal', Animal);
    
                socket = new Socket();
                socket.addEventListener(ProgressEvent.SOCKET_DATA, onResponse);
                socket.connect("localhost", 8081);
            }
    
            private function onResponse(e:ProgressEvent):void {
                var animal:Animal = socket.readObject() as Animal;
                trace(Object(animal).constructor); // [trace] [class Animal]
                trace(animal.name); // [trace] Zebra
                trace(animal.age); // [trace] 5
            }
        }
    }
    
    class Animal {
        public var name:String;
        public var age:int;
    }
    

    socket_server.rb:

    require 'rubygems'
    require 'socket'
    require 'rocketamf'
    
    class Animal
      attr_accessor :name, :age
    end
    
    # Map "Animal" in ruby to "Animal" in flash
    RocketAMF::ClassMapper.define do |m|
      m.map :as => 'Animal', :ruby => 'Animal'
    end
    
    server = TCPServer.open(8081)
    loop {
      client = server.accept
    
      animal = Animal.new
      animal.name = "Zebra"
      animal.age = 5
      client.write RocketAMF.serialize(animal, 3)
    
      client.close
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following Java socket client app, that sends same string to socket
I have a Java Client which sends UTF-8 strings to a C# TCP-Server, I'm
Java Socket Server I have a Java process that is creating a listener on
I have a big issue with my java client. Server: perl, with IO::Socket; $n
Hey all. I have a server written in java using the ServerSocket and Socket
I have Java and Flash client applications. What is the best way for the
Essentially I have built a socket server that multiple clients can connect to and
From this rpg socket tutorial we created a socket client in rpg that calls
I do have a java server. I am trying to build IPhone application that
I have created a basic Client Server that will send image files in a

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.