|
-
onMouseWheel problem
Hi all,
I have a scrolling dynamic text, and I made it support mouse wheel also.
The scrolling text is part of a movie that loads externally (on _level2).
I am making a site with the main menu on a level, and the other pages load on _level2 (so all pages are loaded externally, including the page with the scroller). I am saying this because my problem occurs when I visit another page (load another page on _level2), and then I come back to the page that contains the scroller (load the scroller movie on _level2) the mouse wheel works wird, meaning it scrolls more than it did last time.
So the first time you visit the scrolling text page, the mouse wheel scrolls about 20 pixels with every scroll, if I press a button to visit another page and then come back, the mouse wheel will scroll about 60 pixels with every scroll, and so on. The distance keeps increasing, only if I go to another page and then come back. Weird ain't it? 
Here is the code (the onMouseWheel code is at the end)
PHP Code:
import mx.transitions.*;
import mx.transitions.easing.*;
var First=_level3.loadXMLS[_level3.firstMovie]
var _css = new TextField.StyleSheet();
function loadXML(loaded) {
if (loaded) {
_root.info = this.firstChild.childNodes[0].firstChild.nodeValue;
_root.heights = this.firstChild.childNodes[1].firstChild.nodeValue;
_css.load("colors.css");
_css.onLoad = function(){
main.scroller.styleSheet = _css
pageTitles.styleSheet = _css
_level3.preloader_mc.stop ()
_level3.preloader_mc._visible = false
TransitionManager.start(_root.content_mc, {type:Wipe, direction:Transition.IN, duration:1, easing:Strong.easeOut, startPoint:6});
};
main.scroller.htmlText = _root.info
main.scroller.html = true
main.scroller.styleSheet = _css
main.scroller.autoSize = "left";
main.scroller.text = _root.info;
if(main.scroller._height < mask_mc._height){
up_btn._visible = false;
dragger._visible = false;
bar._visible = false;
down_btn._visible = false;
}
bottom = /*(main._y+mask_mc._height-main._height)*/ - _root.heights
} else {
content = "Error Loading File";
}
}
myXML = new XML();
myXML.ignoreWhite = true;
myXML.onLoad = loadXML;
if (First != undefined) {
myXML.load(First)
} else{
Txt.text="No Xml file specified yet.."
}
//LOADING THE XML FROM THE main_menu.xml
var File=_level3.loadXMLS[_level3.currentMovie]
///////////////////////////////////////////////////////////
if (File != undefined) {
myXML.load(File)
} else{
Txt.text="yoyo"
}
///////////////////////////////////////////////////////////
stop();
space = 0;
friction = 0.9;
speed = 4;
y = dragger._y;
top = main._y;
bottom = (main._y+mask_mc._height-main._height-space) - _root.heights
dragger.onPress = function() {
drag = true;
this.startDrag(false, this._x, this._parent.y, this._x, this._parent.y+this._parent.bar._height-this._height);
dragger.scrollEase();
};
dragger.onMouseUp = function() {
this.stopDrag();
drag = false;
};
bar.onPress = function() {
drag = true;
if (this._parent._ymouse>this._y+this._height-this._parent.dragger._height) {
this._parent.dragger._y = this._parent._ymouse;
this._parent.dragger._y = this._y+this._height-this._parent.dragger._height;
} else {
this._parent.dragger._y = this._parent._ymouse;
}
dragger.scrollEase();
};
bar.onMouseUp = function() {
drag = false;
};
moveDragger = function (d) {
if ((dragger._y>=y+bar._height-dragger._height && d == 1) || (dragger._y<=y && d == -1)) {
clearInterval(myInterval);
} else {
dragger._y += d;
dragger.scrollEase();
updateAfterEvent();
}
};
up_btn.onPress = function() {
myInterval = setInterval(moveDragger, 20, -1);
};
down_btn.onPress = function() {
myInterval = setInterval(moveDragger, 20, 1);
};
up_btn.onMouseUp = down_btn.onMouseUp=function () {
clearInterval(myInterval);
};
up_btn.onRollOver = function() {
this.gotoAndPlay("over");
};
up_btn.onRollOut = function() {
this.gotoAndPlay("out");
};
down_btn.onRollOver = up_btn.onRollOver;
down_btn.onRollOut = up_btn.onRollOut;
up_btn.onPress = function() {
myInterval = setInterval(moveDragger, 20, -1);
};
down_btn.onPress = function() {
myInterval = setInterval(moveDragger, 20, 1);
};
up_btn.onReleaseOutside = function() {
this.gotoAndPlay("out");
}
down_btn.onReleaseOutside = function() {
this.gotoAndPlay("out");
}
MovieClip.prototype.scrollEase = function() {
this.onEnterFrame = function() {
if (Math.abs(dy) == 0 && drag == false) {
delete this.onEnterFrame;
}
r = (this._y-y)/(bar._height-this._height);
dy = Math.round((((top-(top-bottom)*r)-main._y)/speed)*friction);
main._y += dy;
};
};
dragger.originY = dragger._y;
dragger.originX = dragger._x;
scrollSpeed = 5
//cosa=main.scroller._height/bar._height
var mouseListener:Object = new Object();
mouseListener.onMouseWheel = function(delta) {
if(main.scroller._height < mask_mc._height){
trace("hihi")
}else{
dragger.scrollEase()
}
if (dragger._y>=dragger.originY) {
dragger._y -= delta*scrollSpeed
if (dragger._y<dragger.originY) {
dragger._y = dragger.originY;
} else if (dragger._y>dragger.originY+bar._height-dragger._height) {
dragger._y = dragger.originY+bar._height-dragger._height;
}
}
};
Mouse.addListener(mouseListener);
Does anybody have any ideas on how to fix this?
Thank you so much
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|