As with. NET interaction-loading XML on the Web

Source: Internet
Author: User
Tags benchmark joins net

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.



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.