.:: Jasa Membuat Aplikasi Website,Desktop,Android Order Now..!! | | Order Now..!! Jasa Membuat Project Arduino,Robotic,Print 3D ::.

Read variables from text file with AS3

0 komentar


بِسْــــــــــــــــمِ اﷲِالرَّحْمَنِ اارَّحِيم
bismillaahirrahmaanirrahiim

السَّلاَمُ عَلَيْكُمْ وَرَحْمَةُ اللهِ وَبَرَكَاتُهُ
Assalamu'alaikum warahmatullahi wabarakatuh

As you all might have noticed, lately I have converted to actionscript 3.0 instead of the old actionscripting, and yes as a lot of people say, its quite tough to convert, so I have to start from rock bottom. So here will be a lot of experimenting tutorials for flash actionscript 3.0. In this Flash tutorial you will see how to load variables in to flash from a text file.
As you might know a variable is a container, we define a container to keep simple information, it can be text, numbers, true/false etc. In this case we just want to load in simple text variables from a text file we call content.txt (remember to keep the content file in the same directory as the flash file).
First we will look at how the text file is build, it really simple you write everything in one line, separating variables with a & and starting with the variable name then = to its value like this.
  1. var_1=first variable&var_2=second variable  
If you now want to extract var_1 the result will be "first variable"
Now for the flash file, here is first what we want to set up.
This small example will only contain two dynamic text fields, so go open a new flash document, and drag out two text objects, go to properties and change their state from static to dynamic and give the text boxes an instance name (I called mine content_1 and content_2) Look at the properties in the image below.
That was all we needed to do with the flash interface, of cause you can do a lot of visual stuff to make it look more interesting, but for this tutorial I will keep it simple and stick to the nerdy stuff.
As you know we are working with actionscript 3.0 so coding is done on the stage, so click somewhere on the stage, to deselect all, then go to the actionscript panel and type in the following code, lines with // are my comments on how the code works and what it does, you can delete them if you want.
  1. var loader:URLLoader = new URLLoader();  
  2.   
  3. //telling the loader that we are dealing with variables here.  
  4. loader.dataFormat = URLLoaderDataFormat.VARIABLES;  
  5.   
  6. //This is an eventlistener, these are used all the time in AS3  
  7. //learn to use them, this basically tells flash to listen to a specific event  
  8. //and then call a specific function.  
  9. //in Our case we listen for the even called COMPLETE which means it will active  
  10. //a function called "loading" when our flash movie has completed  
  11. loader.addEventListener(Event.COMPLETE, loading);  
  12.   
  13. //Here we tell our loading which file to extract from.  
  14. loader.load(new URLRequest("content.txt"));  
  15.   
  16. //This is the function that will happen when the eventlistener activates.  
  17. //basiclly it says that our text fields called content_1 and _2's text property  
  18. //should be equal to loader.data.var_1 and var_2 (as you might remember from the explanation above).  
  19. function loading (event:Event):void {  
  20.     content_1.text = loader.data.var_1  
  21.     content_2.text = loader.data.var_2  
sumber : http://blog.0tutor.com/post.aspx?id=110

Update Contact :
No Wa/Telepon (puat) : 085267792168
No Wa/Telepon (fajar) : 085369237896
Email : Fajarudinsidik@gmail.com
NB :: Bila Sobat tertarik Ingin membuat software, membeli software, membeli source code, membeli hardware elektronika untuk kepentingan Perusahaan maupun Tugas Akhir (TA/SKRIPSI), Insyaallah Saya siap membantu, untuk Respon Cepat dapat menghubungi kami, melalui :

No Wa/Telepon (puat) : 085267792168
No Wa/Telepon (fajar) : 085369237896
Email: Fajarudinsidik@gmail.com


atau Kirimkan Private messanger melalui email dengan klik tombol order dibawah ini :

ٱلْحَمْدُ لِلَّهِ رَبِّ ٱلْعَٰلَمِين
Alhamdulilah hirobil alamin

وَ السَّلاَمُ عَلَيْكُمْ وَرَحْمَةُ اللهِ وَبَرَكَاتُهُ
wassalamualaikum warahmatullahi wabarakatuh


Artikel Read variables from text file with AS3, Diterbitkan oleh scodeaplikasi pada Rabu, 02 Januari 2013. Semoga artikel ini dapat menambah wawasan Anda. Website ini dipost dari beberapa sumber, bisa cek disini sumber, Sobat diperbolehkan mengcopy paste / menyebar luaskan artikel ini, karena segala yang dipost di public adalah milik public. Bila Sobat tertarik Ingin membuat software, membeli software, membeli source code ,Dengan Cara menghubungi saya Ke Email: Fajarudinsidik@gmail.com, atau No Hp/WA : (fajar) : 085369237896, (puat) : 085267792168.

Tawk.to