Hello I am back ! Here is what I have been working on:
Everything is working the way I want but I need three things
1. The bouncing effect needs angular movement (so, if I say it to bounce along the 30 deg it should bounce along the 30 degree line)
2. I need the bouncing to stop whenever I create a new line.
3. I need to draw the line and make the registration point in the middle. (in other words when I hit rotate it should rotate along the center. It does that now but its a little bit off.)
I am a noob so please excuse my way of coding. (hey! I am learning!)
Code:
#include "mc_tween2.as"
/* Initial Setup
When the movie first loads, we want the rectangle to have a width & height of "0"
If you want a different height, adjust the values below.
Sample syntax: rect_mc.resizeTo (width, height, time (in seconds), animation type);
We also want to set the text inputs to show that the dimensions are 0 x 0 */
rect_mc.resizeTo(0, 0, .5, "easeOutQuad"); //Initial Rectangle Resize Function
width_text.text = "10"; // Width text field
height_text.text = "100"; // Height text field rot_text
rot_text.text = "0";
//Background color Radio Button.
rb_shape_ln.data = "line";
rb_shape_cr.data = "circle";
//Create new movie
createEmptyMovieClip("tmp_mc", 1);
line1_mc.moveTo(0,0);
//Background color Radio Button.
base_mc.cacheAsBitmap = true;
rb_color_w.data = "0xFFFFFF";
rb_color_b.data = "0x000000";
//Background color Radio Button.
rb_shape_ln.data = "line";
rb_shape_cr.data = "circle";
/* createBtn.onRelease function - activates when you click on the "Create" button */
createBtn.onRelease = function() {
text_mc.text = shapeGroup.selectedData;
this.stop();
tmp_mc.clear();
base_mc.clear();
var rectWidth = width_text.text; // Read in what's in the text input
var rectHeight = height_text.text;
var rectRot = rot_text.text;
var colorData = (Number(baseColorGroup.selectedData));
var tmp;
base_mc.opaqueBackground=colorData;
//Selecting Fill color
if (colorData == 16777215){
tmp = 0x000000;
}
else {
tmp = 0xFFFFFF;
}
if (shapeGroup.selectedData == "line"){
tmp_mc.lineStyle(rectWidth,tmp,100);
tmp_mc.moveTo(0, (rectHeight/2));
tmp_mc.lineTo(0, (-(rectHeight)));
tmp_mc._y = Stage.height/2;
tmp_mc._x = Stage.width/2;
tmp_mc.rotateTo(rectRot, .5, "linear");
}
else if (shapeGroup.selectedData == "circle"){
// use the method to draw a circle in movieclip c
// at x=100, y=100 with a 70-pixel radius
tmp_mc.beginFill(tmp, 100);
tmp_mc.drawCircle(rectWidth, Stage.height/2, Stage.height/2);
tmp_mc.endFill();
}
else {
text_mc.text = "Please Select Shape";
}
}
/* On press rotates */
rot_Button.onRelease = function() {
var i = 0;
while (i<=1000){
tmp_mc.rotateTo(i,3,"linear");
i +=1;
}
}
/* On press bounces the shape */
bounce_Button.onRelease = function() {
var gravity = 100;
var floor = tmp_mc._y+200;
var Vy = 0;
//tmp_mc._y = 40;
tmp_mc.onEnterFrame = function() {
Vy += gravity;
this._y += Vy/4;
if (this._y > floor) {
this._y = floor;
Vy = -Vy;
}
}
}
/* rect_mc.onPress function - activates when you click on the rectangle */
tmp_mc.onPress = function() {
this.startDrag();
}
/* rect_mc.onRelease function - activates when you release the mouse */
tmp_mc.onRelease = function() {
this.stopDrag();
}
// Draw circle method
MovieClip.prototype.drawCircle = function (r, x, y) {
var TO_RADIANS:Number = Math.PI/180;
// begin circle at 0, 0 (its registration point) -- move it when done
this.moveTo(0, 0);
this.lineTo(r, 0);
// draw 12 30-degree segments
// (could do more efficiently with 8 45-degree segments)
var a:Number = 0.268; // tan(15)
for (var i=0; i < 12; i++) {
var endx = r*Math.cos((i+1)*30*TO_RADIANS);
var endy = r*Math.sin((i+1)*30*TO_RADIANS);
var ax = endx+r*a*Math.cos(((i+1)*30-90)*TO_RADIANS);
var ay = endy+r*a*Math.sin(((i+1)*30-90)*TO_RADIANS);
this.curveTo(ax, ay, endx, endy);
}
this._x = x;
this._y = y;
}
Bookmarks