I forgot all about the 30 days of mootools. Thank you so much. About a year ago I was blown away by prada.com's background behavior, hence the PradaBackground class.
This is my first class ever. Not just my first mootools class, but my first class--period. I once was lost but now I'm found :) I feel like Pinnochio, "I'm a real boy!" http://sosaladesign.com/PradaBackground/ On Mar 15, 1:14 pm, pradador <[email protected]> wrote: > I'd suggest taking a look at the set of tutorials > @http://www.consideropen.com/blog/2008/08/30-days-of-mootools-12-tutor... > They have some great info on everything from basic syntax to building > MooTools classes. > > As for your specific question: > > The slides[] on line 13 is an instance variable that just sets up > this.slides as an empty array. This is just to ensure that even an > empty class has an empty slides array instead of an undefined slides[] > variable. The slides[] in line 4 is part of the Options functionality > of MooTools classes. It's actually another slides variable that lives > in "this.options.slides" instead of "this.slides". > It's there because class which implement Options let you initialize > them like this: > > var mySlideshow = new SimpleSlideShowDemo({ > slides: [slide1, slide2, slide3] > > }); > > Very briefly, when the class is initialized, the statement > "this.setOptions(options);" takes the options you passed in and > replaces the default values you see in the Options instance variable. > So if you use my example above, this.options.slides goes from an empty > array to the array I passed containing all the slides. Then, the > statement "this.addSlides(this.options.slides);" adds the slides from > the this.options.slides array to the array this.slides in the format > required by the slideshow (You can see the code for addSlides in step > 3). > > On Mar 13, 11:53 pm, rpflo <[email protected]> wrote: > > > > > Hey folks, > > > I just started programming (both PHP and javascript) less than a year > > ago and have been able to cook up some stuff that impresses me, and > > sometimes my wife. But at the moment everything I do in mootools is > > pretty much something like this: > > > $('something').addEvent('click',function(){ > > // Do some stuff with other selectors and unmanageable code > > > }); > > > ... and then a lot of copy/pasting of the same code and then just > > tweaking the selectors or adding a slight change. > > > I'll create functions for stuff that I use throughout an application > > to avoid repetition, but seriously, there's a better way and I think > > I'm ready to figure it out. But I look at the stuff I create and > > there's a voice saying my head "~Ryan ... you should just have a class > > for this and save yourself tons of code~" and then I feel horrible > > that my subconscious mocks me. > > > I think I understand what a class is, and for the most part how to use > > one (after all, pretty much everything in mootools is a class). > > However, the mootools docs don't help. I'll never have a cat named > > Micia in real life, let alone a web app. > > > I've tried dissecting other people's classes but when I look at the > > code and try to tweak it there are strange pieces that don't make > > sense to me and don't look very "moo"-ey. The only javascript I > > really know is mootools: "raw" javascript sticks out like a sore thumb > > and my brain goes to mush. > > > I visited clientcide's "How to write a mootools Class" > > athttp://www.mootorial.com/wiki/mootorial/09-howtowriteamootoolsclass > > but even then it's a little over my head. (i.e. on step two there's > > slides[] on line 4 and slides[] on line 13. Why?) > > > I'm going to keep poking that but in the meantime I'm looking for some > > pointers and resources online. Maybe even if somebody is willing to > > let me send you my code, that I think ought to be a class, and then > > help me write one or two. > > > Thanks so much!
