Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Flash Left/Right Drag Animation Sequence 2

Status
Not open for further replies.

lunarstudio

Technical User
Jun 23, 2006
5
US
Hi. I haven't used Flash in a long long time (Flash 3.) I'm trying this on the latest version of Flash. I've got an animation sequence - Jpgs. or bmps - or I can convert to a movie.

The image sequence is a rotating 3d image that goes counterclockwise.

I'd like to take this sequence into Flash and be able to drag left to make it appear that you are rotating the object clockwise and vice-versa.

Any suggestions/help is greatly appreciated.
 
Flash 3, those were the days...

Here's an example.

The set up:
- I have a MovieClip called "mcCow" in the frame 1 of the main timeline. This "mcCow" consists of 360° horizontal rotation of 3D cow exported in 30 images sequence. Therefore mcCow has 30 frames. It also has "stop()" in the frame 1.
- Create a new layer in the main timeline and name it "Actions"

The script in the frame 1 of the "Actions layer":

[tt]// AS2 - main timeline
var frameCount:Number = 30;
var speedFacter:Number = 10;
var picID:Number = 15;
rotate();
var prevMouse:Number = NaN;
stop();
//
mcCow.onPress = function():Void {
prevMouse = this._xmouse;
};
mcCow.onRelease = mcCow.onReleaseOutside=function ():Void {
prevMouse = NaN;
};
mcCow.onEnterFrame = function():Void {
if (!isNaN(prevMouse)) {
var xmouse:Number = this._xmouse;
picID += Math.floor((xmouse-prevMouse)/speedFacter);
picID %= frameCount;
if (picID<0) {
picID += frameCount;
}
rotate();
prevMouse = xmouse;
}
};
//
function rotate():Void {
mcCow.gotoAndStop(picID);
}
//[/tt]

You'll need to adjust the first 3 variables to suit your needs.

Kenneth Kawamoto
 
Hi Kenneth. Thanks you very much for your help. I tried all the steps you outlined:

1) create new document
2) create movie clip
3) import 101 frames to movie clip rename to "mcCow"
4) insert "stop()" frame 1 of movie clip
5) go to main timeline. Make sure dimensions match image (640x480) and frame rate (30fps).
6)insert movie clip main layer
7) create new layer rename "Actions"
8) Copy and paste your code into the first frame of actions layer.
9) Adjust 1st variable to 101 frames.
10) Test Movie.

And it doesn't seem to want to work. Also, what is this "var picID:Number = 15;" ?

Thanks,

Chuck
 
Make sure your MovieClip instance is named "mcCow" (it doesn't have to be "cow" by the way, I just called it "cow" because I was using 3D cow model!) - it's not the MovieClip symbol name in the Library, but name given for the instance on Stage.

"var picID:Number = 15;" is for setting the initial frame for mcCow. I have my cow facing front in frame 15 therefore I set the value to 15. You can pick any suitable frame number between 1 - 101 in your case.

Kenneth Kawamoto
 
Is your movie clip separated out to frames? I imported a sequence.
 
AH. I just saw the location I need to put it in. Thank you so freakin much. I really really really appreciate this. Like I said in a private email - I owe you a case of beer and a 3d model. Thanks man! That rocks.
 
Kenneth and Chuck:

I have found this post to be very helpful in my current project.

I am however running into a problem where the MC animates very smoothly when the mouse drags left, but hardly animates at all when you drag to the right. The only thing I have modified in the code is the top 3 variables and MC names.

Did you guys run into this problem?

Thanks
 
No not at all... Don't know what to say. You have a full 360 animation inserted no?
 
I have a placeholder in right now, because the model is being rendered as we speak. But when it rotates to the right, its just not going through the frames. . .I can see it visually, but also in my output window when I trace the frames.
 
Hi,

I was tracing my picID and just noticing it wasnt changing as often or as uniformly when I was dragging to the right.. I have placed in my actual 3D model and I am havng the same problem.

I feel like I have picked apart the code, and I understand almost every line of it, but it is still difficult to identify the problem. It is strange that I copy and pasted the code exactly and had this problem from the very begnning .

Would registration points have any effect on this? My reg point is top left for my MC that hold my 3D rotation
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top