7 Replies - 5840 Views - Last Post: 08 December 2006 - 05:00 AM

#1 hnb   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 04-December 06

Read URL from textfile

Posted 04 December 2006 - 11:11 AM

Hi guys B)

a quick question:

I have a textfile with a URL inside like

http://www.mysite.com

So I want my flash button to read that URL from the txt file,
and when I press the button to go to that url :sleepy:

what exact code should I insert to the flash file?
I tried the get property but failed.
Im sure I m doing something wrong with the syntax
can someone give me the proper one?

Thanks :rolleyes:

This post has been edited by hnb: 04 December 2006 - 06:42 PM


Is This A Good Question/Topic? 0
  • +

Replies To: Read URL from textfile

#2 grimpirate   User is offline

  • Pirate King
  • member icon

Reputation: 149
  • View blog
  • Posts: 717
  • Joined: 03-August 06

Re: Read URL from textfile

Posted 04 December 2006 - 09:13 PM

Flash can't read from text files like other coding languages can. Using ActionScript the best approximation you can come up with is utilizing the XML object. Look it up in the Flash help. I myself haven't worked with it so I can't really tell you exactly what to do.
Was This Post Helpful? 0
  • +
  • -

#3 pioSko   User is offline

  • still.dreaming
  • member icon

Reputation: 23
  • View blog
  • Posts: 1,888
  • Joined: 06-June 03

Re: Read URL from textfile

Posted 05 December 2006 - 02:23 AM

change your text file to
link=http://www.mysite.com


in flash, create a new scene and le it be the first scene. In this new scene add this code
stop();

var file:String = "yourfile.txt";

var textFile:LoadVars = new LoadVars();
textFile.onload = function(ok) {
	ok ? doTXT(this.link) : error();
};
textFile.load( file );

this.onEnterFrame = function(){
	var todo:Number = textFile.getBytesTotal();
	var done:Number = textFile.getBytesLoaded();
	
	if(todo == done){
		trace("TXT LOADED");
		delete this.onEnterFrame;
		play();
	} else {		
		if(todo){
			trace("TXT " + String(Math.round(100 / todo * done)) + "%");
		}
	}
}

function doTXT(link:String){
	trace(link);
}


Make sure that in your other scene (the main stuff), that you have a stop; on the last frame so it doesn't loop between scenes.
Was This Post Helpful? 0
  • +
  • -

#4 hnb   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 04-December 06

Re: Read URL from textfile

Posted 05 December 2006 - 08:19 PM

thanks for the tips guys.

I thought I would need less code, you know like a read and turn it to a variable or link.

however I want to do this in flash 4.
is this script backwards compatible or should I use flash mx and up?

i dont have a scene or a big movie

the entire file will be just a button that reads my link
and inserted to my html page so that I can change my link from the text file,
without having to change the button all the time
what code should the button have?

I m trying to find a way to create the same code in flash 4

thanks in advance

This post has been edited by hnb: 05 December 2006 - 08:45 PM

Was This Post Helpful? 0
  • +
  • -

#5 pioSko   User is offline

  • still.dreaming
  • member icon

Reputation: 23
  • View blog
  • Posts: 1,888
  • Joined: 06-June 03

Re: Read URL from textfile

Posted 06 December 2006 - 01:50 AM

I suggest you get a copy of Flash MX. Flash 4 is very limited and has very little functions and still uses the slash-syntax. From Flash 5, they implemented a dot-syntax which made things a lot easier.

To be honest, I don't remember how to do it in Flash 4. It was 5 to 6 years ago since I used it.
Was This Post Helpful? 0
  • +
  • -

#6 jopiruizen   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 05-December 06

Re: Read URL from textfile

Posted 06 December 2006 - 05:22 PM

Why Flash 4?
Was This Post Helpful? 0
  • +
  • -

#7 hnb   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 04-December 06

Re: Read URL from textfile

Posted 07 December 2006 - 02:16 AM

View Postjopiruizen, on 6 Dec, 2006 - 05:22 PM, said:

Why Flash 4?

cause that was the version I had, and to be honest it has the easyest interface
from all versions so far. at least to me :sleepy:

anyway I got the MX version so I ll do that with flash 8 B)

is there something else in terms of code at the button that I have to add?

thanks
Was This Post Helpful? 0
  • +
  • -

#8 pioSko   User is offline

  • still.dreaming
  • member icon

Reputation: 23
  • View blog
  • Posts: 1,888
  • Joined: 06-June 03

Re: Read URL from textfile

Posted 08 December 2006 - 05:00 AM

yep. give your button a name (eg. myButton) and then add this code to the rest of the above code

myButton.onRelease = function(){
	getURL(myLink, "_new");
}


then, change the doTXT() function to this:
function doTXT(link:String){
	_root.myLink = link;
}

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1