dcsimg
A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Can i turn vars into a link/button

  1. #1
    Junior Member
    Join Date
    Aug 2008
    Posts
    28

    Can i turn vars into a link/button

    I have this textfield in wich i load some vars when a button is clicked.
    How can i make a sort of button of the loaded vars?
    So if i click on the first title; i go to the right txt-file!?

    Here's the code so far:
    code:
    //vars instellen

    //titels
    var title1:String = "Maan Fotografie";
    var title2:String = "Vertigo-/zoomeffect-fotografie";

    //datums
    var date1:String = "16-03-2009";
    var date2:String = "xx-xx-xxxx";

    //categorien
    var cat1:String = "Technieken";
    var cat2:String = "Achtergronden";
    var cat3:String = "Tips & Trucs";


    //programma


    var content_lv:LoadVars = new LoadVars ();
    content_lv.onLoad = function (success:Boolean) {
    if (success) {
    content_txt.html = true;
    content_txt.htmlText = this.ms;
    }
    else {
    trace ("Error loading text file!");
    }
    };


    home_btn.onRelease = function () {
    content_txt.text = title1 + "\n" + date1 + " | " + cat1 + "\n\n" + title2 + "\n" + date2 + " | " + cat1;
    }

    date_btn.onRelease = function () {
    content_lv.load ("Maan Fotografie.txt");
    };

    var cat_lv:LoadVars = new LoadVars ();
    cat_lv.onLoad = function (success:Boolean) {
    if (success) {
    content_txt.html = true;
    content_txt.htmlText = this.ms;
    }
    else {
    trace ("Error loading text file!");
    }
    };

    cat_btn.onRelease = function () {
    content_txt.text = cat1 + "\n\n" + cat2 + "\n\n" + cat3;
    };



    Can it be done!?
    Please help?

  2. #2
    :
    Join Date
    Dec 2002
    Posts
    3,518

    Maybe you can adapt this...

    Code:
    //vars instellen
    //titels
    var title1:String = "Maan Fotografie";
    var title2:String = "Vertigo-/zoomeffect-fotografie";
    //datums
    var date1:String = "16-03-2009";
    var date2:String = "xx-xx-xxxx";
    //categorien
    var cat1:String = "Technieken";
    var cat2:String = "Achtergronden";
    var cat3:String = "Tips & Trucs";
    //
    var link1:String = "Maan.txt";
    var link2:String = "Vertigo.txt";
    //programma
    var content_lv:LoadVars = new LoadVars();
    content_lv.onLoad = function(success:Boolean) {
    	if (success) {
    		content_txt.html = true;
    		content_txt.htmlText = this.ms;
    	} else {
    		trace("Error loading text file!");
    	}
    };
    function loadTxt(file){
    	content_lv.load(_root[file]);
    }
    home_btn.onRelease = function() {
    	content_txt.html = true;
    	content_txt.htmlText = "<a href=\"asfunction:loadTxt,link1\">"+ title1 + "\n" + date1 + " | " + cat1 + "</a>\n\n <a href=\"asfunction:loadTxt,link2\">" + title2 + "\n" + date2 + " | " + cat2 + "</a>";
    };

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