PDA

View Full Version : Dynamic Text Referencing


karlzoe2
06-23-2002, 11:56 PM
NOT SURE IF I USED THE RIGHT TERM. HERE GOES ANY WAY

i am tyrinh to creat a page with several buttons so that when you click the appropriate button it lshows the appropriate text. eg the NEWS BUTTON would show the news (news headline and article) when it is clicked and the SPORTS BUTTON would show the button when it is clicked.

this is where i am so far....

news = new Array ();
news[0] = "headline news";
news[1] = "this is just a test";
headline.text = news[0];
article.text = news[1];

i have a layer called labels with the following frame names, initialize, refresh and sit

now on the button i have placed the following

on (release) {
I KNOW SOMETHING IS MISSING between the two lines of code

this.gotoAndPlay ("refresh")

}


PROBLEM



my problem is i do not know how to tell the button to get the text and show it in the dynamic text box.


will someone please help me:confused:

Esquared
06-24-2002, 02:29 AM
First of all, I would create 2 dynamic text boxes, one for the headline and one for the article text. Be sure these are not set as selectable. Then, make the variables for these text boxes _root.headline and _root.article, respectively.

If no text is to be shown here before a button is clicked, add the following to your initialize frame:


_root.headline = ""
_root.article = ""


Now I'm confused as to why you needed your initial variables in an array, but if that's necessary then what you have is fine. However, what you need to do on the buttons is this. You need to set the variables in the dynamic text boxes to your preset strings, be they in an array or not. For instance:


on (release)
{
_root.headline = _root.newsHeadline
_root.article = _root.newsArticle

this.gotoAndPlay ("refresh")
}


That code would work for your news button, as long as you declare _root.newsHeadline and _root.newsArticle in your initialize frame. Again, this could be done directly, or through your array if needed.

In this way, you need only to declare 2 strings for each button, and then specialize each button to set the text box variables to its associated strings. The only thing that would change for your other buttons would be the variables to the right of the "=" in the code above, which would be changed to _root.sportsHeadline and _root.sportsArticle, etc...

Hope this is what you're looking for.

Esquared

karlzoe2
06-24-2002, 02:17 PM
will try and report to u later