A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Dynamic Text as links?

  1. #1
    Junior Member
    Join Date
    Dec 2000
    Posts
    13

    Dynamic Text as links?

    Is this possible?

    I have a dynamic menu that writes out the menu text from a dynamic array, but I want to make a link for each menu item... is there a way I can do that?

    thanks

    -Emo

  2. #2
    Registered User nunomira's Avatar
    Join Date
    May 2002
    Location
    portugal
    Posts
    7,003
    suppose your links are flashkit and macromedia:

    Code:
    link = ["<a href='http://www.flashkit.com'>flashkit</a>", "<a href='http://www.macromedia.com'>macromedia</a>"];
    this.createTextField("t_txt", 1, 0, 0, 1, 1);
    t_txt.html = true;
    t_txt.htmlText = "here is " + link[0] + " and here is " + link[1];
    t_txt.autoSize = true;

  3. #3
    Junior Member
    Join Date
    Dec 2000
    Posts
    13
    Thanks for the reply..

    of couse, I have no idea where to stick your code, so I modified mine a little bit like this: (the bold is my modification)... so can you please tell me what am I doing wrong?

    Code:
    menuItems = 3;
    titles = new Array();
    url = new Array();
    leader.myText.text = "Drag Me";
    for (i=0; i<menuItems; i++) {
    	url[0] = "http://www.flashkit.com"
    	url[1] = "http://www.microsoft.com"
    	url[2] = "http://www.nxsupport.com"
    	titles[0] = "Reviews";
    	titles[1] = "Reader Reviews";
    	titles[2] = "Round Table Reviews";
    	_root.leader.duplicateMovieClip("subject"+i, i);
    	_root["subject"+i].myText.getURL(url[i]);
    	_root["subject"+i].myText.text = titles[i];
    but it's not working of couse...

    thanks for any help

    EDIT: I wanted to add that this is the first time me messing with ActionScript so dont go laughing on my newbie mistakes

    -Emo

  4. #4
    Registered User nunomira's Avatar
    Join Date
    May 2002
    Location
    portugal
    Posts
    7,003
    if I understand what you want:
    Code:
    menuItems = 3;
    titles = new Array();
    titles[0] = "<a href='http://www.flashkit.com'>Reviews</a>";
    titles[1] = //like 0"
    titles[2] = //like 0"
    leader.myText.text = "Drag Me";
    for (i = 0; i < menuItems; i++) {
    	_root.leader.duplicateMovieClip("subject" + i, i);
    	_root["subject" + i].myText.html = true;
    	_root["subject" + i].myText.htmlText = titles[i];
    }
    you just need one array
    you don't use getURL because this is text, not a button or a movieClip. therefore you use htmText
    you don't put code which doesn't have an i inside the for loop, otherwise it will be executed menuItems times


    oops..
    maybe you want buttons:
    Code:
    menuItems = 3;
    titles = new Array();
    url = new Array();
    url[0] = "http://www.flashkit.com";
    url[1] = "http://www.microsoft.com";
    url[2] = "http://www.nxsupport.com";
    titles[0] = "Reviews";
    titles[1] = "Reader Reviews";
    titles[2] = "Round Table Reviews";
    leader.myText.text = "Drag Me";
    for (i = 0; i < menuItems; i++) {
    	_root.leader.duplicateMovieClip("subject" + i, i);
    	//assign a variable i to each
    	_root["subject" + i].i = i;
    	//they are buttons, so have to be clickable
    	_root["subject" + i].onRelease = function() {
    		getURL(url[this.i]);
    	};
    	_root["subject" + i].myText.text = titles[i];
    }
    Last edited by nunomira; 03-21-2003 at 04:13 AM.

  5. #5
    Junior Member
    Join Date
    Dec 2000
    Posts
    13
    Hmm..... that didnt work..

    here is what I'm trying to modify:

    http://www.flashkit.com/movies/Inter...7792/index.php

    basically he made a button, then with AS, he duplicated it and with the FOR loop he named all of the buttons, but since the text has to be dynamic, it can't hold any URL properties and I'm trying to go around that problem

    thanks agian

    -Emo

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center