Hello,
I’m doing an interactive flash ad. The functionality is like this:
[LIST]
[]The ad should animate through panels of survey templates and their interval is set to 5 secs each.
[]I have used one of the famous scroller script here because it is needed by the ad.
[]The interval of 5 secs should stop while user interacts with the scrolling survey panels. one the user is done interacting, it should run the next panel in 2 secs.
[/LIST]I was able to achieve the above. The problem happens when:
[LIST]
[]I try to use the button to scroll,
[*]I double click on any place in the ad
[/LIST]Im not sure what is happening. See below the Script I used. Any help will greatly be appreciated:
var scrollHeight:Number = scroller1.scrollTrack._height;
var contentHeight:Number = scroller1.contentMain._height;
var scrollFaceHeight:Number = scroller1.scrollFace._height;
var maskHeight:Number = scroller1.maskedView._height;
var initPosition:Number = scroller1.scrollFace._y=scroller1.scrollTrack._y;
var initContentPos:Number = scroller1.contentMain._y;
var finalContentPos:Number = maskHeight-contentHeight+initContentPos;
var left:Number = scroller1.scrollTrack._x;
var top:Number = scroller1.scrollTrack._y;
var right:Number = scroller1.scrollTrack._x;
var bottom:Number = scroller1.scrollTrack._height-scrollFaceHeight+scroller1.scrollTrack._y;
var dy:Number = 0;
var speed:Number = 10;
var moveVal:Number = (contentHeight-maskHeight)/(scrollHeight-scrollFaceHeight);
var intervalId:Number;
var play1Now = function()
{
gotoAndPlay("goon1");
clearInterval(intervalId);
}
//Makes the scrollbar active to scroll the content
scroller1.scrollFace.onPress = function() {
var currPos:Number = this._y;
startDrag(scroller1.scrollFace, false, left, top, right, bottom);
scroller1.scrollFace.onMouseMove = function() {
dy = Math.abs(initPosition-scroller1.scrollFace._y);
scroller1.contentMain._y = Math.round(dy*-1*moveVal+initContentPos);
};
clearInterval(intervalId);
};
scroller1.scrollFace.onMouseUp = function() {
stopDrag();
delete scroller1.scrollFace.onMouseMove;
intervalId = setInterval(play1Now, 2000, "Interval called"); //so that on mouse out the timer is set to 2 secs
};
scroller1.btnUp.onPress = function() {
scroller1.btnUp.onEnterFrame = function() {
if (scroller1.contentMain._y+speed<scroller1.maskedView._y) {
if (scroller1.scrollFace._y<=top) {
scroller1.scrollFace._y = top;
} else {
scroller1.scrollFace._y -= speed/moveVal;
}
scroller1.contentMain._y += speed;
} else {
scroller1.scrollFace._y = top;
scroller1.contentMain._y = scroller1.maskedView._y;
delete scroller1.btnUp.onEnterFrame;
}
};
clearInterval(intervalId);
};
scroller1.btnUp.onDragOut = function() {
delete scroller1.btnUp.onEnterFrame;
intervalId = setInterval(play1Now, 2000, "Interval called");
}
scroller1.btnUp.onRelease = function() {
delete scroller1.btnUp.onEnterFrame;
intervalId = setInterval(play1Now, 2000, "Interval called");
};
scroller1.btnDown.onPress = function() {
scroller1.btnDown.onEnterFrame = function() {
if (scroller1.contentMain._y-speed>finalContentPos) {
if (scroller1.scrollFace._y>=bottom) {
scroller1.scrollFace._y = bottom;
} else {
scroller1.scrollFace._y += speed/moveVal;
}
scroller1.contentMain._y -= speed;
} else {
scroller1.scrollFace._y = bottom;
scroller1.contentMain._y = finalContentPos;
delete scroller1.btnDown.onEnterFrame;
}
};
clearInterval(intervalId);
};
scroller1.btnDown.onRelease = function() {
delete scroller1.btnDown.onEnterFrame;
intervalId = setInterval(play1Now, 2000, "Interval called");
};
scroller1.btnDown.onDragOut = function() {
delete scroller1.btnDown.onEnterFrame;
intervalId = setInterval(play1Now, 2000, "Interval called");
};
if (scroller1.contentHeight<scroller1.maskHeight) {
scroller1.scrollFace._visible = false;
scroller1.btnUp.enabled = false;
scroller1.btnDown.enabled = false;
} else {
scroller1.scrollFace._visible = true;
scroller1.btnUp.enabled = true;
scroller1.btnDown.enabled = true;
}
intervalId = setInterval(play1Now, 5000, "Interval called"); //initial 5 seconds delay
stop();