Page 11 of 33 FirstFirst ... 91011121321 ... LastLast
Results 101 to 110 of 327

Thread: new to flash 2004 mx

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

    Default

    i just taken a peek. the beginning part is very familer. Okie, this is just the linking of the files right? I seeing some similarites between the old marquee & the new marquee.

    This is only a test. You'll have to figure out how to plug it into your marquee. But it should give you enough ideas about how to go about it.
    eh, don`t quite get what you saying? do you mean the directions or the linking of the data?

    Oh ya, so should i use the one you gave yesterday & this is for practice

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

    Default

    The new code isn't for the marquee. It's how you would parse all the data with one text file.

    Change your logos.txt file to the following format:

    images.jpg|http://www.website.com

    and run the new code. You'll understand it.

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

    Default

    the 1st line is storing the raw data( pics etc), the 2nd is storing the images names,3rd is the url list,the 4th line is
    LoadVars object to obtain verification of successful data loading, progress indications, and stream data while it downloads( works the same way as xml)
    the 5th line is display the data in the text file exactly in the file. ( qns1? i read from a site, it is using lv.onData = function(thetext:String), but you changed the thetext to src, why is that so?)
    for the 6th line I not too sure how to explain The 7th line is a for loop, this command will loop through all the images in the folder the 1st pic starts from 0. the 8th line is split("|") meaning what kind of symbol etc you are
    using to seperate the two or more datas. the 9th line is line is push the image untill later & 10 line is the same for url( qns2 for the image i get the idea , but why is the url having [1] instead of [0]?) line 11 is testme( the name of next function
    so what name you going is put is al`right. line 12 is the function of testMe. line 13 (qns 3 i not too sure about that, mind explaining?)line 14 is similar to line 15 & 16. 14 is the pic arrangment in the image folder, 15 is the tracing of the logo names step by step
    16 is the url blah blah. line 17 is trace the thing to separate the 2 datas (qns 4 why we can`t put "|" instead of "") FINALLY, line 18 is load all the stuff data etc from the text file


    ps: sorrie to anyone who read the post .

    correct me if i having any mistakes ( newbie in action )

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

    Default

    Whoa there. That's a lot. Why don't I explain it my way and then you can judge if you have more questions.

    First, lets forget the testMe() function. That's only for testing purposes. It has nothing to do with understanding what's going on.

    So, we're left with this:
    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 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");
    1. The Arrays
    At the top of the AS, we set three variables which represent three arrays. An array is a simple way to hold multiple pieces of data and still have one reference point.

    Here we have three arrays set: rawdata, images, and urls
    The rawdata array contains the full string that we parse from text file (image.jpg|http://www.website.com). The images array contains only the image portion or the part before the delimiter (image.jpg). The urls array contains the values that come after the delimiter.

    How we separate what's before and after the delimiter is coming up.

    2. The loadVars
    I think you get this part. It's what you've been doing all along. For the benefit of a full post, loadVars is the method used to "load" the "vars" or variables from an external source.

    3. The onData event
    The onData event fires when all of the data from the external source has been brought into Flash and is ready to be parsed.

    You ask about an alternate syntax:
    Code:
    lv.onData = function(thetext:String)
    lv and thetext are both user-set variables. They are not explicit AS syntax. So this:

    Code:
    popsicles.onData = function(bananas:String)
    will work just as well (but tastier) than any other syntax for those portions.


    4. Split the Linebreaks
    When the onData event fires, Flash has the external data in the following format:
    Code:
    image.jpg1|www.website1.com
    image.jpg2|www.website2.com
    image.jpg3|www.website3.com
    It's exactly as what's in the text file. We need to break this down into manageable bits so that we can work the rest of the application properly. First, let's get rid of the line breaks.

    Code:
    rawdata = src.split("\r\n");
    This handy-dandy bit of code says take the source data (src, again this can be anything) and split it wherever you encounter \r\n (signify line breaks) and assign it to the variable array of rawdata. At the end of that method, we're left with data that looks like this:

    Code:
    rawdata = array("image.jpg1|www.website1.com", "image.jpg2|www.website2.com", "image.jpg3|www.website3.com");
    Each line of our external .txt file is now one element in an array. We can access a specific array with using it's index. For example:

    rawdata[0] would equal image.jpg1|www.website1.com
    rawdata[1] would equal image.jpg2|www.website2.com

    and so on...

    Notice that the count starts at zero. This is important.


    5. Split based on delimiter
    Now that we have the line breaks out, we'll need to separate the raw data that we have into the two parts we need -- the images and urls. To do this, we use a simple for loop:

    Code:
    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
    	}
    The for loop has the following conditions: it starts at 0 (because remember, arrays start at 0) and it's going to perform as many loops as there are elements in the raw data array minus 1. Again, because the array count starts at 0 but the loop counter starts at 1, we need to account for this and subtract one from the rawdata.length value.

    So let's split it:
    Code:
    info = rawdata[i].split("|");
    By now you should be familiar with the split. This code is saying split the rawdata element where we encounter the "|" character. So it takes image.jpg|http://www.website.com and splits it into image.jpg and http://www.website.com.

    Remember that since this is in a for loop, we're only dealing with one element at a time. So, it performs this action on the first line of the text file, then on the second line, the on the third line. It's not all at the same time.


    6. Array Push
    As I explained earlier, we can access specific array values by using an index. When the first line is split based on the delimiter, the result is this:

    Code:
    info = array("image1.jpg", "http://www.website1.com");
    So, to access the image we would say info[0] and to access the website, we would say info[1].

    Ok, we have the values, that should be it, right?

    Not quite... Since we're doing this in a loop, each loop wipes the info array clean and inserts a new value.

    So if at the end of everything you were to test for the values of info[0] and info[1] were it would show you the value of the last line in the text file. Why? Because it has looped through them all and the last value is just what's left.

    So...to fix for this, what we need to do is maintain a separate array to hold these values. We already set these arrays up in the first three lines.

    So, we use the array.push() method. array.push() bascially takes whatever value you feed to the function and adds it to the end of the array in question.

    Code:
    images.push(info[0]);
    urls.push(info[1]);
    The first line adds the image names to the images array. The second adds the url paths to the urls array.


    That was long...sorry if it's confusing but it seemed like you were getting confused with the traces and everything so I thought I'd go over it again.

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

    Default

    Sorrie medyman, I was just trying to understand it in my terms. So i just wrote it down & erm let you check if i was on the wrong side(oh i was indeed wrong in some parts). That nothing wrong with your explaination though its quite long ( thanks for trying to make it more digestable)

    oh,the traces i seriously thought its was used to track down stuff, though I know what the purpose of it in actionscript. my mistake

    lol, sorrie for making write you the whole stuff like an entire tutorial.

    Hey i have a request to make, if you don`t mind, lol. Could i continue posting erm my noob-ish terms, if i`m wrong in my understanding, you could erm correct me. sounds more like a plea than a request. haha. Of course you can disagree, you are rather busy of late, so you might not have time to go through all of it

    This sounds veri noob-ish since i working with it for 2 months now .I just to ask what the colors in the as means Well here goes, the Array is a command, the black words is the variables etc,

    Thanks
    Last edited by hyk; 04-25-2008 at 06:55 AM.

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

    Default

    Well those colors can be customized. I changed mine a while ago and I can't remember what the default ones were. But they're only for ease of reading code. It has no functional value.

    If you do some searches for "syntax highlighting", you might come up with more info.

    About your first request/plea, lol, go right ahead. Just, if you're going to do things line-by-line like that, it'll be easier for me to follow along and answer your questions if you:

    1) Put in a line break between each line's explanation.
    2) Bold the questions you would like answers to.
    Last edited by Medyman; 04-26-2008 at 03:27 PM.

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

    Default

    About your first request/plea, lol, go right ahead. Just, if you're going to do things line-by-line like that, it'll be easier for me to follow along and answer your questions if you:

    1) Put in a line break between each line's explanation.
    2) Blog the questions you would like answers to.
    ok, thanks alot ( you one step closer to getting the longest thread in this forum )

    hey, the tutorial you wrote is talking about the split() method & how to use it right etc? lol, its so detailed that i print a copy to read

    i learning step1( how to use split () method to make flash communicate with the 2 variables in the text files ( url &jpg). 2nd step( the moving direction & speed of the marquee ) step3 ( the rollOver, think we gone through that few weeks back)

    Just checking it out, I trying to add more content in my report Look kinda of bare now.

  8. #108
    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
    ok, thanks alot ( you one step closer to getting the longest thread in this forum )

    hey, the tutorial you wrote is talking about the split() method & how to use it right etc? lol, its so detailed that i print a copy to read

    i learning step1( how to use split () method to make flash communicate with the 2 variables in the text files ( url &jpg). 2nd step( the moving direction & speed of the marquee ) step3 ( the rollOver, think we gone through that few weeks back)

    Just checking it out, I trying to add more content in my report Look kinda of bare now.
    I wonder what actually is the longest thread, lol.

    Anyway, yes I covered the split in my write up. I'm not sure if you're familiar with PHP. But if you are, the split() method is the same thing as the explode() function.

    Don't know if that helps you any.

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

    Default

    eh, i don`t anything about php. The only thing i know about web development stuff is eh, html,xml & ya flash

  10. #110
    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
    eh, i don`t anything about php. The only thing i know about web development stuff is eh, html,xml & ya flash
    Oh...well, even if you don't. It's not hard to pick up.

    It basically takes a string and splits it into an array based on the delimiter.

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
  •