Page 12 of 33 FirstFirst ... 2101112131422 ... LastLast
Results 111 to 120 of 327

Thread: new to flash 2004 mx

  1. #111
    Join Date
    Mar 2008
    Posts
    222
    Thanks
    10
    Thanked 3 Times in 3 Posts

    Default

    i sort of get the idea. oh btw, so for now right the split method is able to read the url& images variables right? ( i feel like running round & round the same circle). I never tried out in school yet. sorrie if you are repeating your sentence

    If i right for this part, then just to check out something if i just write

    Code:
    something.push
    will the program read another variable or even more stuff? (provided its in the data is in the same text file?

  2. #112
    Join Date
    Mar 2007
    Location
    Currently: New York/Philadelphia
    Posts
    2,735
    Thanks
    3
    Thanked 519 Times in 507 Posts

    Default

    Yes, as I explained in my long paragraph, the new code parses the images and urls from one text file.

    Think of the split() function as something that breaks larger pieces of data in smaller ones. First we split() the entire text file into individual lines. Then, we split the individual lines into images and urls.

    Remember, each line in the text files is set up like this: images.jpg|http://www.website.com

    The array.push() has nothing to do with reading a value from an array. It writes to the array.

    If I have an array like this:

    Code:
    fruits = array("apple", "orange", "grape");
    and I do this:
    Code:
    fruits.push("banana");
    It will add banana to the end of the fruits array. So you'll get.

    Code:
    fruits = array("apple", "orange", "grape", "banana");
    So, back to the marquee example. Once the for loop completes, all of the images and the URLs will be in their separate arrays because of this method.

    I hope that makes sense.
    Last edited by Medyman; 04-27-2008 at 03:02 PM.

  3. #113
    Join Date
    Mar 2008
    Posts
    222
    Thanks
    10
    Thanked 3 Times in 3 Posts

    Default

    sure, getting clearing abit. I orginally thought the split must be used to split 2 things then with another variable another split. ok, thanks alot for clearing my doubt
    Using the example on the code u gave ( long but veri detailed tutorial, u provided if i want to add in more stuff, at the start i put.

    var bananas //declare variables
    ...
    ....
    banana. push(info[2]) push......

    if more stuffs just keep adding it in the script & also the text file right?

  4. #114
    Join Date
    Mar 2007
    Location
    Currently: New York/Philadelphia
    Posts
    2,735
    Thanks
    3
    Thanked 519 Times in 507 Posts

    Default

    Why do you need to add more variables?

    Are you adding more information to the marquee? Like a caption or something? You're really abusing text files, then. XML would make this so much easier.

    Anyway, I won't go down that same line of rhetoric again.

    If you want to add more information, you would have to format your text file like so:

    images.jpg|http://www.website.com|the text you want to appear
    The AS, would then be:
    Code:
    var rawdata:Array = [];  //  stores all the raw data
    var images:Array = [];  //  stores symbol image file names
    var urls:Array = [];  //  stores associated website URIs
    var captions:Array = []; // stores captions associated with the thumbnails
    
    var lv:LoadVars = new LoadVars();
    
    lv.onData = function(src:String) {
    	rawdata = src.split("\r\n");  // Seperates the raw data based on line breaks.  Output image.jpg|http://www.website.co,
    	for(i=0;i<rawdata.length-1;i++) {   // Loops through all of the raw data
    		info = rawdata[i].split("|");  // Seperates each array element by a delimiter (vertical bar).  Resulting array:  info[rawdata[i]] = (info[0], info[1]) or (image, uri)
    		images.push(info[0]);  // "Pushes" the 0th value (the image path) to the images array for later access
    		urls.push(info[1]);  //  "Pushes" the 1st value to the urls array for later access
    		captions.push(info[2]) // "Pushes" the 2nd value to the captions array
    	}
    	
    }
    
    lv.load("logos.txt");
    The highlighted bits are the changes. I just used the "captions" as an example. If you want to call it "bananas", that works too.

  5. #115
    Join Date
    Mar 2008
    Posts
    222
    Thanks
    10
    Thanked 3 Times in 3 Posts

    Default

    Sorrie medy, its completed unrelated to my project . I just curious that all if i realli understand this part anot. Seens that i understand the split part already

    I go work on it when i in school tomorow (doing the text file etc)


    Thanks alot
    Last edited by hyk; 04-27-2008 at 04:48 AM.

  6. #116
    Join Date
    Mar 2007
    Location
    Currently: New York/Philadelphia
    Posts
    2,735
    Thanks
    3
    Thanked 519 Times in 507 Posts

    Default

    Quote Originally Posted by hyk View Post
    Sorrie medy, its completed unrelated to my project . I just curious that all if i realli understand this part anot. Seens that i understand the split part already)
    Ahh, gotcha. No harm in learning. I was just wondering what your plan was for it.

    I'm glad you get the split() method now.

  7. #117
    Join Date
    Mar 2008
    Posts
    222
    Thanks
    10
    Thanked 3 Times in 3 Posts

    Default

    Eh, i better post my script down. when i run it nothing happens. ?? I might have left out something or another. I go check it again Let me just comfirm some stuff, if you don`t mind

    rawdata is the images* folder
    images is the images name
    url is url names
    the logo text is a txt file of both images & url?

    Code:
    #include "mc_tween2.as"
    
    var rawdata:Array = [];  //  stores all the raw data
    var images:Array = [];  //  stores symbol image file names
    var urls:Array = [];  //  stores associated website URLs
    
    var lv:LoadVars = new LoadVars();
    
    lv.onData = function(src:String) 
    {
    	rawdata = src.split("\r\n");  // Seperates the raw data based on line breaks.  Output image.jpg|http://www.website.co,
    	for(i=0;i<rawdata.length-1;i++) {   // Loops through all of the raw data
    		info = rawdata[i].split("|");  // Seperates each array element by a delimiter (vertical bar).  Resulting array:  info[rawdata[i]] = (info[0], info[1]) or (image, uri)
    		images.push(info[0]);  // "Pushes" the 0th value (the image path) to the images array for later access
    		urls.push(info[1]);  //  "Pushes" the 1st value to the urls array for later access
    	}
    }
    
    lv.load("logos.txt");
    Code:
    
    
    Last edited by hyk; 04-28-2008 at 01:09 AM.

  8. #118
    Join Date
    Mar 2007
    Location
    Currently: New York/Philadelphia
    Posts
    2,735
    Thanks
    3
    Thanked 519 Times in 507 Posts

    Default

    Nothing is supposed to happen. That code is to only parse the data, not to display it.

    That is why I had all those traces in there before, if you'll remember. If you want to see what the output would be, place that testMe() function back in.

    Again, it's only for testing -- so you actually get some results and can confirm that it's working. You won't need any of that in your marquee code.

    Also, just to confirm. Make sure logos.txt is in the same directory as the .fla.

  9. #119
    Join Date
    Mar 2008
    Posts
    222
    Thanks
    10
    Thanked 3 Times in 3 Posts

    Default

    That is why I had all those traces in there before, if you'll remember. If you want to see what the output would be, place that testMe() function back in.

    Again, it's only for testing -- so you actually get some results and can confirm that it's working. You won't need any of that in your marquee code.

    Also, just to confirm. Make sure logos.txt is in the same directory as the .fla.
    oh okie, Its just for testing if the things is correct etc(troubleshooting) logos.txt I used it for putting the URL & images names right?

  10. #120
    Join Date
    Mar 2007
    Location
    Currently: New York/Philadelphia
    Posts
    2,735
    Thanks
    3
    Thanked 519 Times in 507 Posts

    Default

    Quote Originally Posted by hyk View Post
    oh okie, Its just for testing if the things is correct etc(troubleshooting) logos.txt I used it for putting the URL & images names right?
    Yup, exactly.

Bookmarks

Posting Permissions

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