-
Banned
Hi,
Yes, the line in the middle is the bitwise operator "Or". Check to make sure your instance names are correct. The function is applied the same way a standard play or stop function is invoked.....
code:
myButton.onRollOver = function() {
startFrame = 1;
mcInstanceName.play();
}
myButton.onRollOut = function() {
startFrame = 0;
mcInstanceName.back();
}
I only have FlashMX and most posted files are MX2004 or later, so I didn't look at the file.
-
-
Freelance Web Designer
Originally Posted by NTD
Hi,
Another method involves Actionscript, using the prevFrame function in an enterframe event to reverse a timeline...
code:
startFrame = 0;
movieclip.prototype.back = function() {
this.onEnterFrame = function() {
this.prevFrame();
// DELETES THE ENTERFRAME IF THE CLIP IS AT FRAME 1
if (this._currentframe == 1 | startFrame == 1) {
delete this.onEnterFrame;
mcInstanceName.play();
}
}
}
myButton.onRollOver = function() {
startFrame = 1;
mcInstanceName.play();
}
myButton.onRollOut = function() {
startFrame = 0;
mcInstanceName.back();
}
OK, i have a question for you. i've been trying to use that reverse effect in a muliple movie clip in one SWF but i got messed up. even though i changed the name of the movie clip. like if the mouse was over one button the other button do the ainmation.. was kinda funny but not what i was looking for. any idea on how to have the same script with diffrent buttons in one SWF?
have a happy new year, btw
-
Banned
Hi,
The simple solution would be to remove the prototype and use the function as a normal function. You can specify multiple clips as target parameters. Something like..
code:
startFrame = 0;
function back(targ) {
targ.onEnterFrame = function() {
targ.prevFrame();
// DELETES THE ENTERFRAME IF THE CLIP IS AT FRAME 1
if (targ._currentframe == 1 | startFrame == 1) {
delete targ.onEnterFrame;
mcInstanceName.play();
}
}
}
myButton.onRollOver = function() {
startFrame = 1;
mcInstanceName.play();
}
myButton.onRollOut = function() {
startFrame = 0;
_root.back(mcInstanceName);
}
-
Senior Member
Try this, put the code on the MC that animates...
onClipEvent (enterFrame) {
if (this.hitTest(_root._xmouse, _root._ymouse, true)) {
this.nextFrame();
} else {
this.prevFrame();
}
}
this is the simplest way to make a MC play backwards on rollOut
-
Banned
That will work, but it will call the enterFrame event 12 times per second, or whatever frame rate your using, whether the clip is stopped at frame 1 or not. A couple of other onEnterFrame events and an old or slow cpu wont like you much. It's good practice to delete enterFrame events when not in use.
-
Senior Member
Hey NTD,
if I placed updateAfterEvent(); where I did would this solve the problem?
onClipEvent (enterFrame) {
if (this.hitTest(_root._xmouse, _root._ymouse, true)) {
this.nextFrame();
} else {
this.prevFrame();
updateAfterEvent();
}
}
-
Banned
No, the enterframe event continues to fire at the frame rate per second. UpdateAfterEvent is used to refresh the screen when using setInterval calls. It updates the display (independent of the frames per second set for the movie) when you call it within an onClipEvent handler or as part of a function or method that you pass to setInterval. Flash ignores calls to updateAfterEvent that are not within an onClipEvent handler or part of a function or method passed to setInterval.
You would need to check if the clip is at frame 1 and delete the enterFrame event. However, with the set up of onClipEvent, this will only allow the code to operate one time once the enterFrame event is deleted. This is why I wrote the function, so that the enterFrame event is reusable after being deleted.
-
Senior Member
I'm sorry where do I place this code, can I place it on my MC or do I place it on the timeline
startFrame = 0;
function back(targ) {
targ.onEnterFrame = function() {
targ.prevFrame();
// DELETES THE ENTERFRAME IF THE CLIP IS AT FRAME 1
if (targ._currentframe == 1 | startFrame == 1) {
delete targ.onEnterFrame;
mcInstanceName.play();
}
}
}
myButton.onRollOver = function() {
startFrame = 1;
mcInstanceName.play();
}
myButton.onRollOut = function() {
startFrame = 0;
_root.back(mcInstanceName);
}
-
Banned
I rarely use object code. Consider if you have 1000 movieclips with object code that needs updateing The major difference between object code and frame code is that frame code passes itself to an object by instance name. Frame code is easier to edit at a later point especially with complex projects. The code I posted above would reside on the first frame of a movie. Usually on a layer labeled "actions" above all other content. Pass the instance name of the clip you want to effect in the function parameters....
_root.back(mcInstanceName);
-
Senior Member
Hey I have tried it and it doesn't seem to work, could you post a quick source file for me. I am a designer and "self taught programmer", its usually easy for me to decipher code if I see it!
That would be great!
Thanks again!
-
Banned
Here is a quick demo link of it in action........
http://www.ntdesigns.net/demoFiles/reverseMC.swf
The above link uses the first prototype function I posted. I have to step out for awhile. I'll post a demo of the regular function without prototype inheritance later tonight or tomorrow.
NTD
-
Senior Member
Thanks sooo much, I appreciate it!
-
Senior Member
Hey NTD, Thankful, and everyone
In refrence to Thankfuls demo and NTD's code
the code does not work for flash 8, it plays but does not reverse!
any fixes?
I know your working on a source file for me NTD so keep in mind I am
using flash 8.
Thanks again!
Last edited by freshly; 01-04-2006 at 11:28 PM.
-
Banned
Hi,
I don't have Flash8. Maybe the prototype inheritance is causing an issue as Flash8 uses class based inheritance. However, both AS1 and AS2 are supported by Flash8, so not sure if the problem is code related. Here is a quick demo of using a regular function to control multiple movieclip timelines.
Regards
NTD
-
Senior Member
Actually this demo that you have made for me works fine in Flash 8 as well.
Thanks very much, I appreciate it.
Freshly
-
I'm learning...
I don't know what I'm doing wrong here, but regarding this reply:
http://www.flashkit.com/board/showpo...2&postcount=23
by ehabaref (in this same thread, same page)...
I'm having exactly the same problem when I'm trying to place two different "buttons" with different onPress actions on them... it looks like one works well, while other acts strange... it activates another "button" on the scene etc.
Is there any source code where we can see both buttons in action not interfering one with another by any chance ?
Thanks in advance !
:: ONLINE PORTFOLIO :: web site (Flash version 7 required, recommended screen resolution: at least 1024x768 pixels)
-
Freelance Web Designer
try that code
it works perfectly with me
b1.onRollOver = over;
b1.onRollOut = out;
b1.onrelease = over1;
b2.onRollOver = over;
b2.onRollOut = out;
b2.onrelease = over2;
b3.onRollOver = over;
b3.onRollOut = out;
b3.onrelease = over3;
b4.onRollOver = over;
b4.onRollOut = out;
b4.onrelease = over4;
b5.onRollOver = over;
b5.onRollOut = out;
b5.onrelease = over5;
function over() {
this.gotoAndPlay(6);
}
function out() {
this.gotoAndPlay(21);
}
function over1() {
getURL("javascript :NewWindow=window.open('link','m yWindow','width=772,height=443,left=100,top=100,to olbar=No,location=No,scrollbars=No,status=No,resiz able=No,fullscreen=No'); NewWindow.focus(); void(0);");
}
function over2() {
getURL("link", "_blank");
}
function over3() {
getURL("link", "_blank");
}
function over4() {
getURL("link", "_blank");
}
function over5() {
getURL("link", "_blank");
}
-
Freelance Web Designer
you also need to use AS1 in order for the code to work
-
I'm learning...
Thanks a lot... the only problem is I have to use AS2 because rest of the Flash where I want to use this requires AS2 to run properly.
Anyway, do you use this code you just provided with those examples from the beginning of this thread, or you have something else running in the background ?
Thanks again !
:: ONLINE PORTFOLIO :: web site (Flash version 7 required, recommended screen resolution: at least 1024x768 pixels)
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
|