Java method call in flash file

1.2k views Asked by At

I have sample code for NetConnection in as3 :

  var good:Boolean;
  nc = new NetConnection();    
  nc.connect("rtmp://ip:port/MyDemo/");
  nc.addEventListener(NetStatusEvent.NET_STATUS,getStream);

  function getStream(e:NetStatusEvent):Void
    {
         good=e.info.code == "NetConnection.Connect.Success";
         if(good)
         {
           var responder = new Responder(adder);
           nc.call("addSomething",responder,2,3);
         }
     }

  function adder (obj:Object):Void
  {
    trace("Total = "+obj.toString());
  }

i have a method "addSomething" in my Test.java which extends ApplicationAdapter class.

My question is that can i use this code in actions of an fla file using as2 or not. If yes than how ?

If not than what changes have to made to use this code in as2 ?

Thanks

1

There are 1 answers

1
Jonathan Dunlap On

Nope, you cannot use this code in any form inside an AS2 project. Unfortunately, you will have to rewrite this from pretty much from scratch to work. Event listeners, Responder(s), and callback functions by reference are not usable in the same form in the AS2 language.

However, what you're trying to do is possible in AS2. Read into this link below on the differences between languages for NetConnection: http://www.justskins.com/forums/actionscript-2-0-vs-127566.html