Scroller Clip Stop At End
Hi,
I've made this item scroller: HERE and I want it to stop scrolling when the scroll reaches the end.. I've tried numerous methods but nothing actually seems to make it stop (without getting stuck) exactly on the mark
here is my code, and the fla:
Code: // speed = 0; scrlMargn = 100; fastNess = 6; decel = 1.08; this.onEnterFrame = function() { bits._x += speed; if (_root._ymouse>this._y) { if (_root._xmouse<scrlMargn) { lPoo = (_root._xmouse-scrlMargn)*-1; speed = lPoo/fastNess; } else if (_root._xmouse>(masker._width-scrlMargn)) { rPoo = ((masker._width-scrlMargn)-_root._xmouse); speed = rPoo/fastNess; } else { speed /= decel; } } else { speed /= decel; } };
FlashKit > Flash Help > Flash ActionScript
Posted on: 04-21-2006, 06:44 AM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Getting My Scroller To Stop
Hey folks,
Okay after about 3 days work! ive made a scroller that responds to how long a button is pressed - the longer the faster it goes and the slower it slows down at the end!
any ideas how to make my scroller stop on an exact spot - ive tried using < and > symbols but these are innadequate as they take the thing slightly beyond or below the target..
ive attached the file. in an ideal world it would slow to a stop at 40 and 400, alternatively if it stopped dead at these targets that would be cool too!
many thanks! a free for the answer!
Scroller Won't Stop?
I've made a scroller that speeds up in either direction the further the mouse is from the centre of the scroll bar, which all works fine, but when it gets to the end of the images it jumps to the beginning again?
I'm sure its pretty straight forward, but I just need it to stop when the images run out so people know they've seen them all? It starts with the first image showing, so I need it to go right initially, and then go back left until it returns to that point, which it does, the problem is when it gets to the right end of the pics.
Heres the code thats set in the first frame of the .FLA-
Code:
panel.onRollOver = panelOver;
function panelOver() {
this.onEnterFrame = scrollPanel;
delete this.onRollOver;
}
var b = stroke.getBounds(_root);
function scrollPanel() {
if (_xmouse<b.xMin || _xmouse>b.xMax || _ymouse<b.yMin || _ymouse>b.yMax) {
this.onRollOver = panelOver;
delete this.onEnterFrame;
}
if (panel._x>=21.2) {
panel._x = 21.2;
}
if (panel._x<=-4050) {
panel._x = 4050;
}
var xdist = _xmouse-425;
panel._x += -xdist/7;
}
Any help with this would be really appreciated as I've been trying to fix it all weekend and still got nowhere, if you need to know anything else about it or want to look at the FLA post a response and I'll reply asap.
Thanks in advance to anyone who knows how to do this..
Tom
Can't Stop Scroller Please Help
Ok, so I have a scroller, with buttons on eachside, when the buttons clicked it slides either way on the x direction to show another images (holder). Right now it just jumps from image to image, and I'll put easing on it once I get this figured out. BUT, I can't get it to stop at the constraints of my dynamic movie. Right now I have 10 images in and I can trace all the maxWidth etc, but my first one always comes up NaN, so I can't find the beggining. Below is my code as well as some of the traces I have done to try to get this to work.
Traces:
totalClips I get 1,2,3,4,5,6,7,8,9,10 (I just want the last one tho, how do I get that?
w_clips I get Nan, 161.5 (9times sorry, not gonna type 161.5 and confuse ya)
totalWidth I get NaN, 323, 484.5, 646, 807.5, 969, 1130.5, 1292, 1453.5, 1615
maxleft I get 10 undefieneds.
and maxright, I get NaN then the distances. How do I set this up so I don't get the NaNs and undefineds, and how do I stop my movie from moving on my left and right btns when it reaches these max widths??
PHP Code:
function loadXML(loaded) {
if (loaded) {
xmlNode = this.firstChild;
image = [];
description = [];
title = [];
link = [];
btn = [];
total = xmlNode.childNodes.length;
var xPos = 90;
for (i=0; i<total; i++) {
image[i] = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue;
description[i] = xmlNode.childNodes[i].childNodes[1].firstChild.nodeValue;
title[i] = xmlNode.childNodes[i].childNodes[2].firstChild.nodeValue;
link[i] = xmlNode.childNodes[i].childNodes[3].firstChild.nodeValue;
btn[i] = xmlNode.childNodes[i].firstChild.nodeValue;
var scrollerMovie = attachMovie("scrollerMovie", "new"+i, i, {_x:xPos, _y:42});
xPos += scrollerMovie._width+20;
scrollerMovie.picture.loadMovie (image[i], 1);
scrollerMovie.desc_txt.text = description[i];
scrollerMovie.title_txt.text = title[i];
var totalClips = scrollerMovie=i+1;
var clipBaseName = 'new';
var w_clips = _root[clipBaseName + '1']._width+2;
var totalWidth = (totalClips * w_clips);
var maxleft = ["new"+i]._x;
var maxright = (totalWidth/2);
trace(maxleft);
}
} else {
content = "file not loaded!";
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("images.xml");
_root.leftBtn.swapDepths(99);
_root.rightBtn.swapDepths(109);
_root.lines.swapDepths(89);
leftBtn.onRelease = function(){
for (var i=0; i<total; i++) {
_root["new"+i]._x += 161.5;
if(_root["new"+i]._x <= maxleft){_root["new"+i]._x += totalWidth;}
}
}
rightBtn.onRelease = function(){
for (var i=0; i<total; i++){
_root["new"+i]._x -= 161.5;
if(_root["new"+i]._x >= maxright){_root["new"+i]._x -= totalWidth;}
}
}
Scroller Won't Stop At End?
I've made a scroller that speeds up in either direction the further the mouse is from the centre of the scroll bar, which all works fine, but when it gets to the end of the images it jumps to the beginning again?
I'm sure its pretty straight forward, but I just need it to stop when the images run out so people know they've seen them all? It starts with the first image showing, so I need it to go right initially, and then go back left until it returns to that point, which it does, the problem is when it gets to the right end of the pics.
Heres the code thats set in the first frame of the .FLA-
Code:
panel.onRollOver = panelOver;
function panelOver() {
this.onEnterFrame = scrollPanel;
delete this.onRollOver;
}
var b = stroke.getBounds(_root);
function scrollPanel() {
if (_xmouse<b.xMin || _xmouse>b.xMax || _ymouse<b.yMin || _ymouse>b.yMax) {
this.onRollOver = panelOver;
delete this.onEnterFrame;
}
if (panel._x>=21.2) {
panel._x = 21.2;
}
if (panel._x<=-4050) {
panel._x = 4050;
}
var xdist = _xmouse-425;
panel._x += -xdist/7;
}
Any help with this would be really appreciated as I've been trying to fix it all weekend and still got nowhere, if you need to know anything else about it or want to look at the FLA post a response and I'll reply asap.
Thanks in advance to anyone who knows how to do this..
Tom
Scroller Won't Stop At End
I've made a scroller that speeds up in either direction the further the mouse is from the centre of the scroll bar, which all works fine, but when it gets to the end of the images it jumps to the beginning again?
I'm sure its pretty straight forward, but I just need it to stop when the images run out so people know they've seen them all? It starts with the first image showing, so I need it to go right initially, and then go back left until it returns to that point, which it does, the problem is when it gets to the right end of the pics.
Heres the code thats set in the first frame of the .FLA-
Code:
panel.onRollOver = panelOver;
function panelOver() {
this.onEnterFrame = scrollPanel;
delete this.onRollOver;
}
var b = stroke.getBounds(_root);
function scrollPanel() {
if (_xmouse<b.xMin || _xmouse>b.xMax || _ymouse<b.yMin || _ymouse>b.yMax) {
this.onRollOver = panelOver;
delete this.onEnterFrame;
}
if (panel._x>=21.2) {
panel._x = 21.2;
}
if (panel._x<=-4050) {
panel._x = 4050;
}
var xdist = _xmouse-425;
panel._x += -xdist/7;
}
Any help with this would be really appreciated as I've been trying to fix it all weekend and still got nowhere, if you need to know anything else about it post a response and I'll reply asap, or email me for the FLA if that'll help.
Thanks in advance to anyone who knows how to do this..
Tom
Scroller Problem It Won't Stop
I've adapted a scroller from a tutorial for my project but now I can't get it to stop where I need it to. The movie clip just keeps scrolling out of site.
Help!
What do I alter in the AS to get it to stop at a certain point?
--------------------------------------------------------------------------
fscommand("allowscale", "false");
bar.useHandCursor = dragger.useHandCursor=false;
space = 20;
friction = 0.9;
speed = 4;
y = dragger._y;
top = main._y;
bottom = main._y+mask_mc._height-main._height-space;
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, 18, -1);
};
down_btn.onPress = function() {
myInterval = setInterval(moveDragger, 18, 1);
};
up_btn.onMouseUp = down_btn.onMouseUp=function () {
clearInterval(myInterval);
};
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;
};
};
--------------------------------------------------------------------------
I also attached the .fla to see if that would help make sense of it.
I reeeeeeeeeally appreciate your taking the time. Thanks!
How Can I Stop The Mouse Following A Scroller?
I have made a scrolling menu that follows the _x position of the mouse, the problem is that the scroller stays attached to the mouse cursor no matter where is it on the screen, not only when it is above the menu.
How can I change it so that the scroller only follows the mouse when it is over its hit point?
Heres the code I am using, on frame 1:
code: fscommand("allowscale", "false");
if (_xmouse < 100) {
setProperty("_root.slider", _x, (-1*_xmouse) + 700);
} else if (_xmouse > 100) {
setProperty("_root.slider", _x, (-1*_xmouse) + 700);
} else {
trace("=");
setProperty("_root.slider", _x, _xmouse);
}
Frame 2:
code: if (_xmouse<100) {
setProperty("_root.slider", _x, (-1*_xmouse)+700);
} else if (_xmouse>100) {
trace(">");
setProperty("_root.slider", _x, (-1*_xmouse)+700);
} else {
setProperty("_root.slider", _x, _xmouse);
}
setProperty("_root.drag", _x, _xmouse);
gotoAndPlay(1);
Any help would be appreciated. I have attached the source file I am using
Can't Stop Scroller Please Help So I Can Have A Drink ;op
Ok, so I have a scroller, with buttons on eachside, when the buttons clicked it slides either way on the x direction to show another images (holder). Right now it just jumps from image to image, and I'll put easing on it once I get this figured out. BUT, I can't get it to stop at the constraints of my dynamic movie. Right now I have 10 images in and I can trace all the maxWidth etc, but my first one always comes up NaN, so I can't find the beggining. Below is my code as well as some of the traces I have done to try to get this to work.
Traces:
totalClips I get 1,2,3,4,5,6,7,8,9,10 (I just want the last one tho, how do I get that?
w_clips I get Nan, 161.5 (9times sorry, not gonna type 161.5 and confuse ya)
totalWidth I get NaN, 323, 484.5, 646, 807.5, 969, 1130.5, 1292, 1453.5, 1615
maxleft I get 10 undefieneds.
and maxright, I get NaN then the distances. How do I set this up so I don't get the NaNs and undefineds, and how do I stop my movie from moving on my left and right btns when it reaches these max widths??
PHP Code:
function loadXML(loaded) { if (loaded) { xmlNode = this.firstChild; image = []; description = []; title = []; link = []; btn = []; total = xmlNode.childNodes.length; var xPos = 90; for (i=0; i<total; i++) { image[i] = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue; description[i] = xmlNode.childNodes[i].childNodes[1].firstChild.nodeValue; title[i] = xmlNode.childNodes[i].childNodes[2].firstChild.nodeValue; link[i] = xmlNode.childNodes[i].childNodes[3].firstChild.nodeValue; btn[i] = xmlNode.childNodes[i].firstChild.nodeValue; var scrollerMovie = attachMovie("scrollerMovie", "new"+i, i, {_x:xPos, _y:42}); xPos += scrollerMovie._width+20; scrollerMovie.picture.loadMovie (image[i], 1); scrollerMovie.desc_txt.text = description[i]; scrollerMovie.title_txt.text = title[i]; var totalClips = scrollerMovie=i+1; var clipBaseName = 'new'; var w_clips = _root[clipBaseName + '1']._width+2; var totalWidth = (totalClips * w_clips); var maxleft = ["new"+i]._x; var maxright = (totalWidth/2); trace(maxleft); } } else { content = "file not loaded!"; } } xmlData = new XML(); xmlData.ignoreWhite = true; xmlData.onLoad = loadXML; xmlData.load("images.xml"); _root.leftBtn.swapDepths(99); _root.rightBtn.swapDepths(109); _root.lines.swapDepths(89); leftBtn.onRelease = function(){ for (var i=0; i<total; i++) { _root["new"+i]._x += 161.5; if(_root["new"+i]._x <= maxleft){_root["new"+i]._x += totalWidth;} } } rightBtn.onRelease = function(){ for (var i=0; i<total; i++){ _root["new"+i]._x -= 161.5; if(_root["new"+i]._x >= maxright){_root["new"+i]._x -= totalWidth;} } }
Scroller And Stop Certain Mc Scrolling
I have mc. Inside this mc are mc-s what i need to scroll. First mc is certain mainpage. If i scroll it will moove up and another come out. But i want to make thisway that thisfirst is scrolling till it reach up (and only bottom selvage is visible ) and then it stops. But all other mc-s should be scrollable. And this stopping mc should scroll back also.
My one idea is to make one scroll button but two scrolling areas and two code. But i know that this is bad.
....
Image Scroller Needs To Stop
Hi,
can anyone help me, this is driving me crazy and i am sure the answer is right in front of me!!!
I have this scroller working but what i want to do now is to make it stop when it reaches the end of each end if that makes any sense (see digram/code below)... can anyone help?
x = image | = stop area where 'End' should stop
ViewArea
-------------
Endx--x--x-|-x--x--x--x-|-x--x--xEnd
-------------
I believe i would do it in this section:
Code:
if (movement<0) {
if (path["image"+1]._x<=imageWidth) {
path["image"+i]._x = SOMETHING HERE
path["boarderBox"+i]._x = path["image"+i]._x;
path["imageSelect"+i]._x = path["image"+i]._x;
}
} else {
if (path["image"+(counter-1)]._x>=(_global.rightEdge-imageWidth)) {
path["image"+i]._x = SOMETHING HERE
path["boarderBox"+i]._x = path["image"+i]._x;
path["imageSelect"+i]._x = path["image"+i]._x;
}
Below is the part of the function that creates the scolling effect.
Code:
path.onEnterFrame = function() {
//trace(path._width);
if (counter>6 && okToScroll == 0) {
// calc movement of images relative to mouse position (764=movie width)
if (_root._ymouse<240) {
Xmouse = _root._xmouse;
} else {
Xmouse = 382;
}
//trace(Xmouse);
var movement = Math.round((Xmouse)-(764/2))*-1;
movement = Math.round(movement/30);
trace(movement);
// move all images to new positions
for (var i = 0; i<counter; i++) {
//trace(path["image"+1]._x);
path["image"+i]._x += movement;
path["imageSelect"+i]._x = path["image"+i]._x;
path["boarderBox"+i]._x = path["image"+i]._x;
}
}
for (var i = 0; i<counter; i++) {
//release actions
if (okToScroll == 1) {
if (_global.releaseNum == i) {
if (path["image"+i]._alpha<=0) {
//blankOne.onPress = function() {
xMoveBox(blankOne, 132, 2, _root.blank.westProducts["id"+i], i);
}
_root.AandT.textEffects._alpha -= 10;
//trace(path["imageSelect"+i]);
if (path["imageSelect"+i]._alpha>=0) {
path["imageSelect"+i]._alpha -= 10;
path["boarderBox"+i]._alpha -= 10;
path["image"+i]._alpha -= 10;
}
//make new image
//move selected image
//fade all other images
for (var i = 0; i<releaseNum; i++) {
path["imageSelect"+i]._alpha = 0;
path["boarderBox"+i]._alpha -= 10;
path["image"+i]._alpha -= 10;
}
for (var i = releaseNum+1; i<counter; i++) {
path["imageSelect"+i]._alpha = 0;
path["boarderBox"+i]._alpha -= 10;
path["image"+i]._alpha -= 10;
}
}
}
if (okToScroll == 0) {
// rollover/out effects...
if (_global.rollOverNum == i) {
//if (path["image"+i]._alpha<=100) {
path["imageSelect"+i]._alpha = 100;
path["image"+i]._alpha = 100;
//}
} else {
//if (path["image"+i]._alpha>=50) {
path["imageSelect"+i]._alpha = 0;
path["image"+i]._alpha = 100;
//}
}
}
if (movement<0) {
if (path["image"+1]._x<=imageWidth) {
path["image"+i]._x = SOMETHING HERE
path["boarderBox"+i]._x = path["image"+i]._x;
path["imageSelect"+i]._x = path["image"+i]._x;
}
} else {
if (path["image"+(counter-1)]._x>=(_global.rightEdge-imageWidth)) {
path["image"+i]._x = SOMETHING HERE
path["boarderBox"+i]._x = path["image"+i]._x;
path["imageSelect"+i]._x = path["image"+i]._x;
}
any help would be welcomed!!!
thank you
skezo
Help Why Does My Text Stop? Using Componet Scroller.
I have a dynamic text box pulling in a rather lengthy .txt document. It stops scrolling the text near the end of the document and I can't scroll to the end.
Is there something in the componet code that I need to change?
I've tested the html tags in the .txt file and I know there is nothing wrong there.
Thanks for any light you can shed on this one.
Pete
Image Scroller Array, I Need It To Stop
Hey everyone.
I am working on this image scroller array and I need it to stop moving if you rollover one of the buttons in the array. This is what I have so far. But nothing that will make it stop moving yet.
Any ideas?
onClipEvent(enterFrame) {
mylist = [_root.square0, _root.square1, _root.square2, _root.square3, _root.square4, _root.square5, _root.square6, _root.square7, _root.square8, _root.square9];
for (i in mylist) {
mylist[i]._x = mylist[i]._x -4;
if (mylist[i]._x <= -100) {
mylist[i]._x = 1033;
}
}
}
Thanks.
Non-stop AS Text Scroller. Any Way To Improve It?
Hi.
I'm making a simple non-stop text scroller with the help of AS, but I've been able to see that the scroll itself is not smooth and, what's worse, it devours my PC resources when played in my AMD Athlon 1200 (which power I think should not be compromised by this simple text scroll )
What I've done is the following:
I've made a big dialog box where all text will be inside (I've made it big because it will contain a lot of dynamic text).
Basically, I've found 2 limitations:
The first one is that when text is being scrolled it stutters, movement is whatever but smooth...
The AS I've used is this:
code: this.bigtext.onEnterFrame = function()
{
if (this._y >-1750) {
this._y -=2;
} else {
this._y =210;
}
};
You can see by the numbers (-1750) that the text box is huge! When it reaches that number it starts all over again from _y position at 210.
In order to get a smoother movement I did the following:
- In the text box, I tried different smooth parameters (Anti-alias for readability, animation..) but nothing improved, so I let it set to "Anti-alias for readability").
- I tried different values for the increasing _y number but "2" seems to be the most stable and visually correct among them all.
- I set the movie to 40 fps, however, irregular and choppy movement is still there.
- I exported it for Flash 8 Player but no improvement (I had heard that Flash 8 Player had been improved a lot for several animations all at once....but must I be forgetting any setting for this?).
What do you suggest me to do?
The second issue is related to updating the text: I'm using dynamic text to be displayed in the box which is loaded from a text file. However, I see that the longer I make the text file, the bigger I'll have to make the box for the text file (and change the conditional _y values in order to let it all be displayed). This is an annoying issue that I'd like to improve too, so that there's no need to retouch the box size everytime that additional text is added.
Any ideas for this?
For those of you who want to have a look at my simple Flash 8 .fla file, here it is.
Thank you very much.
Manare
Text Scroller + Mouseover Stop?
I made a news scroller with dynamic read function.. but is there anyway to make a on mouseover and stop function to this thing?
here is the action on 3 frames....
frame 1
PHP Code:
pos = 90;
frame 2
PHP Code:
pos = pos-1;
_parent.news._y = pos;
if (_parent.news._y<=-320) {
gotoAndPlay(1);
}
frame 3
PHP Code:
gotoAndPlay (2);
Non-stop AS Text Scroller. Any Way To Improve It?
Hi.
I'm making a simple non-stop text scroller with the help of AS, but I've been able to see that the scroll itself is not smooth and, what's worse, it devours my PC resources when played in my AMD Athlon 1200 (which power I think should not be compromised by this simple text scroll )
What I've done is the following:
I've made a big dialog box where all text will be inside (I've made it big because it will contain a lot of dynamic text).
Basically, I've found 2 limitations:
The first one is that when text is being scrolled it stutters, movement is whatever but smooth...
The AS I've used is this:
ActionScript Code:
this.bigtext.onEnterFrame = function(){ if (this._y >-1750) { this._y -=2; } else { this._y =210; }};
You can see by the numbers (-1750) that the text box is huge! When it reaches that number it starts all over again from _y position at 210.
In order to get a smoother movement I did the following:
- In the text box, I tried different smooth parameters (Anti-alias for readability, animation..) but nothing improved, so I let it set to "Anti-alias for readability").
- I tried different values for the increasing _y number but "2" seems to be the most stable and visually correct among them all.
- I set the movie to 40 fps, however, irregular and choppy movement is still there.
- I exported it for Flash 8 Player but no improvement (I had heard that Flash 8 Player had been improved a lot for several animations all at once....but must I be forgetting any setting for this?).
What do you suggest me to do?
The second issue is related to updating the text: I'm using dynamic text to be displayed in the box which is loaded from a text file. However, I see that the longer I make the text file, the bigger I'll have to make the box for the text file (and change the conditional _y values in order to let it all be displayed). This is an annoying issue that I'd like to improve too, so that there's no need to retouch the box size everytime that additional text is added.
Any ideas for this?
For those of you who want to have a look at my simple Flash 8 .fla file,here it is.
Thank you very much.
Manare
Text Scroller + Mouseover Stop?
I made a news scroller with dynamic read function.. but is there anyway to make a on mouseover and stop function to this thing?
here is the action on 3 frames....
frame 1
PHP Code:
pos = 90;
frame 2
PHP Code:
pos = pos-1;
_parent.news._y = pos;
if (_parent.news._y<=-320) {
gotoAndPlay(1);
}
frame 3
PHP Code:
gotoAndPlay (2);
Cannot Stop Movie Clip - This.stop() Confusion
Hello,
In my pong game when someone scores a goal I want the ball to pause in the middle of the screen, wait xx seconds and then randomly move.
Code:
// Return to kick off position
this.stop();
this._y = 325;
this._x = 275;
a = 0;
var myInterval = setInterval(this, "wait", 30*1000);
This calls function wait that simply uses this.play(); to allow the ball to move again.(See below)
Code:
onClipEvent (load) {
this.wait = function() {
this.play();
clearInterval(myInterval);
};
}
However I cant EVER get the ball symbol to stop no matter what I do.
Ive included all the code attached to the clipevent for the ball below.
Im thinking it must be due to the nested loops or somethings, very very confused
Code:
onClipEvent (load) {
this.wait = function() {
this.play();
clearInterval(myInterval);
};
}
onClipEvent (enterFrame) {
//Kick Off, play whistle and select random direction from 4 diagonals
if (a == 0) {
_root.kickoffwhistle.start();
//Use variable to ensure random numbers are generated only once per game
var randNumber1:Number = Math.pow(-1, Math.floor(Math.random()*2));
//-1 ^1 or ^2 = 1 or -1
var randNumber2:Number = Math.pow(-1, Math.floor(Math.random()*2));
//move it on the y axis at -1 or 1 & //move it on the x axis at -1 or 1
this._y += this.randNumber1;
this._x += this.randNumber2;
++a;
//set a trigger to increment so only actioned once.
}
if (randNumber1>0) {
this._y += this.yspeed;
//move it on the y axis at the set speed
} else {
this._y -= this.yspeed;
//move it on the y axis at the set speed
}
if (randNumber2>0) {
this._x += this.xspeed;
//move it on the x axis at the set speed
} else {
this._x -= this.xspeed;
//move it on the x axis at the set speed
}
// Ball(this) collides with PL1 and ball travelling upwards then deflect off randomly {
if (this.hitTest(_root.P1footballman) && this.yspeed<0) {
// Define boundaries for collision detection
var pl1bounds:Object = _root.P1footballman.getpl1bounds(_root);
this._x = Math.round(Math.random()*(pl1bounds.xMax-pl1bounds.xMin))+pl1bounds.xMin;
//Revert direction of ball by using formula below
this.yspeed = this.yspeed*-1;
//Randomly play miss sound effect if ball in goal area
if (this._x>133 && this._x<450) {
var result = Math.round(Math.random()*2);
if (result == 0) {
_root.MissedGoal.start();
}
}
//play football kick & header sound
_root.footballkickorheader.start();
}
if (this.hitTest(_root.cpu) && this.yspeed>0) {
var cpubounds:Object = _root.P1footballman.getcpubounds(_root);
this._x = Math.round(Math.random()*(cpubounds.xMax-pl1bounds.xMin))+cpubounds.xMin;
this.yspeed = this.yspeed*-1;
if (this._x>133 && this._x<450) {
var result = Math.round(Math.random()*2);
if (result == 0) {
_root.MissedGoal.start();
}
}
//play football kick & header sound
_root.footballkickorheader.start();
}
//Roatation properties of the ball
i = getProperty(this, _rotation);
setProperty(this, _rotation, i+5);
//Rotate ball i degees per frame
_this.rotation = i;
//Player Scores routine
//If ball object is beyond defined CPU goal area
if (this._y<75 && this._x>133 && this._x<450) {
_root.goalcry.start();
_root.P1footballman.score++;
//add1 to the cpu score
_root.playertxt = 'PLY: '+_root.P1footballman.score;
//Play start whistle for KICKOFF
_root.kickoffwhistle.start();
//Return to kick off position
this._y = 315;
this._x = 275;
a = 0;
//Stop ball in correct position
this.stop();
//5 seconds then calls function "wait" to use this.play() to move ball
var myInterval = setInterval(this, "wait", 5*1000);
}
//CPU Scores routine
//If ball object is beyond defined Player goal area
if (this._y>470 && this._x>133 && this._x<450) {
_root.goalcry.start();
_root.cpu.score++;
//add1 to the cpu score
_root.cputxt = 'CPU: '+_root.cpu.score;
//Play start whistle for KICKOFF
_root.kickoffwhistle.start();
// Return to kick off position
this.stop();
this._y = 325;
this._x = 275;
a = 0;
var myInterval = setInterval(this, "wait", 30*1000);
}
if (this._x>620 || this._x<5) {
this.xspeed = this.xspeed*-1;
//if it hits an edge inverse the xspeed
_root.bounce.start();
//Play bounce side effect
}
if (this._y>470 || this._y<75) {
this.yspeed = this.yspeed*-1;
//if it hits the top or bottom of pitch inverse the yspeed
_root.bounce.start();
//Play bounce side effect
}
}
That Scroller Doesn't Stop, I'm Feeling Sea-sick;)
step by step, I'm trying to learn. but now I've got another problem. I've got a sliding menu in a movie clip that activates various movieclips when I press the buttons like the one in
http://www.flashkit.com/movies/Inter...-463/index.php
taking this movie as an example, I'd like to understand
1) if the scrolling of the menu can be activated ONLY when the mouse is on it (Dunno, I really can't figure out HOW )
2) if there is a way to stop it when the mouse is over it; I've tried inputting commands such as on mouseover stop/on mouseout play but probably I'm waaaaaay out from the right path...
can you help me!?
How To Make Scroller Stop When Menu Is Active
hi,
in my flash file i use a movieclip that scrolls images controlled by the mouse. there is a variable speed, and if it set to 0, the scroller is stopped.
so far it works fine.
but i also have a dropdown menu which overlaps the scroll area when it is unfolded. and so, if i want to navigate, the images keep quickly scrolling around, which is rather annoying.
the menu is inside a movie clip.
i think i'll have to set the speed variable to 0 when the mouse rolls over the space that the menu occupies.
can you tell me if it works that way and how i have to actionscript that?
thanks a lot
jo
How To Make Scroller Stop When Menu Is Active
hi,
in my flash file i use a movieclip that scrolls images controlled by the mouse. there is a variable speed, and if it set to 0, the scroller is stopped.
so far it works fine.
but i also have a dropdown menu which overlaps the scroll area when it is unfolded. and so, if i want to navigate, the images keep quickly scrolling around, which is rather annoying.
the menu is inside a movie clip.
i think i'll have to set the speed variable to 0 when the mouse rolls over the space that the menu occupies.
can you tell me if it works that way and how i have to actionscript that?
thanks a lot
jo
Image Scroller With Stop/change Direction?
Hey everyone.
I am a flash newbie so please bear with me! I did try to search on here for how to do this but I couldn't find anything that fitted really with what I am looking for.
I want to create a scrolling image marquee in Flash; when you mouseover the middle, the scrolling stops, when you mouseover to the left side, the images scroll to the left, when you mouseover to the right, the images scroll to the right. I have no idea how to do this!
I have seen a few tutorials where you can create something similar like with thumbnails or where it's continuous but I don't want thumbnails and although continuous would be fine if I can't achieve this, I would prefer to be able to have something a bit more fun!
If anyone knows of any good tutorials (newbie friendly!) or if anyone wants to tell me how to do it (for free, I can't pay you I'm afraid!), I would be VERY grateful!
Many thanks!
Annie
AS3 - Mouse Controlled Scroller - How Do I Get It To Stop Scrolling?
hi guys,
i have a script that scrolls a movie clip according to the mouse's x position and whether or not it is moving left or right. i am trying to figure out a way to make the scrolling slow down, or just stop completely when the mouse has stopped moving or is idle. my script so far handles the scrolling part, but not the stopping/slowing of the scroll. can anyone point me in the right direction?
http://www.bobthabuilda.net/misc/tutorials_AS3.swf
and the code:
Code:
var prevX:uint = 0;
var curX:uint = 0;
var scrollRight:Boolean = false;
var scrollLeft:Boolean = false;
var scrollAmt:Number = (links_mc.width / stage.stageWidth) * 10;
function checkDirection(event:MouseEvent):void
{
prevX = curX;
curX = mouseX;
trace(scrollLeft);
trace(scrollRight);
if (curX > prevX)
{
scrollRight = false;
scrollLeft = true;
}
else if (prevX > curX)
{
scrollLeft = false;
scrollRight = true;
}
else
{
null;
}
}
function scrollMenu(event:Event):void
{
if (scrollRight && (links_mc.x < 0))
{
links_mc.x += scrollAmt;
}
else if (scrollLeft && (links_mc.x > -606))
{
links_mc.x -= scrollAmt;
}
else
{
null;
}
}
stage.addEventListener(MouseEvent.MOUSE_MOVE, checkDirection);
stage.addEventListener(Event.ENTER_FRAME, scrollMenu);
thanks!
john
Stop Moving When Mouse Is Outside Certain Area (parallax Scroller)
Hi everyone.
I have a problem with a "paralax scroller" movie clip. I downloaded the original from this site and I'm currently modifying it. Currently I'm loading it into the .swf as another .swf like this:
Code:
loadMovie("parallax_01.swf", parallax_mc);
which is fine.
My problem is that it continues to scroll even when the mouse isn't over it. Please check it out here to see what I mean. As you can see, it works perfectly, as long as the mouse remains within the bounds of the loaded .swf, but once outside those bounds - ie outside the box - it continues to scroll (which is bad).
Can anyone help me modify my code so that this can be fixed? I guess its something about checking where the mouse is? getBounds maybe? The code governing the movement is inside the loaded "parallax_01.swf" and reads as follows:
(foreground layer)
Code:
onClipEvent (enterFrame) {
if (_root.parallax_mc.mainVar == 0) {
homeX = (-_root.parallax_mc._xmouse*3)+540;
} else {
homeX = (-_root.parallax_mc.mainVar*3)+540;
}
thisX = _x;
diffX = homeX-thisX;
if (_root.parallax_mc.mainVar == 0) {
moveX = diffX/30;
} else {
moveX = diffX/5;
}
_x = thisX+moveX;
}
(middleground layer)
Code:
onClipEvent (enterFrame) {
if (_root.parallax_mc.mainVar == 0) {
homeX = (-_root.parallax_mc._xmouse*2)+405;
} else {
homeX = (-_root.parallax_mc.mainVar*2)+405;
}
thisX = _x;
diffX = homeX-thisX;
if (_root.parallax_mc.mainVar == 0) {
moveX = diffX/30;
} else {
moveX = diffX/5;
}
_x = thisX+moveX;
}
(background layer)
Code:
onClipEvent (enterFrame) {
if (_root.parallax_mc.mainVar == 0) {
homeX = (-_root.parallax_mc._xmouse)+270;
} else {
homeX = (-_root.parallax_mc.mainVar)+270;
}
thisX = _x;
diffX = homeX-thisX;
if (_root.parallax_mc.mainVar == 0) {
moveX = diffX/30;
} else {
moveX = diffX/5;
}
_x = thisX+moveX;
}
I'm sure its fairly simple but I just can't figure it out. Thank you for looking I really appreciate it.
Stop And Play Button For Movie Clip Within Moive Clip
hi i have problems with my buttons. i have got 2 fla files. 1) shell.fla 2) content.fla.
The shell.fla has a movie clip(name:holder) to load the content.swf. And within the content.swf i have got movie clip within movie clip.
Thru a search from the forum i came across this script
first frame:
Quote:
function stopAllClips(clip) {
clip.stop();
for (var i in clip) {
if(typeof clip[i]=="movieclip") {
if(clip[i]!=clip) {
stopAllClips(clip[i]);
}
}
}
};
function startAllClips(clip) {
clip.play();
for (var i in clip) {
if(typeof clip[i]=="movieclip") {
if(clip[i]!=clip) {
startAllClips(clip[i]);
}
}
}
};
for the button:
Quote:
on (release) {
if(!_root.stopped){
_root.stopAllClips(_root.holder_mc);
_root.stopped = true;
} else {
_root.startAllClips(_root.holder_mc);
_root.stopped = false;
}
}
everything works fine except after i pause and play, i doesn't play from where it has stopped. Anyone has got any ideas as to how i can solve this problem. Thanks very much.
Scroller Smart Clip
Hello,
I have a deadline coming up & I need some helpful guidance please... I have downloaded a smartclip from the web to use within my Flash website. Once I click on clip parameters, I need to set the DataURL to the path to external text file to pull info into the smartclip scroller. I am not sure how to type the relative path to my external text file. I have placed the text file in the same folder as my .fla. I think the path involves _root or something but not sure. If someone knows the correct format for typing the relative path to my text file to pull my data into my scroller, please let me know. Greatly appreciated!
Movie Clip Scroller
Can someone tell me the action script I need to use for my move clip scroller? (up button, down button, MC actionscript?) I tried a tutorial for it inteded for Flash 5, but I got syntax errors? Any help would be appreciated Thanks,
Ice2009
Movie Clip Scroller
can anyone give me an example of a movie clip scroller, WITH a DRAGBAR and UP + DOWN ARROW BUTTONS. I have been searching for about a month and I haven't come up with anything that meets this criteria. I have seen many uses of this on websites so I know it exists. Any example of this would be much appreciated.
Thanks
Movie Clip Scroller...
what i'm trying to do is make one movie clip go up and down based on the y position of another movie clip that dragged up and down (essentially like the bar of any browser window, minus the arrows at the top and bottom).
the AS below is on a keyframe in the main timeline, and the items involved are:
homeTextMC is a movie clip in the main time line that contains sliderMC (the movie clip that is dragged by the user for scrolling) and textMC (a movie clip that contains a static text box), which is masked.
basically, what I've concluded is that I need to calculate the position of the slider handle as a percentage of its max. position (290.1), then apply that percentage to the textMC movie clip.
In its initial position, the textMC y is 0. in the position where the bottom-most text would be visible, the y is -206.
ActionScript Code:
//Text Slider
_root.homeTextMC.sliderMC.onPress = function () {
this.startDrag(false,205.2,22.1,205.2,290.1);
}
var slider_y = this.homeTextMC.sliderMC._y;
_root.homeTextMC.sliderMC.onRelease = function () {
stopDrag();
var sliderPercent = ((slider_y/264.1) * 100);
var textPos = (sliderPercent) * -206;
_root.homeTextMC.textMC._y = (textPos);
}
This does do something, but I think I must have my equations mixed up or something. When the sliderMC is dragged, the text moves, but it moves drastically and is no longer visible at all. Also, in a perfect world, the textMC would scroll along with the sliderMC, which with my current AS set up, I don't think is possible because of the order in which I have the actions.
I'll attempt to upload my fla, but can't make any guarantees because in the past i've been unable to upload for one reason or another, mainly because of some filter or something on my work PC.
Any other necessary info, let me know and I'll post it
Thanks so much
-James
Movie Clip With Scroller
Hi everyone!
I want to make a movie clip with scroll, Instead of images, i want to add text box and labels inside the movie clip from a "for" loop, you guys have any idea please help me out
Cheers
Scroller Controlling Movie Clip
Hey everyone,
I want to control a movie clip using a slider.
Basically as I drag my scroller to the left I want
the movie clip to go from frame 1-2-3. When I drag
the scroller to the right I want my movie clip to
go from frame 3-2-1.
I created a fla at http://www.pointnorthds.com/scrolling_movie_clip.fla
Can someone take a look at this script and tell me
what I'm doing wrong.
Also is this possible in Flash 4?
Thanks
Cracker
Scroller With Slider Bar For Movie Clip
Hello!
I would love to find a tutorial that will show me how to make a scroller for a movie clip with text in it. I don't want one that uses dynamic text b/c I need for the text to be live links, too.
any pointers?
Load Scroller Into Movie Clip
Hi i am using this scroll bar.
http://www.flashkit.com/movies/Scrip...3731/index.php
But it doesnt work when i load it into another movie clip. Can someone show me how to do that please. Also how to change the size.
Thanks guys
Movie Clip Scroller Buttons
Does anyone know how to make an 'up' and 'down' scroll buttons that will work on a movie clip?
Making these scroll buttons to apply to a dynamic text box is not a problem, but I can find any clues anywhere as to how you do this for a movie clip.
Any help would be fantastic.
Cheers.
Scroller In A Movie Clip Problem ...URGENT
ive got a scroller (scroller1.swf) which is getting loaded into a movieclip in my main flash movie (one.swf)
but when i check the site the scoller doesnt work because it in a movie clip, although it does work if its load straight into the main timeline
i really need to have it workin within the movie clip
please someone help...
ive included the 2 fla for you to have a look at
Movie Clip Scroller That Support HTML
Hey
I am looking for a scroller component for movie clips, that would support HTML files, I find a few movieclip scroller at the flash kit archive, that I guess was made for flash 5, and they do not support html text inside the movie clip. dose anybody have any idea?
(I am not looking for a text scroller, if that’s what you had in mind)
thanks
Another Text/movie Clip Scroller Question.
Im looking for the easiest way to custom write/code your own "scroll bar" and what I mean by this is:
just to be able to use an object (movie clip) onPress/drag vertically only a.) dynamic text & b.) movie clip's/ object's
Im not talking about the buttons parts (no clicking)..... just to be able to use any object to drag up/down to scroll dynamic text or a movie clip (that would load an image or external.swf)
looking for a simple, smooth one...no "inertia"..or throwable ones please....
Looking for alternative to using styles on the "components" or actually going in and trying to edit the symbols.
dont need any hel on how to load the text..or load the external.swf's/external images....just the scroller part.
appreciate anything anyone can share.
Thanks..
Interactive Movie Clip Scroller W/Easing
Hi guys,
Recently I've been developing a new site that runs 100% with noScale. What I'm aiming to achieve is the ability for the user to move their mouse up and down on the Y Axis to effectively scroll the site. (Without having to click)
I've tried adapting the Interactive Image Panner Actionscript from the Tutorial on kirupa - but it doesn't seem to be working quite right I've changed all the X Values to Y.
Code:
stop();
this.onMouseMove = function() {
constrainedMove(bg_mc, 4, 1);
};
function constrainedMove(target:MovieClip, speed:Number, dir:Number) {
var mousePercent:Number = _ymouse/Stage.height;
var mSpeed:Number;
if (dir == 1) {
mSpeed = 1-mousePercent;
} else {
mSpeed = mousePercent;
}
target.destY = Math.round(-((target._height-Stage.height)*mSpeed));
target.onEnterFrame = function() {
if (target._y == target.destY) {
delete target.onEnterFrame;
} else if (target._y>target.destY) {
target._y -= Math.ceil((target._y-target.destY)*(speed/150));
} else if (target._y<target.destY) {
target._y += Math.ceil((target.destY-target._y)*(speed/150));
}
};
}
The zip containing the fla and html files are located here - http://www.archeradvertising.co.uk/kirupa/Archive.zip
If anyone can help I'd really appreciate it.
Cheers
David
Using A List To Skip To Different Scroller/movie Clip Points
Hi guys! Was wondering if anyone could help me on my list conundrum.
My scroller ("scroller") scrolls my movie clip ("movIn").
Id like to add in a list in which when an event is selected the movie clip skips to that event. i.ei centers the movie clip at that point
Ive no history of using lists so any help on how to get started is greatly appreciated.
Cheers everyone
Image Scroller Script Doesn't Work When Put Inside Movie Clip
I've given up trying to figure this out myself as I'm new to this and desperately in need of help.
I got a script which is an image scroller. I've attached the fla in question and the problem seems to be in the 'controller' MC which you can see in the assets. This is what controls the button actions to the slides.
I want to be able to put this in another movie clip so that I can refer to it from another mc and then this shoudl start playing.
Will really appreciate your help!
BTW I am using Flash MX 2004.
Stop Clip
hi there!!!
my question is this.
I have a Mclip, and I want that to the 15 seconds start..(_x with easing)
i want use set interval
i have this code.. but no works.. which is the error??
excuse me enlgish
ActionScript Code:
function time_entrar() {
this._x += (300-this._x)/10
}
n = 1000
this.onEnterFrame = function() {
setInterval(time_entrar,n)
}
Making A Movie Clip Stop When Colliding With Another Movie Clip....
OK I have a stage are which is surrounded by walls on all four sides, (wall_left , wall_right , wall_top , and wall_bottom.) Also, I have a character which is named "Omekk" (Some fag name I made up.) I can control 'omekk' with the keys, but I don't quite understand the hitTest function. I am using flash MX. On the left wall I put the code
Code:
onClipEvent (load) {
Omekk.hitTest(wall_left);
}
and the top wall I put:
Code:
onClipEvent (load) {
Omekk.hitTest(wall_top);
}
...and so on and so forth. The problem is, when I test the movie, the character STILL goes through the wall... What's up with that? Are there more actions that I have to put on the wall? Actions on Omekk himself? Error in the syntax? What is it??
If someone helps, I'd be SOOOOO happy. I feel like such a moron because I can NEVER understand this. I'm about to just give up flash if I don't get it... I suck and I can never get the hang of it.
Sorry,
Josh
Movie Clip Stop
How do I stop a movie clip at a certain location, it just keeps playing...
Stop Movie Clip
hi all,
i need help. i have placed a MC of a moving flower on scene 2 of my movie.
on that frame, i duplicate this MC, creating a field of floating flowers.
however, when i click to return to scene 1 of the movie, the flowers do not disappear and continue to duplicate and float over scene 1.
how can i remove/stop the MC when i hit the return button.
thanks!
bittergawd
Stop Movie Clip
Hey all.
I have a movie clip within a graphic symbol. The movie clip is basically a mouth moving that is stuck onto a face in the graphic to give the impression this it is talking. I just want to know whether there is anyway to stop and start the movie clip at specified frames, rather than having to create a seperate graphic symbol without the mouth.If someone could talk me through the process I would be most grateful.
Olly
Stop Clip At Certain Frame
I try to find a way to stop a movieclip at a certain framelabel.
If I click a button the movie 'nav' is going to play.
On a certain frame (with a label) in 'nav' I want the movie to stop. How do I do that?
on (press) {
_root.nav.play();
?
if(_root.nav._currentframe==_root.nav.label) {
stop();
?
}
}
Sister
Stop A Movie Clip
I have Frame 2, where the action is stop(). On that frame there is a movieclip. Now that movie clip still runs, even though there is a stop(). How can I actually stop that movie clip? If it helps, I'm making a game and when the player gets hit by an enemy I wanted to enemies to stop moving.
Thanks,
Meesta Plunk
Movie Clip Help ( Stop )
Hey guys, Im making a scroller kinda thing and I have a question. Right now I have it moving and each thumbnail will be a button. ( right now the cartoon bottle with the cape button only works. My questions is I need it so when I rollover the whole thumbnail I need the movie to stop moving and the rollover effect happens. Right now the cartoon works when I rollover it but I need the whole thing to stop. Any help?
http://xquisitegraphix.com/portfolio...incbanner.html
Thanks
Tom
AIM: xquisitegraphix
HELP How To Stop A Movie Clip?
I have a movie clip imported on the stage in Scene 1 frame 1, and the movie clip is 20 frames long. I want to know how could I tell the movie clip to play itself one time, then stop and move on to the next frame in Scene 1 (Scene 1 frame 2). What I actually mean here is I just want the movie clip to hold only 1 frame in Scene 1, because I have another motion tween on frame 2, but I don't want them to be played overlapping. So is there any actionscript I can add to the movie clip to tell it to play itself, and after it has done playing, then move to the next frame in the same Scene?
I have below actionscript applied on the movie clip:
onClipEvent(enterframe){
startDrag(blossom);
}
I have attached the FLA file of this movie clip, please have someone to tell me what's wrong and how to solve the problem.
Thanks,
Karen
karen_yan@hotmail.com
My Movie Clip Won't Stop
I've tried adding stop actions to the main timeline as well as within the movie clip timeline, but my clip won't stop. I've even tried adding a stop action at the end of just about every layer, but to no avail. There isn't even any exotic scripting going on. I've just got a movie within a movie that I'd like to stop near the end of the clip. The only scripting I have on the darn thing is a stop action.
Suggestions?
|