Hi,

Very new to prototype/scriptaculous, but I'm working on a client site,
and wanted to implement a couple of custom controls.  The first one is
a slideshow that fades between images.  By no means complete yet.

I'm having a rather wierd problem though and wondering if anyone can
help shed some light on it.

In my initialize function I'm setting up a number of member variables,
but they don't seem to exist when called by the PeriodicalExecuter
(this.options, this.frontimage, etc).  Can someone explain?

Here's the code:

Effect.SlideShow = Class.create();
Object.extend(Object.extend(Effect.SlideShow.prototype,
Effect.Base.prototype), {

        // Constructor
        initialize: function(element) {
                //alert('Initializing');
                this.element = $(element);
                this.options = Object.extend({
                        slidetime:      5,
                        fadetime:       3,
                        height:         '200px',
                        width:          '200px',
                        images:         new Array()
                }, arguments[1] || {});


                this.frontimage = document.createElement('div');
                this.backimage = document.createElement('div');
                Element.setStyle(this.frontimage, {
                        height:this.options.height,
                        width:this.options.width,
                        position:'absolute',
                        top:0,
                        left:0
                });
                Element.setStyle(this.backimage, {
                        height:this.options.height,
                        width:this.options.width,
                        position:'absolute',
                        top:0,
                        left:0
                });
                this.element.appendChild(this.backimage);
                this.element.appendChild(this.frontimage);

                this.currentbuffer = 0;
                this.imagecursor = 0;
                setInterval('this.shownext', 5000);
                this.pe = new PeriodicalExecuter(this.shownext,
this.options.slidetime);

        },

        // Show Next Image
        shownext: function() {
                //alert(this.frontimage);

                var hiddenbuffer;
                var visiblebuffer;
                if(this.currentbuffer == 0) {
                        hiddenbuffer = this.frontimage;
                        visiblebuffer = this.backimage;
                }
                else {
                        hiddenbuffer = this.backimage;
                        visiblebuffer = this.frontimage;
                }

                Element.setStyle(hiddenbuffer, {background: "url(" +
this.images[this.imagecursor] + ") no-repeat"});


                Effect.FadeOut(visiblebuffer);
                Effect.FadeIn(hiddenbuffer);

                this.imagecursor++;
                if(this.imagecursor > this.options.images.length) {
                        this.imagecursor = 0;
                }
        }


});


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Spinoffs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to