-
how to combine two movie clip and rotate together in flash action script 2.0
Hi,
I have two movie clips.
I have attached screen shot of movie clip.
1. Movie clip : CD
below code rotate globe by mouse control.
CD.getMouseRotation = function(){
var x = this._parent._xmouse-this._x;
var y = this._parent._ymouse-this._y;
return Math.atan2(y,x)*180/Math.PI;
};
CD.positionToMouse = function(){
this._lastrotation = this._rotation;
this._rotation = this.getMouseRotation() - this._clickrotation;
};
CD.spin = function(){
this._rotation += this.spinSpeed;
this.spinSpeed *= .9;
};
CD.onPress = function(){
this._clickrotation = this.getMouseRotation() - this._rotation;
this.onEnterFrame = this.positionToMouse;
};
CD.onRelease = CD.onReleaseOutside = function(){
this.spinSpeed = this._rotation - this._lastrotation;
if (this.spinSpeed > 180) this.spinSpeed -= 360;
else if (this.spinSpeed < -180) this.spinSpeed += 360;
this.onEnterFrame = this.spin;
};
2. Movie clip : AE
below code rotate dynamic.
onEnterFrame = function(){
AE._rotation+=2;
}
how to combine two movie clip and rotate together.
could you guide me.
banner_step_1.jpg
-
You already have the mouse control set up all you need to do is set it to rotate constently at the speed of the world, which is controlled via the spinSpeed varible.
You currently have the spinSpeed set up as this.spinSpeed, So its a varible of CD
So something like should have it speed in time with the world
Code:
onEnterFrame = function (){
CD.AE._rotation += CD.spinSpeed;
}
I have placed CD.AE, as I would have thought you have set AE's MC inside of CD.
If not remove the CD and put AE.
If all is good please mark this and your other threads as resolved. Just helps see who still needs help.
You can mark resolved at the top of your thread via the thread Tools menu, top bar of your first post 
Hope all works
Mr Wabbit
Trust my code, and not my english.
-
Hi Wabbit,
The AE Movie clip actionscript change to:
i remove this code:
/* onEnterFrame = function(){ AE._rotation+=2; } */
i add below code, but still i'm not able to combine these two movie clip. what's my mistake...
onEnterFrame = function (){
CD.AE._rotation += CD.spinSpeed;
}
-
This would go on the root timeline actions.
OnEnterFrame is placed on frames
onClipEvent is place on mc's
You also want to makes sure the path is correct, as mentioned above, if AE is inside CD, this will work fine. If both are seperate at the root level, remove the CD from CD.AE
Trust my code, and not my english.
-
Hi Wabbit,
i'm not able to understand clearly,
My steps are:
I convert CD movie clip and actionscript event i add below code. ( My process is when i rotate the globe use by mouse and at the same time small fan(movie clip - AE ("another layer")) also rotate.
CD.getMouseRotation = function(){
var x = this._parent._xmouse-this._x;
var y = this._parent._ymouse-this._y;
return Math.atan2(y,x)*180/Math.PI;
};
CD.positionToMouse = function(){
this._lastrotation = this._rotation;
this._rotation = this.getMouseRotation() - this._clickrotation;
};
CD.spin = function(){
this._rotation += this.spinSpeed;
this.spinSpeed *= .9;
};
CD.onPress = function(){
this._clickrotation = this.getMouseRotation() - this._rotation;
this.onEnterFrame = this.positionToMouse;
};
CD.onRelease = CD.onReleaseOutside = function(){
this.spinSpeed = this._rotation - this._lastrotation;
if (this.spinSpeed > 180) this.spinSpeed -= 360;
else if (this.spinSpeed < -180) this.spinSpeed += 360;
this.onEnterFrame = this.spin;
};
onEnterFrame = function (){
CD.AE._rotation += CD.spinSpeed;
}
-
If on another layer then you can remove the CD.
So you get:
Code:
onEnterFrame = function (){
AE._rotation += CD.spinSpeed;
}
Trust my code, and not my english.
Tags for this Thread
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
|