Recently made a chat, need to use as to load a website XML, but I as also not how to drop, go to see how to play, after reading is quite simple.
As the business is more complex, just say a small example.
Many times, for the page area more flexible, vivid, attractive, more or less to use flash, if the flash can not exchange with the outside world, that
It does have a lot of restrictions on the functionality of the flash, it is not fun, on many sites we can see with flash to display the current number of online users, or with flash
Displays the current number of user participants, or scrolls through the current winning list.
Because it is pure teaching, so the business is very simple, dynamic display of the current number of user participation, but the fun part is that many programs to get a benchmark number after
Instead of rotation the state to the server, it uses random numbers on flash to simulate the increase and decrease of the dynamic to deceive the participants ...
One: XML file
This simple, only place a benchmark number of participants:
20
Second: Request XML as code on the Web
Import Flash.net.URLLoader;
Import Flash.net.URLRequest;
Import flash.events.Event;
Import Flash.text.TextField;
Import Flash.utils.Timer;
Import flash.events.TimerEvent;
var myxml:xml;
Request XML var url= "Http://localhost:25212/test.xml" on the web;
var req:urlrequest=new urlrequest (URL);
var loader:urlloader=new urlloader (req);
var lab:textfield=new TextField ();
var timer:timer=new timer (1000);
var joinscale:int loader.addeventlistener (Event.complete,oncomplete); function OnComplete (e:event): void{ myxml=new XML (loader.data); joinscale= Myxml.joins.nums var output= "Current number of participants:" + Joinscale trace (output)
;
lab.text=output lab.width=200;
lab.x=100;
lab.y=100;
AddChild (Lab);
Timer.addeventlistener (timerevent.timer,settext); Timer.start (); } function SetText (e:timerevent) { //To accommodate there is increased there is a reduction joinscale= Joinscale+ (10*math.random ())-3 lab.text= "Current number of participants are:" + joinscale }
There is a urlloader to load the results of the urlrequest request, after the results of the XML, the Timer control to generate random numbers to simulate user dynamic participation,
The number of the following picture is dynamic.