-
Hi all,
I have a couple movie clips that I move from right to left. They are in a movie clip called "footer" . I want to make a function that moves them from right to left until they get to a certain point and then go back to the beginning so that it loops over and over. On my main movie time line I have a function that takes in the name of a movie clip:
function books(name){
if (_root.footer.name._x <= -170){
_root.footer.name._x = 595;
_root.footer.name._x -= 1;
}else{
_root.footer.name._x -=1;
}
}
on the movie clip I have the code:
on ClipEvent(enterFrame){
books(mxsource); //name of this movie clip is "mxsource"
}
The movie clip does not move at all. Anyone got anything for me I would appreciate.
thanks,
Justin
-
Senior Member
52426t25243242
im not sure if this syntax still works in FLASH MX but its worth a shot... try:
onClipEvent (enterframe){
blah blah blah
this._x= this._x+1
this._y= this._y+1
if ( this._x>=[this is where you would insert your boundaries]
then this._x= this._x -1.
}
hope you get the general idea. and Hopefully this helps you.
-
Keeper of Brooms and Jars
I've just recently made friends with functions and i had a problem *exactly* like yours. The thing is you have to specify where the function is when you call it. so, instead of
onClipEvent(enterFrame){
books(mxsource);
}
try
onClipEvent(enterFrame){
_root.books(mxsource)
}
it worked for me, maybe it will work for you... either way, happy flashing
-
Hi,
While what pkghost said was correct, it probably won't completely solve your problem. The issue is that you use the name of the movie clip within the movie clip itself, so it tries to find mxsource within the mxsource movie clip, but there isn't one. Try this:
Code:
function books(path){
if (path._x <= -170){
path._x = 594;
}else{
path._x -=1;
}
}
Here I just cleaned up your code a bit and made it ready to accept a reference instead of a name. On the movieclip itself, put this:
Code:
onClipEvent (enterFrame) {
_root.books(this);
}
What this will do is send a reference to the movieclip to the function, and the function will use that to move the clip across the stage. Hope this helps, and if you have any questions, don't hesitate to ask. Chuckles8421
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
|