A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Easy if you know how? I just dont know how!

  1. #1
    Junior Member
    Join Date
    Dec 2005
    Posts
    23

    Easy if you know how? I just dont know how!

    Hi Guys...

    I am learning AS quickly but need some help simplyfying this bit of code, I have to create 43 of them and know that there must be a more simplyfied way of doin it! Can anyone show me the light?

    Code:
    thisText = new LoadVars();
    thisText.load("exhibitor1.txt");
    thisText.onLoad = function(success) {
        if (success) {
            title1.text = thisText.exhibitor1_name;
    		}
    }
    thisText2 = new LoadVars();
    thisText2.load("exhibitor2.txt");
    thisText2.onLoad = function(success) {
        if (success) {
            title2.text = thisText2.exhibitor2_name;
    		}
    }
    Thanks

  2. #2
    Flashmatics silentweed's Avatar
    Join Date
    Mar 2005
    Location
    London, UK
    Posts
    4,875
    use XML instead and put all the exhibitors details in there..it would be a nightmare trying to update and also load 43 different text files... if you don't know XML look at the video tutorial Flash and XML at www.gotoandlearn.com
    Flashmatics | Flashmatics Library (free downloads)
    -----------------------------------------------------
    Latest Projects:
    The Dead Room | Are You Smarter | Prison Break (Frame A Friend) | Beck's Fusions | The 24 Experience

    -----------------------------------------------------
    Flash Certified Developer

  3. #3
    Junior Member
    Join Date
    Dec 2005
    Posts
    23
    Yeah i thought about xml but its too late in the day to rework the whole project.

    If i can just simplyfy this code life would be so much easier :-)

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

    Maybe you can adapt this to what you are trying to do...

    Code:
    stop();
    var _MAIN = this;
    for (var i = 1; i <= 43; i++) {
    	var myText = _MAIN["thisText" + i];
    	myText = new LoadVars();
    	myText.load("exhibitor" + i + ".txt");
    	myText.num = i;
    	myText.onLoad = function(success) {
    		if (success) {
    			_MAIN["title" + this.num].text = this["exhibitor" + this.num + "_name"];
    		}
    	};
    }
    /*
    // ***** Note, changes the first to include the number '1', so it mirrors the subsequent ones. So it would be like this...
    thisText1 = new LoadVars();
    thisText1.load("exhibitor1.txt");
    thisText1.onLoad = function(success) {
    	if (success) {
    		title1.text = thisText1.exhibitor1_name;
    	}
    };
    */

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