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

Video Corsi Actionscript 3.0


+ Reply to Thread
Page 1 of 3
1 2 3 LastLast
Results 1 to 10 of 25

Thread: as3 ed i socket

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

    Unhappy as3 ed i socket

    amazing Flash templates
    Salve a tutti!
    Quest'oggi ho un problemino alquanto serio...almeno per le mie conoscenze.
    In pratica ho creato un semplice server socket in java e l'ho messo in ascolto su localhost.
    Poi ho fatto un client in as3 che non deve far altro che ricevere un messaggio di benvenuto dal server.
    L'as3 è stato incluso in un fla tramite impostazione pubblicazione->impostazione . Ora la cosa strana è che quando io provo il tutto sotto ambiente adobe cs3 funziona (cioè se io faccio ctrl+invio) . Quando poi, prendo il file eseguibile swf e lo lancio non funziona più. Sapete darmi una mano in merito?
    Grazie

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

    Re: as3 ed i socket

    Ciao
    Se apri l' SWF direttamente col Flash Player non funziona per questioni di sicurezza.
    Inserisci l' SWF in una pagina html e provalo, vedrai che funziona.

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

    Riferimento: as3 ed i socket

    Ciao Flep,
    sempre rapido a venirci in aiuto. Cmq ho provato anche con il file html stesso che mi produce ma niente!
    :(
    Qualche altro aiuto? Vuoi che ti posto il codice?

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

    Re: as3 ed i socket

    Se pubblichi l' SWF dal FLA e funziona, allora il codice che hai implementato è corretto.
    Purtroppo Flash non è testabile al 100% in tutte le sue funzioni in locale.
    Ti consiglio di provarlo sul web server.

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

    Riferimento: as3 ed i socket

    Eh ed è questo il problema:D
    recuperare un server dove far girare il server socket

  6. #6
    Administrator Living At The FlepStudio! Flep is on a distinguished road
    Join Date
    Jul 2007
    Posts
    5,452
    Rep Power
    8

    Re: as3 ed i socket

    Chiedo scusa ma di server side non ne capisco molto, il mio lavoro è solo Actionscript.
    Ti faccio un esempio,
    se ho una form mail Flash+ PHP, se la apro dal FLA e la testo, se il codice è corretto, funziona correttamente. Se invece apro l' SWF direttamente col Flash Player, la form non funziona per fattori di sicurezza.
    Ora, per testarla, devo inserirla in una pagina html, caricarla sul server e andare col browser a quella pagina.
    Tu dovresti fare lo stesso. inserisci l' SWF in una pagina HTML e la carichi sul server.
    Vai col browser a quell' indirizzo e vedi se funziona. Se non funziona allora bisogna che guardiamo il codice.

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

    Riferimento: as3 ed i socket

    Ciao Flep.
    Ho provato ma nulla. Quello che leggevo su qualche forum è che potrebbe essere un problema di policy. Io non l'ho proprio inserito nel mio codice. Tu che ne pensi?

    Ti posto il codice

    socketExample.swf
    Code:
    package {
        import flash.display.Sprite;
     import flash.text.*;
        public class socketExample extends Sprite {
            public function socketExample() {
                var socket:CustomSocket = new CustomSocket("localhost",666);
       CustomSocket.casella=this;
            }
      
        }
    }
    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 {
            trace("connectHandler: " + event);
            sendRequest();
        }
        private function ioErrorHandler(event:IOErrorEvent):void {
            trace("ioErrorHandler: " + event);
        }
        private function securityErrorHandler(event:SecurityErrorEvent):void {
            trace("securityErrorHandler: " + event);
        }
        private function socketDataHandler(event:ProgressEvent):void {
            trace("socketDataHandler: " + event);
            readResponse();
        }
    }
    Aspetto tua. Grazie mille

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

    Re: as3 ed i socket

    Il codice infatti è corretto.
    Prova ad aggiugere un Policy File nella root del sever.
    Come questo:
    HTML Code:
    <?xml version="1.0"?>
    <!DOCTYPE cross-domain-policy 
    SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
    <cross-domain-policy>
    <allow-access-from domain="www.yoursite.com" />
    </cross-domain-policy>
    salvato con nome crossdomain.xml

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

    Riferimento: as3 ed i socket

    Continua a non funzionare. Ti spiego cosa ho fatto:

    aggiunto al codice la riga

    Code:
    Security.loadPolicyFile( "http://www.mydomain.com/crossdomain.xml" );
    Ho creato il crossdomain.xml come mi hai detto tu e posizionato nella root del mydomain.com

    Continua a non funzionarmi.

  10. #10
    Administrator Living At The FlepStudio! Flep is on a distinguished road
    Join Date
    Jul 2007
    Posts
    5,452
    Rep Power
    8

    Re: as3 ed i socket

    Posso sapere a cosa ti serve il socket ? nel senso, a che fine ?
    Perchè forse ci sono altre soluzioni.

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

Similar Threads

  1. Concorrenza scrittura su socket
    By Simona in forum Actionscript 3.0 avanzato
    Replies: 0
    Last Post: 07-05-09, 09:30
  2. Socket e restrizioni porte
    By Simona in forum Actionscript 3.0 avanzato
    Replies: 1
    Last Post: 02-04-09, 20:45
  3. Classe Socket
    By enefein in forum Actionscript 3.0 avanzato
    Replies: 1
    Last Post: 24-09-08, 18:20
  4. sandbox, policyfile e socket
    By z4g0 in forum Actionscript 3.0 avanzato
    Replies: 0
    Last Post: 26-06-08, 15:23
  5. ftp client & socket
    By nootropic.kint in forum Actionscript 3.0 avanzato
    Replies: 1
    Last Post: 04-12-07, 17: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

Search Engine Optimization by vBSEO