New AS Experiment: Jump Orbs

Alright, everyone here knows my coding isn’t exactly that efficient, I am a very sloppy coder, but here goes the code…

[AS]MovieClip.prototype.drawSquare = function(r, x, y) {
this.lineStyle(.25, 0x000000, 50);
this.beginFill(0xE6E6E6, 50);
this.moveTo(-r, -r);
this.lineTo(r, -r);
this.lineTo(r, r);
this.lineTo(-r, r);
this.lineTo(-r, -r);
this.endFill();
this._x = x;
this._y = y;
};
MovieClip.prototype.drawSliderLine = function() {
this.lineStyle(1, 0x000000, 50);
this.moveTo(0, 0);
this.lineTo(100, 0);
};
MovieClip.prototype.drawCircle = function(x, y, r, lineThickness, RGB, alpha, xpos, ypos) {
var c1 = r*(Math.SQRT2-1);
var c2 = rMath.SQRT2/2;
this.lineStyle(lineThickness, RGB[0], alpha[0]);
this.beginFill(RGB[1], alpha[1]);
this.moveTo(x+r, y);
this.curveTo(x+r, y+c1, x+c2, y+c2);
this.curveTo(x+c1, y+r, x, y+r);
this.curveTo(x-c1, y+r, x-c2, y+c2);
this.curveTo(x-r, y+c1, x-r, y);
this.curveTo(x-r, y-c1, x-c2, y-c2);
this.curveTo(x-c1, y-r, x, y-r);
this.curveTo(x+c1, y-r, x+c2, y-c2);
this.curveTo(x+r, y-c1, x+r, y);
this.endFill();
this._x = xpos;
this._y = ypos;
};
MovieClip.prototype.createSlider = function(x, y, startPos, effectVar) {
this.createEmptyMovieClip(“sliderLine”, -10).drawSliderLine();
this.createEmptyMovieClip(“slider”, -9).drawSquare(5, startPos, 0);
this.slider.onPress = function() {
this.startDrag(true, 0, 0, 100, 0);
this.onMouseMove = function() {
this._parent.sliderLabel.text = Math.round(this._x);
this._parent.sliderLabel.setTextFormat(myFormat);
if (effectVar == “affectArea”) {
affectArea = Math.round(this._x);
} else if (effectVar == “pushDist”) {
pushDist = Math.round(this._x);
}
};
};
this.slider.onRelease = this.slider.onReleaseOutside=stopDrag;
this.createTextField(“sliderLabel”, -6, 110, -8, 100, 16);
this.sliderLabel.text = startPos;
this.sliderLabel.selectable = false;
this.sliderLabel.setTextFormat(myFormat);
this._x = x;
this._y = y;
};
MovieClip.prototype.jumper = function() {
this.startX = this._x;
this.startY = this._y;
this._xscale = this._yscale=this._alpha=15;
this.onMouseMove = function() {
if (this._parent.hitBlock.hitTest(this._parent._xmouse, this._parent._ymouse, true)) {
this._x = this.startX;
this._y = this.startY;
this.dx = this._x-this._parent._xmouse;
this.dy = this._y-this._parent._ymouse;
this.hyp = Math.sqrt(this.dx
this.dx+this.dythis.dy);
if (this.hyp<affectArea) {
this.strength = Math.pow((affectArea-this.hyp)/affectArea, 3);
this._x += pushDist
this.strengththis.dx/this.hyp;
this._y += pushDist
this.strengththis.dy/this.hyp;
this._xscale = this._yscale=this._alpha=15+100
this.strength;
} else {
this._xscale = this._yscale=this._alpha=15;
}
} else {
this._x += (this.startX-this._x)/5;
this._y += (this.startY-this._y)/5;
this._xscale = this._yscale=this._alpha += (15-this._xscale)/5;
}
};
};
myFormat = new TextFormat();
myFormat.font = “Verdana”;
myFormat.size = 10;
var maxClips = 95;
var affectArea = 50;
var pushDist = 25;
this.createEmptyMovieClip(“hitBlock”, -10).drawSquare(99, 100, 100);
this.createEmptyMovieClip(“slider1”, -100).createSlider(55, 220, 50, “affectArea”);
this.createEmptyMovieClip(“slider2”, -99).createSlider(55, 240, 25, “pushDist”);
this.createEmptyMovieClip(“circle”, -7).drawCircle(0, 0, 20, 5, [0x000000, 0xFFFFFF], [100, 0], 10, 10);
this.createTextField(“slider1Label”, -1000, 10, slider1._y-18, 500, 16);
slider1Label.text=“Affected Area”, slider1Label.selectable=false, slider1Label.setTextFormat(myFormat);
this.createTextField(“slider2Label”, -2000, 10, slider2._y-18, 500, 16);
slider2Label.text=“Push Distance”, slider2Label.selectable=false, slider2Label.setTextFormat(myFormat);
circle._visible = false;
for (var i = 0; i<maxClips; i++) {
mc = circle.duplicateMovieClip(“circle”+i, i);
mc.createEmptyMovieClip(“center”, 1).drawCircle(0, 0, 10, 0, [0x000000, 0x666666], [0, 100], 0, 0);
mc._x = (i*20)+20;
while (mc._x>=200) {
mc._x -= 190;
mc._y += 20;
}
mc.jumper();
}[/AS]

drolling

:stuck_out_tongue: thats really cool, but to me its complicated. lol

lost… i got a cool idea for you

see how that kind of looks like a flower?
Your next expiriment should involves spiffy flowers like that or something… yup

LoL 28, you’re a dork. :stuck_out_tongue:
I think LIB has already worked a lot with flowers, anyways. Have you seen his site?

That’s really cool Shane, but not as good as that random moving triangle thingy you did. (I think you did that. I hope you did, or I’m sounding pretty stupid right now…)

Ahah, I went to your site to make sure, Shane, and you DID make it! And it’s still awesome! And I was browsing around and it seems to me like you made some sort of ‘new-age flash/photoshop-pen-tool for people that suck’ with that bezier experiment.

I feel like I can actually use the pen tool! giddy Yay! keeps playing with the bezier thingy

Aislin, yeah ive seen his site, thats why i suggested it;)

I was thinking of having a garden this year. I would make lots of flowers. But then I remembered it would take effort.

LOL… that bezier curve experiment is OLD I need to update it big time. But you like that eh? Thats all AS as well… check here…

Syko: Wouldn’t you like to know how I did it hehehe

well of course I would but I was afraid I can’t understand **** about the full code so I just asked the thing I was the most curious about

Im just waiting for somone to come along and point out my mistakes that I was hoping no one would notice. I see a few, but I am feeling lazy right now, so screw it… it works, thats all that matters right now to me :P.

I see half a dozen mistakes and a few oddities that could be.

I’m also lying, because it looks awesome to me.

Yes, the bezier thing is cool. I can use the pen tool now! (In my mind…)

I don’t understand that code and I’m too lazy to even try to understand it! So I’m jut gonna wait until I’m not lazy again… :slight_smile:

Ok, I made a few very minor changes of some things that were bugging me, and also rearranged some code to make it look sloppier, oh, and added a few little comments in there so its easier to browse through when editing…

[AS]//prototype to draw the square objects
MovieClip.prototype.drawSquare = function(r, x, y) {
this.lineStyle(.25, 0x000000, 50);
this.beginFill(0xE6E6E6, 50);
this.moveTo(-r, -r);
this.lineTo(r, -r);
this.lineTo(r, r);
this.lineTo(-r, r);
this.lineTo(-r, -r);
this.endFill();
this._x = x;
this._y = y;
};
//prototype to draw the line for the slider
MovieClip.prototype.drawSliderLine = function() {
this.lineStyle(1, 0x000000, 50);
this.moveTo(0, 0);
this.lineTo(100, 0);
};
//prototype to draw circles
MovieClip.prototype.drawCircle = function(x, y, r, lineThickness, RGB, alpha, xpos, ypos) {
var c1 = r*(Math.SQRT2-1);
var c2 = rMath.SQRT2/2;
this.lineStyle(lineThickness, RGB[0], alpha[0]);
this.beginFill(RGB[1], alpha[1]);
this.moveTo(x+r, y);
this.curveTo(x+r, y+c1, x+c2, y+c2);
this.curveTo(x+c1, y+r, x, y+r);
this.curveTo(x-c1, y+r, x-c2, y+c2);
this.curveTo(x-r, y+c1, x-r, y);
this.curveTo(x-r, y-c1, x-c2, y-c2);
this.curveTo(x-c1, y-r, x, y-r);
this.curveTo(x+c1, y-r, x+c2, y-c2);
this.curveTo(x+r, y-c1, x+r, y);
this.endFill();
this._x = xpos;
this._y = ypos;
};
//prototype to create the slider bars
MovieClip.prototype.createSlider = function(x, y, startPos, effectVar) {
this.createEmptyMovieClip(“sliderLine”, 1).drawSliderLine();
this.createEmptyMovieClip(“slider”, 2).drawSquare(5, startPos, 0);
this.slider.onPress = function() {
this.startDrag(true, 0, 0, 100, 0);
this.onMouseMove = function() {
this._parent.sliderLabel.text = this._parent._parent[effectVar]=Math.round(this._x);
this._parent.sliderLabel.setTextFormat(myFormat);
};
};
this.slider.onRelease = this.slider.onReleaseOutside=stopDrag;
this.createTextField(“sliderLabel”, 3, 110, -8, 100, 16);
this.sliderLabel.text = startPos;
this.sliderLabel.selectable = false;
this.sliderLabel.setTextFormat(myFormat);
this._x = x;
this._y = y;
};
//prototype for motion
MovieClip.prototype.jumper = function() {
this.startX = this._x;
this.startY = this._y;
this._xscale = this._yscale=this._alpha=15;
this.onMouseMove = function() {
if (this._parent.hitBlock.hitTest(this._parent._xmouse, this._parent._ymouse, true)) {
this._x = this.startX;
this._y = this.startY;
this.dx = this._x-this._parent._xmouse;
this.dy = this._y-this._parent._ymouse;
this.hyp = Math.sqrt(this.dx
this.dx+this.dythis.dy);
if (this.hyp<affectArea) {
this.strength = Math.pow((affectArea-this.hyp)/affectArea, 3);
this._x += pushDist
this.strengththis.dx/this.hyp;
this._y += pushDist
this.strengththis.dy/this.hyp;
this._xscale = this._yscale=this._alpha=15+100
this.strength;
} else {
this._xscale = this._yscale=this._alpha=15;
}
} else {
this._x += (this.startX-this._x)/5;
this._y += (this.startY-this._y)/5;
this._xscale = this._yscale=this._alpha += (15-this._xscale)/5;
}
};
};
//textbox formatting
myFormat=new TextFormat(), myFormat.font=“Verdana”, myFormat.size=10;
//declare variables
var maxClips = 95, affectArea = 50, pushDist = 25;
//create all the clips
this.createEmptyMovieClip(“hitBlock”, -10).drawSquare(99, 100, 100);
this.createEmptyMovieClip(“slider1”, -100).createSlider(55, 220, affectArea, “affectArea”);
this.createEmptyMovieClip(“slider2”, -99).createSlider(55, 240, pushDist, “pushDist”);
this.createEmptyMovieClip(“circle”, -7).drawCircle(0, 0, 20, 5, [0x000000, 0xFFFFFF], [100, 0], 10, 10);
//create the slider labels
this.createTextField(“slider1Label”, -1000, 10, slider1._y-18, 500, 16);
slider1Label.text=“Affected Area”, slider1Label.selectable=false, slider1Label.setTextFormat(myFormat);
this.createTextField(“slider2Label”, -2000, 10, slider2._y-18, 500, 16);
slider2Label.text=“Push Distance”, slider2Label.selectable=false, slider2Label.setTextFormat(myFormat);
//make the original clip disappear
circle._visible = false;
//for loop for duplicating clips
for (var i = 0; i<maxClips; i++) {
mc = circle.duplicateMovieClip(“circle”+i, i);
mc.createEmptyMovieClip(“center”, 1).drawCircle(0, 0, 10, 0, [0x000000, 0x666666], [0, 100], 0, 0);
mc._x = (i*20)+20;
while (mc._x>=200) {
mc._x -= 190;
mc._y += 20;
}
mc.jumper();
}[/AS]

wow… page 2ed just overnight :stuck_out_tongue:

::bump::