Tutorial: Realizziamo una chat per il nostro sito (Lesson 2)

Spread the love

Cominciamo la nostra seconda lezione sulla creazione di una piccola chat da inserire in un box del nostro sito web, spiegando a cosa servono le righe di comando che abbiamo utilizzato nell’Action Script del pulsante Invia.

 

L’azione:

 

loadVariablesNum (“resp.asp”, 0, “POST”);

 

da l’avvio al inserimento del nuovo messaggio, effettua il refresh dei messaggi e pulisce il nostro campo di testo per inserire i nuovi messaggi.

Lo script di resp.asp, va comunque inserito in codice. Di seguito vedremo l’inserimento effettuato con i commenti per capire meglio passo passo cosa stiamo facendo:

<%
Dim strLinea, FileObject, Instream, intVisite, intTipo, OutStream, i, k, arrMsg(100), fine, allMsg
‘questa stringa permette l’utilizzo semplice in visualizzazione di : “username _ messaggio”
stringa = Trim(Request(“stringa”))
strFile = Server.MapPath(“msg.txt”)
definiamo l’oggetto creato in questo caso i messaggi che andranno in un file di testo
Set FileObject = Server.CreateObject(“Scripting.FileSystemObject”)
‘faccio la lettura del file
intTipo = 1 ‘ lettura
Set InStream = FileObject.OpenTextFile(strFile,IntTipo,true)
‘inseriamo il valore di data e ora al messaggio per fare in modo che in ordine cronologico siano aggiunti nella lista
i = 0
arrMsg(i) = FormatDateTime(Now(),3)&” – “&stringa
‘leggiamo il file di testo ed inseriamo i messaggi
Do While not InStream.AtEndOfStream
StrLinea = InStream.ReadLine()
i=i+1
arrMsg(i) = StrLinea
Loop
Set OutStream = FileObject.CreateTextFile(strFile, true)
‘determiniamo il numero massimo di messaggi
if i>15 then
fine=15
else
fine=i
end if
k=0
‘visualizziamo in Flash i messaggi inserendo il (br) a capo dove necessario
Do While k<=fine
OutStream.WriteLine(arrMsg(k))
allMsg=allMsg&arrMsg(k)&”<br />”
k=k+1
Loop
OutStream.Close
Set OutStream = Nothing
InStream.Close
Set InStream = Nothing
Set FileObject = Nothing
‘inviamo definitivamente i messaggi alla chat
Response.Write(“corpo=”&allMsg)
%>

Ecco, così abbiamo inserito il codice alla nostra chat e potremmo utilizzarla in modalità standard per dare la possibilità agli utenti del vostro sito di scambiare due chiacchiere. Ricordiamo che la versione utilizzata per la realizzazione di questo tutorial è l’ActionScript 4 incluso nella suite Adobe Macromedia Flash CS4 Professional.

Nella prossima ed ultima lezione, vedremo come dare un “tocco di colore” alla nostra chat.

731 commenti su “Tutorial: Realizziamo una chat per il nostro sito (Lesson 2)”

  1. Pretty impressive article. I just stumbled upon your site and wanted to say that I have really enjoyed reading your opinions. Any way I’ll be coming back and I hope you post again soon.

    Rispondi
  2. This is really interesting, You’re a very skilled blogger. I have joined your feed and look forward to seeking more of your great post. Also, I’ve shared your web site in my social networks!

    Rispondi
  3. You’ve made some really good points there. I checked on the internet for more information about the issue and found most individuals will go along with your views on this web site.

    Rispondi
  4. Hello there I am so delighted I found your weblog, I really found you by mistake, while I was searching on Google for something else, Anyhow I am here now and would just like to say cheers for a remarkable post and a all round exciting blog (I also love the theme/design), I don’t have time to browse it all at the moment but I have book-marked it and also included your RSS feeds, so when I have time I will be back to read a lot more, Please do keep up the superb work.

    Rispondi
  5. I feel that is among the so much significant info for me. And i am satisfied studying your article. However should commentary on some basic issues, The site style is ideal, the articles is in reality excellent : D. Excellent activity, cheers

    Rispondi
  6. I really love your site.. Great colors & theme. Did you develop this site yourself? Please reply back as I’m hoping to create my own website and would like to know where you got this from or what the theme is called. Appreciate it.

    Rispondi
  7. Hi there! I could have sworn I’ve visited this blog before but after looking at a few of the posts I realized it’s new to me. Anyways, I’m definitely delighted I found it and I’ll be book-marking it and checking back often.

    Rispondi
  8. That is really fascinating, You’re an excessively skilled blogger. I’ve joined your rss feed and look forward to in the hunt for extra of your magnificent post. Additionally, I’ve shared your website in my social networks!

    Rispondi
  9. I concur with your conclusions and will eagerly look forward to your future updates. The usefulness and significance is overwhelming and has been invaluable to me!

    Rispondi

Lascia un commento