kode
December 27, 2002, 1:01am
1
onClipEvent (enterFrame) {
if (this._currentframe == 1) playMe = true;
if (this._currentframe == this._totalframes) playMe = false;
if (playMe == true) this.nextFrame();
if (playMe == false) this.prevFrame();
}
[SIZE=1]PS: I’ve seen this asked a few times in some forums… I thought I should share my way.[/size]
system
December 27, 2002, 5:17am
2
Well in mx instead of making a whole new empty movie clip you can just put it on a frame like this…
_root.onEnterFrame = function() {
if (this._currentframe == 1) {
playMe = true;
}
if (this._currentframe == this._totalframes) {
playMe = false;
}
if (playMe == true) {
this.nextFrame();
}
if (playMe == false) {
this.prevFrame();
}
};
If ya wanted.
Very nice and simple code though.
system
December 27, 2002, 5:26am
3
Of course, if you want to get all obfuscated and stuff, you can do this…
_root.onEnterFrame = function() {
this._currentframe == 1 ? playMe=true : null;
this._currentframe == this._totalframes ? playMe=false : null;
playMe == true ? this.nextFrame() : this.prevFrame();
};
system
December 27, 2002, 7:49am
4
Wow, I managed to condense it even more… obfuscating is FUN!!!
:: ok ok, I am just really bored right now, what do you expect at 3am ::
_root.onEnterFrame = function() {
_currentframe == 1 ? playMe=true : _currentframe == _totalframes ? playMe=false : null;
playMe ? nextFrame() : prevFrame();
};
system
December 27, 2002, 8:04am
5
Hey I never said obfuscated was better, I just said I was bored
LOL, I needed something to do and for some reason, I had flash opened and the original code inside and I started messing with it.
And yes, you are allowed to do _root.onEnterFrame, I have seen it many places and used it many times myself. And I tested my code, it works.
And yes, it isn’t always best, because it gets all jumbled and confusing, so it is unreadable by the viewer and harder to process by the computer (I believe that is the way it goes).
Although obfuscated code does run slower depending on what you are doing, in this case it seems to run just the same (I think).
Some nice info here: http://www.bit-101.com/forum/viewtopic.php?t=1051 // pom
system
December 27, 2002, 8:20am
6
Wow, if using show streaming in the preview can help you determine how long it takes to work (by saying how long it takes to load), then my code is actually quicker.
Didn’t expect that one.
system
December 28, 2002, 2:39am
7
onClipEvent (enterFrame) {
gotoAndStop(_currentframe+dir);
}
if dir (short for direction) is 1, it plays forward. 0, is stop and -1 is backward. 2 is twice the speed, -2 is twice the speed backwards. 3 is three times the speed… etc. You dont need to check for 1 or total frames because it will just cap off there anyway.
system
December 28, 2002, 3:35am
8
Yeah, but that only plays in one direction senocular.
The code we are messing with plays forwards, and once it gets to the end, it plays the movie backwards, then forwards, then backwards, etc.
system
December 28, 2002, 3:43am
10
Yeah, but to make it go backwards then forwards again you will have to check for last and first frames :-\
system
December 28, 2002, 3:58am
11
fine
gotoAndStop(_currentframe + (dir = (_currentframe == _totalframes) ? -Math.abs(dir) : (_currentframe == 1) ? Math.abs(dir) : dir));
system
December 28, 2002, 4:14am
12
Test it, when it gets to the end it flicks back and forth rapidly
system
December 28, 2002, 4:33am
14
boy thats confusing!! can’t you programmers keep it simple :beam:
system
December 28, 2002, 4:35am
15
Interesting, That code in the .zip file is exactly the same, but when I use the code you put in your post, it doesn’t work.
Hmmmmm… odd. Oh well.
Anyone else got some interpretations of this code? I want to see how far we can take this :beam:
system
December 28, 2002, 4:42am
16
yay Im not dumb afterall!
system
December 28, 2002, 4:42am
17
Never said ya were That code is very nice. I just wasn’t sure if you tested it because it wasn’t working on this end.
system
December 28, 2002, 6:48am
18
7000!! you can’t be stopped huh?
system
December 28, 2002, 3:06pm
19
7005 (44.20 posts per day)
lol
how do you have time to code with all the time you spend in the forum?
system
January 15, 2003, 6:32pm
20
now what if you wanted to have this action be triggered by a button? do I just make a action for the button?