From: "Christine Jones" To: "Philip Karras" Subject: Re: script challenge Date: Wed, 28 Nov 2001 22:39:06 -0600 Hi PHIl!! It works & I even understand where I went wrong. You give great explanations!! Thanks soooooooooooooooooooooo much. Christine ----- Original Message ----- From: "Philip Karras" To: "Christine Jones" Sent: Wednesday, November 28, 2001 9:33 AM Subject: Re: script challenge > OK, Got your objects.js file. > > Now, the first problem is that you are using: > text.charAt[i] but the charAT part is not defined. > That's where the "undefined" is coming from. At this > point you should make a charAt() function: > > // > ---------------------------------------------------- > // Return the jth char from this txt string > // > // inputs: text string, and j > // output: none > // return: jth char from the txt string pk > // > ---------------------------------------------------- > function charAt(txt, j) { > return (txt.substring(j, j+1)); > } > > and call it this way (replace your: tetxt.charAt[i]: > .... + charAt(text, i) + .... > > (I have checked out my suggested charAt function to > see that it really works.) > > Oh, one other suggestion, you will need to look at > your str = string since you will only have one char in > the string if you use "=", you should define str > before the loop: > > var str = ""; > > then inside the loop use: > > str += .....; > > to build up each char into the string at a different > font size & color. > > Last, notice how I wrote the charAt() function above. > I also used a few lines to explain what the function > does, and what the inputs, outputs, and returns are. > It is a very good idea to start doing this for EVERY > function you write. Sometime, simply writing this > description helps clarify your concept of what the > function should be doing. > > Here's how I would document the neon1() function: > > // > ---------------------------------------------------- > // Builds up an html line of the text string with each > // character being a different size and color. > // > // inputs: none, the needed string is in a global var > // output: str - string var of the needed html line. > // return: none > // > ---------------------------------------------------- > > Oops, one last point to remember, it is NEVER a good > idea to declare a var in a loop, some versions of JS > will die because of it. A var is to be declared only > ONCE! So, something like: > > for(i=0; i var FSize = ...; > . > . > . > } > > will cause errors in some browsers since you are > declaring FSize over and over again. It is better to > use: > > var FSize; // declare var once > for(i=0; i FSize = ...; // get new random value > . > . > . > } > > It is also a good idea to comment each line in your > code. Again, this will help with debugging and > sometimes helps clarify your ideas while you're > writing the comment. > > I think I'm done, I hope that helps & I do have it all > working here with the above suggestions. > > Phil K > > ============================== > > > --- Christine Jones wrote: > > Sorry, I think our blizzard went to my head. Here's > > the address > > http://www.geocities.com/cjrentals/ex2_3 > > > > Thanks for your suggestions!! > > Christine > > > > > > ----- Original Message ----- > > From: "Philip Karras" > > To: "Christine Jones" > > Sent: Tuesday, November 27, 2001 8:29 AM > > Subject: Re: script challenge > > > > > > > I can't help without the code. > > > > > > As to your error try reducing the code to the > > smallest > > > possible, then start cutting things out (do keep > > the > > > original in a safe place) and see what it takes to > > get > > > rid of the problem. The add it back in and find > > out > > > why it's a problem > > > > > > Now, as to each letter you'll need to write each > > > letter individually. HTML doesn't care how you > > write > > > it but you'll do something like: > > > > > >

> > > > > >

> > > > > > where ChangeStuff() is a function to change the > > color > > > and size of the present letter, Letter[j] holds > > all > > > the letters in the string, and Length is the > > length of > > > the Letter array. (I know this won't work this > > way, > > > you but since you have it working for the full > > title > > > you should be able to modify this & that to make > > it do > > > what you want.) > > > > > > Hope that helps. > > > > > > Phil > > > > > > --- Christine Jones > > wrote: > > > > Hi Phil :) > > > > > > > > How are you? Thanks for your help with the last > > > > script problem!! > > > > > > > > I wish I could be more help with your NS 6 > > dilemna > > > > but luckily I haven't had > > > > to deal with it. My instructor said not to even > > > > install it---too many bugs > > > > when doing javascript. So we have stuck to IE & > > NS > > > > 4.7, however lately he > > > > has focused entirely on IE (nice!). What little > > I > > > > did do was VERY > > > > frustrating to write the perfect script for IE & > > > > then nothing works in NS. > > > > I just received the book "Javascript Bible" & > > it > > > > has a rather large listing > > > > of the different compatabilities---probably not > > much > > > > help though because you > > > > want to know how to "fix it." > > > > > > > > Interested in helping with another script? If > > not > > > > that's ok. I am on the > > > > right track. This time we had to write code > > from > > > > scratch & it is supposed > > > > to write a text string to the sscreen so that > > the > > > > color & size of EACH > > > > CHARACTER is set up randomly. This effect might > > be > > > > used as a header. I'm > > > > to use at least 5 different text sizes & at > > least 7 > > > > different colors. The > > > > string is to display statically with no > > animation. > > > > > > > > It doesn't like my text array because I get an > > > > undefined error even though > > > > my script is very similar to one that works. > > HHMMHH > > > > Also my script > > > > displays various fonts & colors but not for each > > > > character. I am impressed > > > > that each time I click refresh the font size & > > color > > > > changes, so I know I'm > > > > getting closer. Any suggestions? > > > > > > > > Hope you had a good turkey-day! > > > > > > > > Thanks! > > > > > > > > Christine > > > > > > > > ----- Original Message ----- > > > > From: "Philip Karras" > > > > To: "Christine Jones" > > > > Sent: Thursday, November 15, 2001 8:59 AM > > > > Subject: Re: script challenge > > > > > > > > > > > > > One more thing, I've never been able to get it > > to > > > > work > > > > > (similar things) in NS6.0 so when you find the > > > > correct > > > > > methods for NS6.0 please pass them on to me as > > > > well? > > > > > > > > > > I've tried the ones listed for NS6.0 but > > either > > > > I'm > > > > > not using them correctly, or they simply don't > > > > work. > > > > > (I have NS4.7 working.) > > > > > > > > > > Phil K > > > > > > > > > > ========== > > > > > > > > > > --- Christine Jones > > > > wrote: > > > > > > Hi Phil :) > > > > > > > > > > > > I really appreciate your offer of help. I > > have > > > > > > bought the Javascript bible and am getting a > > > > better > > > > > > feel for the basics but am having the most > > > > trouble > > > > > > with multiple arrays & combining those > > arrays > > > > with > > > > > > multiple functions. I've looked at some > > online > > > > > > tutorials but again not seeing much using > > > > multiple > > > > > > arrays & combining those arrays with > > multiple > > > > > > functions. > > > > > > > > > > > > The code that I am currently working on I've > > > > loaded > > > > > > onto the web. I haven't gotten object > > expected > > > > > > error when I've run it using IE or NS 4.7 > > > > > > > > > > > > http://geocities.com/cjrentals/mouse > > > > > > > > > > > > I need to edit this code so it will "achieve > > the > > > > > > following functionality: clicking a mouse > > button > > > > > > should fix a point in the browser's window > > and > > > > put a > > > > > > red dot there. The status bar of the browser > > > > should > > > > > > display the "Manhattan distance" between the > > > > current > > > > > > mouse position and the fixed point. The > > > > Manhattan > > > > > > distance d between points (x,y) and (x',y') > > is > > > > > > computed according to the following formula: > > d = > > > > |x > > > > > > - x'| + |y - y'|, where |x - x'| is the > > absolute > > > > > > value of the difference." > > > > > > > > > > > > My first step is to get the red dot placed. > >