This is a discussion on "Help with function to read external file" within the Flash & Multimedia Forum section. This forum, and the thread "Help with function to read external file are both part of the Design Your Website category.
|
|
|
|
|
![]() |
||
Help with function to read external file
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
|||
|
Help with function to read external file
I have a code segment which randomly picks a quote from an external file (shown below). But I want to make it so that I can call this function from anywhere and return the value it obtains.
Here is the code segment:
What I want to do is something like this (from the calling area):
I will use this function from many places, and was planning to define the function in frame 1. But I dont know actionscript well enough to make the first code segment a fully encapsulated function, that can achieve this. Any advice welcome. |
|
|
|
|||
|
Re: Help with function to read external file
So what if we turned this into a fuction like this:
Time for some Coffee. Cheers, Scott
Last Blog Entry: Yay!? (Oct 8th, 2007)
|
|
|||
|
Re: Help with function to read external file
Thanks for the advice. But wouldnt the 'ran' variable only have local scope in the function?
What I was trying to do was return the quote from the function - but couldnt get that to work. |
|
|||
|
Re: Help with function to read external file
hmm, yeah - you could use a global variable and have it set the _root.variablename = run; and then use it that way I would think.
I can take a look at this a little more over the weekend I think...really busy today here at the good ole' job. Does this at least get your gears turning? Cheers, Scott
Last Blog Entry: Yay!? (Oct 8th, 2007)
|
|
|||
|
Re: Help with function to read external file
I just think that because of the onload event, the assignment is only made when its finished loading the quotes.txt file. So at the point you perform the abc.text assignment, its not necessarily set the global variable that you're refering to yet.
I think this is why I was having problems with it as a function - due to the nature of this onload, and only getting the value set asynchronously. Thanks for your thoughts though. |
![]() |
| Tags |
| external file, function |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| file read | alexgeek | PHP Forum | 18 | Aug 19th, 2007 19:49 |
| Load External .JS File Before Anything Else | tox0tes | JavaScript Forum | 1 | Jul 10th, 2007 14:03 |
| Is it possible to use an external text file for a variable | AdRock | JavaScript Forum | 2 | Sep 15th, 2006 17:25 |
| Read only from File..... | courtjester | JavaScript Forum | 7 | Nov 23rd, 2003 16:21 |