Movment and then moving on

hello. i have an object that moves around, and once it is pressed, i want it to move to a specific place and then continue to the next frame in the movie clip. this is what i have : a movie clip, the first frame has the stop(); command and contains approx 12 frames. the mc has this script attached to it :
onClipEvent(enterFrame){
if(_x >= 0){
_x = _x - 10
}
if(_y >= 0){
_y = _y -10
}
if(_x == 0 && _y == 0){
gotoAndPlay("/ball",2) // ball being the instance name of the mc
}
}
the first two parts do move the object to where i want it but the third part will not work and i cant get it to move past frame 1. can anyone please help me?(note : 0,0 is not the place i want it to move to, it is there because i was experimenting with the code and this was an easy place to assign to the movment)

how about this… You might have to verify the spelling in your code for i am coding this off the top of my head…

put this on the movie clip itself. (click on the MovieClip then select the editor)


onClipEvent(load){

var endx = 10;
var endy = 10; //set it the same so it doesnt move

this._x = 10; //initial x Location
this._y = 10; //Inital Y locatinon

}
//This is Lost’s Code

onClipEvent (mouseDown) {
endx = -100; //new X to move to;
endy = -100; //New y to move to;
}
onClipEvent (enterFrame) {
_x += (endx-_x)/speed;
_y += (endy-_y)/speed;
}


First you’ll need to make your object a movie clip (just convert that) click on it, then open the editor and put that code in , should work fine =) hope its not too advanced for ya =) let me know ify ou need help =)

thanks for the code but like i said, i can get it to move, but i want the animation to continue after the first frame in the movie clip. maybe i explained it wrong… my object is a movie clip and the code i put up above(my code) is attached to it and will move it to the point i want. in the movie clip, there is a stop(); command in the first frame allowing for the movment to happen before it continues with the animation. one the object is clicked, it moves to the specified point but wont go to the next frame in the movie clip. how can i get it to move to the next frame in the movie clip after it has been moved to its new location?

gotoAndPlay(n);

where n is the frame number…

you mean that?

yes, but i wanted it to be conditional ie:
if(_x == 0 && _y == 0){// so that x and y reach its position. im not sure if this works in flash but it works in c++ and they are similar so im hoping…
gotoAndPlay(2)
}
but when i do this. it dosent work

try
this.gotoAndPlay(2);
flash has finicky scoping issues

thanks for the advice but that dosent seem to fix it… the only thing that i have gotten to work is if i make object inside the movie clip a button and assign the script:
on(press){
gotoAndPlay(2)
}
any ideas? i really dont understand what its problem is…

http://www.kirupaforum.com/forums/showthread.php?s=&threadid=7457 ?

Hi,

When you use your if with just _x and _y are you sure that it’s looking at the correct properties? What about doing this._x and this._y as that might ensure the correct objects properties are being used.

Another thing to try is to put in an else and trace the values held by _x and _y.

Liz

using this._x/y did not work still.
if(this._x == 0 && this._y == 0){//it dosent work with or without this.
this.gotoAndPlay("/ball",2) // ball being the instance name of the mc
}
^does anyone see anything thats wrong with this code? its in a onClipEvent(enterFrame). i think im just going to find a different way of going about this. if yall have any ideas let me know. i am using flash mx. thanx everyone for your ideas and help.

If your ball movie clip is what the code is attached to then try just using this.gotoAndPlay(2) without including the movie clip name in the call to gotoAndPlay.

If this code is attached to a different movie clip then try doing something like…

_root.ball.gotoAndPlay(2);

or whatever the path to your ball movie clip is.

HTH
Liz

no, still not working. what does this. do? is it like saying the objects name is this. so that it always refers to the object. im a newbie to action scripting. ive had other coding experience so i can look at the code and guess for the most part but it dosent always work like that…

maybe there is something wrong with the: if(_x == 0 && _y == 0)???

Could be you could try rephrasing to
if ( (_x==0) && (_y==0) ) {

that will make it clear to the compiler what order you intend things to happen.

this. is used to indicate the current object (it is part of OOD/P) Object Oriented Design/Programming

When you have an object, like a movie clip and you want the movie clip to do something to itself you use this.<some property> = newValue to set the property.

So if you attach a function to a movie clip you can then use the this. to affect a change to the current movie clip.

If you post your .fla I’ll take a look at it and see if I can spot anything.

Liz

alright, here they are… but let me explain exactly whats going on:
the first one is the actual web page. what i want to happen is when u click on a picture, it moves to a point in the page no matter where the pic was, this is why i thought it would be best to use action scripting. once it got there, i wanted it to enlage and for detail to desplay.
the second one is the fla file i was experimenting with the code in trying to get it to work before i moved it to my actual page.

http://gst.iceman.tripod.com/portfolio.fla
http://gst.iceman.tripod.com/actionscripting.fla

i uploaded the two fla files to a tripod account of my friend. let me know if u can get them and look at them.

to dl them, right clik on them and go to save as… then change html to all files and name it portfolio.fla or code.fla. try that. thanks for your help.

Okay, I took a look at your action script one and this is what I came up with that works, now I’m not positive why this works and yours didn’t except it might have something to do with the code being in enterFrame and possibly restarting the whole thing when you didn’t want it to.

Liz

wow, awsome. thanks for all your help