Flash Gallery | Flash Templates | Flash Menu | Flash Design | Flash Audio & Video

Video Corsi Actionscript 3.0


+ Reply to Thread
Page 2 of 3 FirstFirst 1 2 3 LastLast
Results 11 to 20 of 25

Thread: as3 ed i socket

  1. #11
    Member Settled In Enzuccio is on a distinguished road
    Join Date
    Oct 2007
    Posts
    44
    Rep Power
    0

    Riferimento: as3 ed i socket

    flash templates
    Ho intenzione di creare una chat con comunicazione socket.
    Cioè la cosa che mi fa rabbia è che da ambiente cs3 funge, ho provato anche in rete, facendolo lanciare ad un amico da casa sua, e riesce a collegarsi al server che ho io in locale...poi dall'html non và!

  2. #12
    Administrator Living At The FlepStudio! Flep is on a distinguished road
    Join Date
    Jul 2007
    Posts
    5,609
    Rep Power
    9

    Re: as3 ed i socket

    Per i sockets e le chats ci vorrebbe Flash Remoting.

  3. #13
    Member Settled In Enzuccio is on a distinguished road
    Join Date
    Oct 2007
    Posts
    44
    Rep Power
    0

    Riferimento: as3 ed i socket

    Provandolo con il debug di firefox mi ha dato questo errore:

    SecurityError: Error #2010: I file SWF local-with-filesystem non sono autorizzati a utilizzare i socket.
    at flash.net: ocket/connect()
    at flash.net: ocket$iinit()
    at ::CustomSocket$iinit()
    at socketExample$iinit()

  4. #14
    Administrator Living At The FlepStudio! Flep is on a distinguished road
    Join Date
    Jul 2007
    Posts
    5,609
    Rep Power
    9

    Re: as3 ed i socket

    The Socket class enables ActionScript code to make socket connections and to read and write raw binary data. It is similar to XMLSocket but does not dictate the format of the received or transmitted data.
    The Socket class is useful for working with servers that use binary protocols.

    When you use this class, consider the Flash Player security model:

    Data loading is not allowed if the calling SWF file is in the local-with-file-system sandbox and the target resource is from a network sandbox.
    Data loading is also not allowed if the calling SWF file is from a network sandbox and the target resource is local.
    The calling SWF file and the network resource being accessed must be in exactly the same domain. For example, a SWF file at adobe.com can connect only to a server daemon at adobe.com.
    Websites can permit cross-domain access to a resource through a cross-domain policy file.

  5. #15

  6. #16

  7. #17
    Member Settled In Enzuccio is on a distinguished road
    Join Date
    Oct 2007
    Posts
    44
    Rep Power
    0

    Riferimento: as3 ed i socket

    Ti ringrazio flep per l'interessamento.
    Stò continuando a sbariare...purtroppo ancora nulla!

  8. #18
    Member Settled In Enzuccio is on a distinguished road
    Join Date
    Oct 2007
    Posts
    44
    Rep Power
    0

    Riferimento: as3 ed i socket

    Caro Flep,
    dopo svariati tentativi, sono riuscito a risolvere il problema della policy. Ora non mi da più problemi per quanto riguarda questo aspetto.
    Ma purtroppo ne sorge un altro: praticamente non avviene il collegamento. Nel file swf corrispondente ho messo un pò di caselle di testo di prova per stampare gli eventuali errori.

    Ti posto il codice modificato:

    Code:
    package {
     import flash.display.Sprite;
     import flash.text.*;
     import flash.system.Security;
     import flash.net.*;
     import flash.events.*;
     import flash.errors.*;
    
     public class socketExample extends Sprite {
      public function socketExample() {
       Security.loadPolicyFile("xmlsocket://XX.XX.XX.XX:80");
       var socket:CustomSocket = new CustomSocket("XX.XX.XX.XX",1500);
       CustomSocket.casella=this;
       connessione.text="NON CONNESSO";
      }
     }
    }
    import flash.errors.*;
    import flash.events.*;
    import flash.net.Socket;
    import flash.text.*;
    class CustomSocket extends Socket {
     private var response:String;
     public static  var casella;
     public function CustomSocket(host:String = null, port:uint = 0) {
      super(host, port);
      configureListeners();
     }
     private function configureListeners():void {
      addEventListener(Event.CLOSE, closeHandler);
      addEventListener(Event.CONNECT, connectHandler);
      addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
      addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
      addEventListener(ProgressEvent.SOCKET_DATA, socketDataHandler);
     }
     private function writeln(str:String):void {
      str += "\n";
      try {
       writeUTFBytes(str);
      } catch (e:IOError) {
       trace(e);
      }
     }
     private function sendRequest():void {
      trace("sendRequest");
      response = "";
      writeln("GET /");
      flush();
     }
     private function readResponse():void {
      var str:String = readUTFBytes(bytesAvailable);
      response += str;
      casella.prova.text=response;
     }
     private function closeHandler(event:Event):void {
      trace("closeHandler: " + event);
      trace(response.toString());
     }
     private function connectHandler(event:Event):void {
      casella.connessione.text="CONNESSO";//connectHandler: " + event;
      sendRequest();
     }
     private function ioErrorHandler(event:IOErrorEvent):void {
      casella.erroreIO.text="ioErrorHandler: " + event;
     }
     private function securityErrorHandler(event:SecurityErrorEvent):void {
      casella.erroreSe.text="securityErrorHandler: " + event;
     }
     private function socketDataHandler(event:ProgressEvent):void {
      trace("socketDataHandler: " + event);
      readResponse();
     }
    }

  9. #19
    Administrator Living At The FlepStudio! Flep is on a distinguished road
    Join Date
    Jul 2007
    Posts
    5,609
    Rep Power
    9

    Re: as3 ed i socket

    Ciao Enzuccio, a me sembra tutto ok in Actionscript... lato server è tutto ok ?

  10. #20
    Member Settled In Enzuccio is on a distinguished road
    Join Date
    Oct 2007
    Posts
    44
    Rep Power
    0

    Riferimento: as3 ed i socket

    Lato server è sempre tutto ok.
    C'è sempre il problema che in ambiente cs3 funziona. Quando compilo e lancio da html, non va!

+ Reply to Thread
Page 2 of 3 FirstFirst 1 2 3 LastLast

Similar Threads

  1. Socket Connection
    By epokesrl in forum Actionscript 3.0 avanzato
    Replies: 0
    Last Post: 05-07-10, 16:56
  2. Socket e restrizioni porte
    By Simona in forum Actionscript 3.0 avanzato
    Replies: 1
    Last Post: 02-04-09, 19:45
  3. Classe Socket
    By enefein in forum Actionscript 3.0 avanzato
    Replies: 1
    Last Post: 24-09-08, 17:20
  4. sandbox, policyfile e socket
    By z4g0 in forum Actionscript 3.0 avanzato
    Replies: 0
    Last Post: 26-06-08, 14:23
  5. ftp client & socket
    By nootropic.kint in forum Actionscript 3.0 avanzato
    Replies: 1
    Last Post: 04-12-07, 16:21

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts