View Full Version : Would this work?
Colin Campbell
07-03-2003, 02:37 AM
I was thinking of a code for a slider that on mouse would come to the button from which ever postition it was in before. Would this code work? Is there an easier way to do this? (I thought of this code by myself too :p)
on (mouseOver) {
// lets suppose the mc is at 300 on the x axis
if (_root.myMovieClip._x => 300) {
_root.mySlider._x++
}
if (_root.myMovieClip._x <=300) {
_root.mySlider._x--
}
}
black
07-03-2003, 06:04 AM
with this code your slider could move only once when mouse over event is occured, if you need continuous action try enterFrame event. :)
Regards~
annexion
07-03-2003, 06:40 AM
on (mouseOver) {
// lets suppose the mc is at 300 on the x axis
if (_root.myMovieClip._x >= 300) {
_root.mySlider._x++;
}else{
_root.mySlider._x--;
}
}
I fixed some of your syntax for you ;)
Colin Campbell
07-03-2003, 09:18 PM
will that work continuously?? I need it to work continuously to work.
Timmee_3Styler
07-03-2003, 10:02 PM
it will continiously work as long as your mouse is over that object
annexion
07-03-2003, 10:10 PM
No it won't.
This will however.
on (mouseOver) {
_root.myMovieClip.onEnterFrame=function(){
if (_root.myMovieClip._x >= 300) {
_root.mySlider._x++;
}else{
_root.mySlider._x--;
}
}
}
But with that code, it's going to keep moving back and forth, if you want it to move, then stop the following will work:
on (mouseOver) {
_root.myMovieClip.onEnterFrame=function(){
if (_root.myMovieClip._x >= 300) {
_root.mySlider._x++;
}else{
delete this.onEnterFrame;
}
}
}
Something like that, I'm lazy so it's not perfect. But, that should give you some direction.
Good luck.
Timmee_3Styler
07-03-2003, 10:20 PM
o fudge me........!!! i suck
Colin Campbell
07-03-2003, 10:20 PM
How about an 'if, else if' statement? Like this:
on (mouseOver) {
_root.myMovieClip.onEnterFrame=Function () {
// lets suppose the mc is at 300 on the x axis
if (_root.mySlider._x => 300) {
_root.mySlider._x++
} else if (_root.mySlider._x <=300) {
_root.mySlider._x--
}
}
}
I think I'm getting alot better at actionscript after getting that book. I'm only on page 500 because I've been really busy, but I've already learned so much!
not to mention this service
soup
Colin Campbell
07-04-2003, 01:22 AM
lol, I haven't been on much. :( I've been really busy figuring stuff out. Golf, job, and this other forum I SMOD at just went through some tough times. Oh well, I'll be on more once this passes.
Colin Campbell
07-04-2003, 01:39 AM
I can't get it to work for my life :( any help? This is really getting annoying. -.-
Timmee_3Styler
07-04-2003, 01:47 AM
on (mouseOver) {
_root.mySlider.target = 300
}
mySlider.onEnterFrame = function () {
if (_x => target) {
_x++
} else {
_x--
}
}
Colin Campbell
07-04-2003, 01:55 AM
Theres one more problem in the syntax that I can't seem to find out whats wrong. Heres what comes to the output window when I check for errors:
Line 5: Statement must appear within on/onClipEvent handler
mySlider.onEnterFrame=function () {
Timmee_3Styler
07-04-2003, 02:01 AM
oopz put that code on the main timeline.....
or u can put
onClipEvent (load)
{
CODING
}
Colin Campbell
07-04-2003, 02:17 AM
AHHHH! Life blows! Can someone post a sample .fla? I'm really really sorry. I'm just so lost as to why this won't work... :(
annexion
07-04-2003, 03:16 AM
See, with that if else statement, you're not killing the enterFrame. So it's sitting there using more resources than it needs to. That was my concern in giving it to you. As it stands now it sends it to the target, but doesn't null or delete the enterFrame.
Colin Campbell
07-04-2003, 03:25 AM
What about if I made to of those but made it so that there was one for when the slider was above 300 on the x axis and one for when it is below it... I'll try that. I'm out for tonight though. Thanks for the help. Tomorrows another day. OK, i got this, maybe it'll work:
on (rollOver) {
_root.myMovieClip.onEnterFrame=function(){
if (_root.mySlider._x >= 300) {
_root.mySlider._x++;
}else{
delete this.onEnterFrame;
}
}
_root.myMovieClip.onEnterFrame=function(){
if (_root.mySlider._x <= 300) {
_root.mySlider._x--;
}else{
delete this.onEnterFrame;
}
}
}
}
annexion
07-04-2003, 04:49 PM
on (rollOver) {
_root.myMovieClip.onEnterFrame=function(){
if (_root.mySlider._x > 300) {
_root.mySlider._x--;
}else if(_root.mySlider._x < 300){
_root.mySlider._x++;
}else{
delete this.onEnterFrame;
}
}
}
Colin Campbell
07-04-2003, 05:15 PM
now to apply it. I'm going to need a button named myMovieClip, correct? and a movie clip named mySlider... is that all? Where should I put that code?
Colin Campbell
07-04-2003, 08:03 PM
Bah! It won't work! I've fiddled with it for 2 hours and it won't work! Can someone post that example fla before I do something I'll regret? :p
Timmee_3Styler
07-05-2003, 02:35 AM
you sure you got all the references right?
cause annexion code looks okay 2 me
Colin Campbell
07-05-2003, 02:44 AM
dang. Thats why I want a sample fla. Cuz theres definitly something wrong with what I'm doing. Where should I put that code? What about this?
_root.myMovieClip.onRollOver {
_root.myMovieClip.onEnterFrame=function(){
if (_root.mySlider._x > 300) {
_root.mySlider._x--;
}else if(_root.mySlider._x < 300){
_root.mySlider._x++;
}else{
delete this.onEnterFrame;
}
}
}
Timmee_3Styler
07-05-2003, 02:51 AM
that should work where myMovieClip is your button
and
mySlider is your slider and both are on the main timeline
Colin Campbell
07-05-2003, 02:55 AM
Thats everything right there. I had that... ugh, I really want this to work. SO bad. I just figured out that whole masking deal... and now this is all I need.
Timmee_3Styler
07-05-2003, 03:14 AM
fudge
im trying to figure out this scrpit on how to dynamically mask the same raster picture 16 times =/
eh ill open up flash to fix ur little problem I hope
Colin Campbell
07-05-2003, 03:16 AM
heres what I have so far. It might be wrong because I have fiddled with it considerably. :p
Timmee_3Styler
07-05-2003, 03:20 AM
on (rollOver) {
_root.mySlider.onEnterFrame = function() {
if (_root.mySlider._x>301) {
_root.mySlider._x--;
} else if (_root.mySlider._x<299) {
_root.mySlider._x++;
} else {
delete _root.mySlider.onEnterFrame;
}
};
}
put that in the AS of your buttons :D
Colin Campbell
07-05-2003, 03:28 AM
lets see if this works.... *crosses fingers*
Timmee_3Styler
07-05-2003, 03:29 AM
it should work
i had this pretti box move across the screen until it hit somewhere between 299 n 301
hahah
but then again im seem to have everything wrong today
Colin Campbell
07-05-2003, 03:32 AM
Dude, you rock! It worked! only one problem though. Since the slider and the button are different sizes, they don't line up... but that can be fixed. :D thanks so much!
EDIT: resizing doesn't help either... any ideas?
Timmee_3Styler
07-05-2003, 03:40 AM
line up?
wat you want?
well I guess when I was your age I made this system where the slider(elastically) u might wanna add that slides to the button I was mouseovered..perfectly in the middle....... so u might wanna play with the buttons registration pt n make it in the middle
then on the main timeline make it set on 300 n it should b aligned
I think
Colin Campbell
07-05-2003, 03:43 AM
hmmmm, I'll try that. But just for future thoughts, why do you think the slider won't go under the button like the code suggests? Could I be that the slider is off?
EDIT: MUAHAHAHHAHAHHAHHA!!! The slider was off center in its own timeline, then causing it to be off in the main one... now to make the slider move quicker... :p
Timmee_3Styler
07-05-2003, 03:45 AM
or cause the buttons registration pt is left aligned... therefore when you found the button is located @ 300... the middle portion of the button might be @ 350...
300 is the left most pt of your button
CyanBlue
07-05-2003, 03:48 AM
Yup... As Timmee101 said... I just changed the registration point and it is working as it is supposed to be...
Colin Campbell
07-05-2003, 03:51 AM
how do I change the registration point? (for future reference) nevermind, got it.
Timmee_3Styler
07-05-2003, 03:52 AM
*sigh* im not sure
the only way I know is manuallly
in the buttons timeline
aligned everthing using the align panel n center the entire object
Colin Campbell
07-05-2003, 04:03 AM
thanks alot guys! I'll need to figure out how to make it go quicker, but I'll do that by myself, or try by myself, and have a new thread up by probably monday. :p Thanks again
Timmee_3Styler
07-05-2003, 04:09 AM
just incrrease the counter :p
Colin Campbell
07-06-2003, 01:10 AM
and how do I do that??? Would it be like
_root.mySilder._x++*2
Timmee_3Styler
07-06-2003, 03:28 AM
_root.mySlider += 2
or
_root.mySlider = _root.mySlider + 2
Colin Campbell
07-07-2003, 02:19 AM
oh, so instead of _root.mySlider._x++
just replace it with _root.mySlider= _root.mySlider +2
Timmee_3Styler
07-07-2003, 02:33 AM
yupyupyup
basic programming in
javascript and java and asp and AS
and pretti sure alot of other languages
but i only know those 4
Colin Campbell
07-07-2003, 02:37 AM
kk... I'm learning ok?! I'm learning! :p Sorry, I'm stupid. :p I'm going to start on my site though, which should rock
Colin Campbell
07-12-2003, 07:38 PM
For future reference:
This is the final code I have, I thought it might be helpful to post it for the person coming along with the same problem...
on (rollOver) {
_root.mySlider.onEnterFrame = function() {
if (_root.mySlider._x>304) {
/* because it moves at a speed of 8, instead of 301 in it, its 304. I did this
because 301 causes it to move back and forth. To arrive at 304, I took 8
and divided it by 2, which is four plus 300,
hence 304. Same with down there. */
_root .mySlider._x = _root.mySlider._x -8;
} else if (_root.mySlider._x<296) {
_root .mySlider._x = _root.mySlider._x +8;
} else {
delete _root.mySlider.onEnterFrame;
}
};
}
Timmee_3Styler
07-12-2003, 08:53 PM
Great ;)
Colin Campbell
07-12-2003, 10:29 PM
I figured that out all by myself! Mommy WOW! I'm a big boy now! j/k j/k That works fine, not as smoothly as possible but it shall work fine.
Timmee_3Styler
07-13-2003, 08:42 PM
post that sucker :p
|
vBulletin® v3.8.3, Copyright ©2000-2009, Jelsoft Enterprises Ltd.