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. Hey I know this is off topic but I was wondering if you knew of any widgets I could add to my blog that automatically tweet my newest twitter updates. I’ve been looking for a plug-in like this for quite some time and was hoping maybe you would have some experience with something like this. Please let me know if you run into anything. I truly enjoy reading your blog and I look forward to your new updates.

    Rispondi
  2. Hey there! This post couldn’t be written any better! Reading this post reminds me of my old room mate! He always kept talking about this. I will forward this page to him. Pretty sure he will have a good read. Thanks for sharing!

    Rispondi
  3. Simply want to say your article is as amazing. The clearness for your post is simply nice and i can think you are a professional in this subject. Well with your permission allow me to take hold of your RSS feed to stay up to date with forthcoming post. Thank you one million and please continue the gratifying work.

    Rispondi
  4. Superb site you have here but I was curious if you knew of any discussion boards that cover the same topics talked about in this article? I’d really love to be a part of online community where I can get responses from other knowledgeable individuals that share the same interest. If you have any recommendations, please let me know. Many thanks!

    Rispondi
  5. Hello there, simply became aware of your blog through Google, and found that it is really informative. I’m gonna watch out for brussels. I will appreciate if you continue this in future. Many other people can be benefited from your writing. Cheers!

    Rispondi
  6. Excellent site you have here but I was wanting to know if you knew of any community forums that cover the same topics talked about in this article? I’d really love to be a part of group where I can get opinions from other knowledgeable individuals that share the same interest. If you have any recommendations, please let me know. Many thanks!

    Rispondi
  7. I don’t even know the way I ended up here, however I thought this post was good. I don’t realize who you’re however definitely you are going to a famous blogger in case you are not already. Cheers!

    Rispondi
  8. It is perfect time to make a few plans for the future and it is time to be happy. I have read this publish and if I may I want to recommend you few interesting things or advice. Perhaps you could write next articles relating to this article. I wish to read more things approximately it!

    Rispondi
  9. I don’t know if it’s just me or if everyone else experiencing problems with your website. It appears like some of the text on your posts are running off the screen. Can someone else please comment and let me know if this is happening to them too? This could be a problem with my browser because I’ve had this happen before. Kudos

    Rispondi
  10. Do you have a spam issue on this website; I also am a blogger, and I was curious about your situation; many of us have created some nice methods and we are looking to trade strategies with other folks, be sure to shoot me an e-mail if interested.

    Rispondi
  11. Oh my goodness! Amazing article dude! Thanks, However I am experiencing difficulties with your RSS. I don’t know why I can’t subscribe to it. Is there anyone else getting the same RSS problems? Anyone who knows the solution will you kindly respond? Thanx!!

    Rispondi
  12. My programmer is trying to persuade me to move to .net from PHP. I have always disliked the idea because of the expenses. But he’s tryiong none the less. I’ve been using Movable-type on a number of websites for about a year and am anxious about switching to another platform. I have heard very good things about blogengine.net. Is there a way I can transfer all my wordpress content into it? Any kind of help would be really appreciated!

    Rispondi
  13. You really make it seem so easy together with your presentation however I find this topic to be really something which I think I might never understand. It kind of feels too complicated and very vast for me. I am taking a look forward in your next post, I will try to get the grasp of it!

    Rispondi
  14. Hi, Neat post. There is a problem with your web site in internet explorer, might check this? IE still is the marketplace leader and a good part of other folks will leave out your fantastic writing due to this problem.

    Rispondi
  15. I am extremely impressed with your writing skills and also with the layout on your blog. Is this a paid theme or did you customize it yourself? Either way keep up the nice quality writing, it’s rare to see a nice blog like this one nowadays.

    Rispondi
  16. An intriguing discussion is worth comment. I believe that you ought to write more on this subject, it might not be a taboo subject but generally people do not discuss such topics. To the next! Kind regards!!

    Rispondi
  17. This is very fascinating, You are an overly professional blogger. I have joined your feed and sit up for in quest of more of your wonderful post. Also, I have shared your web site in my social networks

    Rispondi
  18. Hello there, just became aware of your blog through Google, and found that it is really informative. I’m gonna watch out for brussels. I will appreciate if you continue this in future. A lot of people will be benefited from your writing. Cheers!

    Rispondi
  19. Simply want to say your article is as amazing. The clearness in your post is simply nice and i can assume you are an expert on this subject. Well with your permission allow me to grab your RSS feed to keep up to date with forthcoming post. Thanks a million and please continue the rewarding work.

    Rispondi
  20. I like the valuable information you provide in your articles. I will bookmark your weblog and check again here frequently. I am quite certain I will learn many new stuff right here! Good luck for the next!

    Rispondi

Lascia un commento