Skip to main content
Participating Frequently
January 26, 2008
Question

Bitmapdata + Flash Media Server 3

  • January 26, 2008
  • 7 replies
  • 733 views
I could not make streaming bitmapdata using Flash Media Server 3.

I am using the default connection, and continues giving the same issue of conversion.

This code:

private function init():void
{
if(nc){
nc.close()
}
nc = new NetConnection();
NetConnection.defaultObjectEncoding = flash.net.ObjectEncoding.AMF3;
nc.addEventListener( NetStatusEvent.NET_STATUS, netStatus );
nc.connect("rtmp://localhost/fmsdemo/demo", "demo");
}

private function netStatus( event:NetStatusEvent ):void
{
switch( event.info.code ) {
case "NetConnection.Connect.Success":
_labelStatus.text = "Status: Conexão realizada com sucesso!";

nc.client = this;

users_so = SharedObject.getRemote("users_so", nc.uri, true);
users_so.addEventListener( SyncEvent.SYNC, usersSyncHandler );
users_so.connect( nc );
users_so.client = this;
break;
}

    This topic has been closed for replies.

    7 replies

    egenialAuthor
    Participating Frequently
    January 31, 2008

    Hi,

    Yes, I am willing to send the screen of the tool by stream, I believe that the adobe restricted the bitmapdata :(

    Participant
    January 31, 2008
    Carlos,

    Not sure about bytearray conversion and all but are you trying to send screen over fms?
    egenialAuthor
    Participating Frequently
    January 30, 2008

    Does anyone have any tips?

    How can I do streaming bitmapdata by fms3?

    Thanks!

    egenialAuthor
    Participating Frequently
    January 27, 2008
    Ha,

    Return correct:

    public function recebes(...args:Array):void
    {
    var buffer:* = args[0] ;
    var o:* = buffer.readObject();
    var bit:Bitmap = new Bitmap();
    bit.bitmapdata = o; // Returned object in o, no bitmapdata
    addChild(bit);
    }
    egenialAuthor
    Participating Frequently
    January 27, 2008

    Hi ekameleon ;-)

    Has no support for bitmapda, even if I turn him into an object with byte array, it is returned as an object normal :(

    Do you have any example of how to do?

    My example:

    var bd:BitmapData = new BitmapData(_videoDisp.width,_videoDisp.height);
    var m : Matrix = new Matrix();
    bd.draw(_videoDisp, m);

    var ba:ByteArray = new ByteArray();
    ba.writeObject(bd);
    users_so.send("recebe", ba)

    Return.....

    public function recebes(...args:Array):void
    {
    var buffer:* = args[0] ;
    var o:* = buffer.readObject();
    var bit:BitmapData = new BitmapData(_img0.width, _img0.height);
    bit.bitmapdata = o; // Returned object in o, no bitmapdata
    addChild(bit);
    }


    Continued giving the same error of conversion :(

    Thanks!
    Inspiring
    January 27, 2008
    Hello :)

    You must try to transform your BitmapData in ByteArray ... you dispatch
    your ByteArray to the server... and when you receive the ByteArray to
    the server you transform your ByteArray in BitmapData ;)

    See the code source in my French article about AMF3 and classmapping
    with FMS3 :
    http://www.ekameleon.net/blog/index.php?2008/01/27/92--fmis3-flash-media-interactive-server-3-amf3-and-classmapping

    To transform un objet in ByteArray i use the code :

    var buffer:ByteArray = new ByteArray();
    buffer.writeObject( myObject );

    And to transform the ByteArray in a new object :

    var o:* = buffer.readObject();

    For me this solution is a good solution to send objects with AMF3. AMF3
    support ByteArray, XML(E4X), Number, Boolean, String, Object, Array and
    class mapping (use registerClass). I don't think AMF3 support the
    BitmapData type ?

    EKA+ :)


    egenial a écrit :
    > Sorry, tightness enter unintentionally.
    >
    > Continue...
    >
    > var bd:BitmapData = new BitmapData(_videoDisp.width,_videoDisp.height);
    > bd.draw(_videoDisp);
    > users_so.send("recebe", bd)
    >
    >
    > Receive...
    >
    > public function recebe(bd:BitmapData):void
    > {
    > var out:Bitmap = new Bitmap();
    > out.bitmapData = bd;
    > _myVideoComponent.addChild(out);
    > }
    >
    > Error....
    >
    > Error #2044: Unhandled AsyncErrorEvent:. text=Error #2095:
    > flash.net.SharedObject was unable to invoke callback recebe. error=TypeError:
    > Error #1034: Type Coercion failed: cannot convert Object@ebd6719 to
    > flash.display.BitmapData.
    >
    > Anyone know any solution? I want to make streaming bitmapdata.
    >
    > I use AMF3
    > __Info___________________________
    > level -> status
    > objectEncoding -> 3
    > code -> NetConnection.Connect.Success
    > description -> Connection succeeded.
    >
    > Thanks!
    >
    >
    egenialAuthor
    Participating Frequently
    January 26, 2008
    Sorry, tightness enter unintentionally.

    Continue...

    var bd:BitmapData = new BitmapData(_videoDisp.width,_videoDisp.height);
    bd.draw(_videoDisp);
    users_so.send("recebe", bd)


    Receive...

    public function recebe(bd:BitmapData):void
    {
    var out:Bitmap = new Bitmap();
    out.bitmapData = bd;
    _myVideoComponent.addChild(out);
    }

    Error....

    Error #2044: Unhandled AsyncErrorEvent:. text=Error #2095: flash.net.SharedObject was unable to invoke callback recebe. error=TypeError: Error #1034: Type Coercion failed: cannot convert Object@ebd6719 to flash.display.BitmapData.

    Anyone know any solution? I want to make streaming bitmapdata.

    I use AMF3
    __Info___________________________
    level -> status
    objectEncoding -> 3
    code -> NetConnection.Connect.Success
    description -> Connection succeeded.

    Thanks!