PDA

View Full Version : Creating function to dynamically change text.


ragnarkarlsson
03-26-2003, 11:42 AM
Hi,

I'm very new to creating functions and could do with some help. The basic idea is as follows :-

1. The variables text and title are loaded in from an external txt file.
2. dynamic text fields display the variables, rendered as html
3. links in the text use the <a href='asfunction:myFunction(target)'> to call my function
4. my function loads new version of the variables from target.txt

My problem is that I don't know how to make this work, its a relatively simple function I assume but my understanding of functions in AS is abysmal. Any help would be greatly appreciated.

R

Billy T
03-26-2003, 11:32 PM
post what you have so far

ragnarkarlsson
03-27-2003, 09:48 AM
Hi,

ok the main movie contains a set of 10 buttons (there are 10 chunks of content text), each of which pull in the variables from txt files (content1.txt, content2.txt, etc). The content of these variables are the content for 2 dynamic text boxes (_root.textbox.text and _root.textbox.title)

Here is how I am currently loading that in


loadVarsText = new loadVars();
loadVarsText.onLoad = function(success) {
if (success) {
textwindow.title.text = this.title;
textwindow.textbox.htmlText = this.message;
}
};


With each button having the line


loadVarsText.load("content1.txt");


The content loaded often refers to one of the other chunks of content, so what I want to do is create a function which I can call from the txt using an A tag. This is where my lack of function knowledge falls down. I don't know how to create a function which I can pass in a target variable to determine which txt file to call for content, and then how to use that function.

Can anyone point me at some simple function tutorials possibly?

R

Billy T
03-27-2003, 09:55 AM
this should help

cheers

ragnarkarlsson
03-27-2003, 10:02 AM
Cheers for that got it now and its all working nicely.

Many thanks

R

Billy T
03-27-2003, 10:08 AM
no problem

don't forget to search before you post as you will often find your answer there

cheers