Basic help with redtamarin

34 views
Skip to first unread message

julifos

unread,
Mar 11, 2013, 4:52:37 PM3/11/13
to fc...@googlegroups.com
Hi everyone!

I'm new to redtamarin.

I'm trying to bring AS3 code to redtamarin and I must use some libraries which use sockets, http requests and so on. What would be the flow to compile such a code? I already had a hard time making work the "Hellow world" ;-)

I'm using Flash Builder and a bunch of .as files...

Thanks in advance!


jj

zwetan

unread,
Apr 9, 2013, 11:49:58 AM4/9/13
to fc...@googlegroups.com
Hi,

sorry for the delay I was busy and not really checking the group

by default redtamarin does not have the classic flash.net.Socket classes
(it is possible to emulate them but not done yet)

so you would want to use avmplus.Socket class
documented here


here an example implementing a socket policy server


in short, the Socket class impl. in redtamarin allow to do more stuff
but is a bit harder to use

the implementation is very close to the classic BSD socket in C/C++



now for the flow, here the 2 best way imho

1) implement the missing libraries from the Flash Platform
    see avmglue


for example
----
package flash.net
{
  public class Socket extends EventDispatcher implements IDataInput, IDataOutput
  {

    private var _sock:avmplus.Socket; //use the full package path

    public function Socket( host:String = null, port:int = 0 )
    {
        _sock = new avmplus.Socket();
    }

    public function connect(host:String, port:int):void
    {
        _sock.connect( host, port );
    }

  }
}
----

you would have to do your own wiring for the events

for ex
----
package flash.net
{
  public class Socket extends EventDispatcher implements IDataInput, IDataOutput
  {

    private var _sock:avmplus.Socket; //use the full package path

    public function Socket( host:String = null, port:int = 0 )
    {
        _sock = new avmplus.Socket();
        _hookCallbacks();
    }

    private function _onConnect():void
    {
      dispatchEvent( new Event( Event.CONNECT ) );
    }

    private function _hookCallbacks():void
    {
      _sock.onConnect = _onConnect;
    }


    public function connect(host:String, port:int):void
    {
        _sock.connect( host, port );
    }

  }
}
----

or
2) use conditional compilation
see


this allow you to keep the different implementations in the same file
and can be more desirable in some cases

cheers,
zwetan
Reply all
Reply to author
Forward
0 new messages