Skip to main content
Participating Frequently
March 1, 2012
Question

How to create a counter ....

  • March 1, 2012
  • 2 replies
  • 746 views

I want to create a counter that will take the number I put in a text file and display it......not sure how to do this.

This topic has been closed for replies.

2 replies

sinious
Legend
March 1, 2012

Second link gives you a full example to examine:

import flash.net.*;

import flash.events.*;

var textArea:TextField = new TextField();

addChild(textArea);

var PATH:String = "yourFileHere.txt";

var urlRequest:URLRequest = new URLRequest(PATH);

var urlLoader:URLLoader = new URLLoader();

urlLoader.dataFormat = URLLoaderDataFormat.TEXT;

urlLoader.addEventListener(Event.COMPLETE, urlLoader_complete);

urlLoader.load(urlRequest);

function urlLoader_complete(evt:Event):void {

    textArea.text = urlLoader.data;

}

Just change yourFileHere.txt to the right path/file.

sinious
Legend
March 1, 2012

Sometimes it's useful to keep the counter in a variable format for url prepending and such but it's not required. Regardless you can find plenty of old tutorials on loading text from a file.

The URLLoader class otherwise can load plain text as well of course.

Participating Frequently
March 1, 2012

Thanks, but I'm still learning, any tips on how to do this?