Mousewheel scrlling of external SWF loaded into MC not working correctly

Hi all,

I’m completely lost with the following problem:

I created a flash site with Flash 8 and AS2.

The site loads external swf files to be displayed as the content on the site. Each button click moves to a new frame that loads a different swf.

Now here is the problem. The external swf files have a good amount of content and I use scrollbars to scroll through them. That works fine so far.

I now added a function to make the scrollbar work with the mousewheel. This works fine as long as the swf is loaded by itself.
When the swf is loaded into the site (mainpage.swf) it stops scrolling half way down.

This happens only when using the mousewheel and ONLY when the external swf was not the first one loaded.

It’s a strange behaviour I can’t make any sense of.

please heck it out at http://www.xtreme-sound.de/site/
First page works fine once you click on ‘Download shop’ the mousewheel is not working correctly. It stops about half way down.

You can load the external swf at http://www.xtreme-sound.de/site/download.swf and http://www.xtreme-sound.de/site/aktuell.swf (first page)

Does anyone know about this problem? Strange is that it works fine when the swf is loaded external. I first thought it was a conflict with some coding of the swf that loads the external file but that is not the case.
I created a complete new swf to load it and made sure it was clean regarding the AS 2 code and naming. I had the same problem thers.

Could this be some kind of Flash Bug??

Any idea??

Thanks a buch,

Tino

Any preloader code in the external swfs?

nope no preloaders.

I think the problem is in the code.

scrolling = function () {
    var scrollHeight:Number = scrollTrack._height;
    var contentHeight:Number = contentMain._height;
    var scrollFaceHeight:Number = scrollFace._height;
    var maskHeight:Number = maskedView._height;
    var initPosition:Number = scrollFace._y=scrollTrack._y;
    var initContentPos:Number = contentMain._y;
    var finalContentPos:Number = maskHeight-contentHeight+initContentPos;
    var left:Number = scrollTrack._x;
    var top:Number = scrollTrack._y;
    var right:Number = scrollTrack._x;
    var bottom:Number = scrollTrack._height-scrollFaceHeight+scrollTrack._y;
    var dy:Number = 0;
    var speed:Number = 10;
    var moveVal:Number = (contentHeight-maskHeight)/(scrollHeight-scrollFaceHeight);
    
    var mwheel = new Object();
    var currPos:Number = this._y;


        
mwheel.onMouseWheel = function(delta) {
//trace("delta: " + delta );
if (contentHeight>maskHeight) {
if (delta<=0){
            
            if (contentMain._y-speed>finalContentPos) {
                if (scrollFace._y>=bottom) {
                    scrollFace._y = bottom;
                } else {
                    scrollFace._y += speed/moveVal;
                }
                contentMain._y -= speed;
            } else {
                scrollFace._y = bottom;
                contentMain._y = finalContentPos;
                delete this.onEnterFrame;
            }
            
}
else if (delta>=0){
            
            if (contentMain._y+speed<maskedView._y) {
                if (scrollFace._y<=top) {
                    scrollFace._y = top;
                } else {
                    scrollFace._y -= speed/moveVal;
                }
                contentMain._y += speed;
            } else {
                scrollFace._y = top;
                contentMain._y = maskedView._y;
                delete this.onEnterFrame;
            }
            }
            
}
 };
Mouse.addListener(mwheel);
    
    
    scrollFace.onPress = function() {
        var currPos:Number = this._y;
        startDrag(this, false, left, top, right, bottom);
        this.onMouseMove = function() {
            dy = Math.abs(initPosition-this._y);
            contentMain._y = Math.round(dy*-1*moveVal+initContentPos);
        };
    };
    scrollFace.onMouseUp = function() {
        stopDrag();
        delete this.onMouseMove;
    };
    btnUp.onPress = function() {
        this.onEnterFrame = function() {
            if (contentMain._y+speed<maskedView._y) {
                if (scrollFace._y<=top) {
                    scrollFace._y = top;
                } else {
                    scrollFace._y -= speed/moveVal;
                }
                contentMain._y += speed;
            } else {
                scrollFace._y = top;
                contentMain._y = maskedView._y;
                delete this.onEnterFrame;
            }
        };
    };
    btnUp.onDragOut = function() {
        delete this.onEnterFrame;
    };
    btnUp.onRelease = function() {
        delete this.onEnterFrame;
    };
    btnDown.onPress = function() {
        this.onEnterFrame = function() {
            if (contentMain._y-speed>finalContentPos) {
                if (scrollFace._y>=bottom) {
                    scrollFace._y = bottom;
                } else {
                    scrollFace._y += speed/moveVal;
                }
                contentMain._y -= speed;
            } else {
                scrollFace._y = bottom;
                contentMain._y = finalContentPos;
                delete this.onEnterFrame;
            }
        };
    };
    btnDown.onRelease = function() {
        delete this.onEnterFrame;
    };
    btnDown.onDragOut = function() {
        delete this.onEnterFrame;
    };
    
    if (contentHeight<maskHeight) {
        scrollFace._visible = false;
        btnUp.enabled = false;
        btnDown.enabled = false;
    } else {
        scrollFace._visible = true;
        btnUp.enabled = true;
        btnDown.enabled = true;
    }
};
scrolling();




I think some variable is being caried over when loading a new swf. Therefore the varibales are not correct anymore.

There is the delete this.onEnterFrame; that IMO should clear it but I’m not sure. I’m not AS Pro and made this working by trying.

Any help is highly appreciated.

Tino

I think the problem is that your not preloading your swf so the scroller is unable to get a true height.

that’s a good point. scrolling however works perfect when using the scrollbar up and down buttons or when dragging the scrollface.

I’d like to preloade them though anyway. Is there a function to easily do this?

thanks a lot,
Tino

Plenty of info about preloaders here

Thanks for the tip but that wasn’t the issue. I just found a solution however would like to have some advice.

It seems that the variables are getting false values when visiting the sceond external swf. I assume that is due to the load of the variables in the first swf.

When I change the varible names in the AS code used for the mousewheel scrolling and have differen ones in each external swf it works fine.

Now my question: Is there a way to somehow “clear” the variables before the scrolling function is loaded? That way I wouldn’t have to change variables on 10 extrenal swfs and could keep the same code for each scroller.

Thanks a lot,

Tino

I think I’ll have do add Mouse.removeListener(mwheel); somewhere but I have no clue where :smiley:

help is appreciated

Tino