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.

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

  1. I am really impressed with your writing skills as well as with the layout on your blog.
    Is this a paid theme or did you modify it yourself?
    Anyway keep up the nice quality writing, it’s rare to see a
    great blog like this one nowadays.

    Rispondi
  2. I know this if off topic but I’m looking into starting my own weblog and was wondering what
    all is required to get set up? I’m assuming
    having a blog like yours would cost a pretty penny?
    I’m not very web savvy so I’m not 100% sure.
    Any recommendations or advice would be greatly appreciated.
    Appreciate it

    Rispondi
  3. Heya i am for the first time here. I found this board and I to find It truly useful
    & it helped me out a lot. I am hoping to present one thing back and
    aid others like you helped me.

    Rispondi
  4. Hello there I am so happy I found your webpage, I really found you by accident,
    while I was browsing on Digg for something else, Anyways
    I am here now and would just like to say thanks a lot for a
    fantastic post and a all round enjoyable blog (I also love the theme/design), I don’t have time to read through it all at
    the minute but I have saved it and also added in your RSS feeds,
    so when I have time I will be back to read much more,
    Please do keep up the fantastic work.

    Rispondi
  5. I have been surfing online more than 4 hours today,
    yet I never found any interesting article like yours.
    It’s pretty worth enough for me. Personally, if all webmasters and bloggers made good content as
    you did, the internet will be a lot more useful than ever before.

    Rispondi
  6. Excellent website you have here but I was wondering
    if you knew of any user discussion forums that cover the same topics
    talked about in this article? I’d really like to be a part of group where I
    can get feed-back from other knowledgeable people that share the same interest.
    If you have any recommendations, please let me know.

    Kudos!

    Rispondi
  7. Hey just wanted to give you a quick heads up and let you know a few of the images aren’t loading correctly. I’m not sure why but I think its a linking issue. I’ve tried it in two different internet browsers and both show the same results.

    Rispondi
  8. You’re so awesome! I don’t suppose I’ve read something like this before. So good to find someone with some unique thoughts on this issue. Really.. thank you for starting this up. This website is something that is needed on the web, someone with some originality!

    Rispondi
  9. Hey this is somewhat of off toic buut I wwas wonbdering iff blovs use WYSIWYG edjtors oor iif you hafe tto manuially code with HTML.
    I’m starting a blog soon buut have no coding knowlerdge sso I
    wanted to gget advicee fom somrone wikth experience.
    Anyy help would bbe greatly appreciated!

    Rispondi
  10. This design is wicked! You obviously know how to keep a reader entertained. Between your wit and your videos, I was almost moved to start my own blog (well, almost…HaHa!) Fantastic job. I really enjoyed what you had to say, and more than that, how you presented it. Too cool!

    Rispondi
  11. I was suggested this web site by my cousin. I am not sure whether this post is
    written by him as nobody else know such detailed about my problem.
    You’re wonderful! Thanks!

    Rispondi

Lascia un commento