Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash




Gravity And Inverse Kinematics - From A Book



Alright, so i got a book called Foundation Actionscript 3 Animation: Making Things Move, and i was reading the inverse kinematics section. i got all the code down, and i was playing with the code trying to add gravity to it. i tried attaching a ball to the last peice of tha chain/rope but that didn't work. for that to work it have to stay in a circular area with a set diameter.... anyway, this is the code (it's free to get off the author's website): Segment.as
ActionScript Code:
package{ import flash.display.Sprite; import flash.geom.Point; public class Segment extends Sprite {  private var color:uint;  private var segmentWidth:Number;  private var segmentHeight:Number;    public var vx:Number = 0;  public var vy:Number = 0;    public function Segment(segmentWidth:Number, segmentHeight:Number, color:uint = 0xffffff)  {   this.segmentWidth = segmentWidth;   this.segmentHeight = segmentHeight;   this.color = color;   init();  }    public function init():void  {   // draw the segment itself   graphics.lineStyle(0);   graphics.beginFill(color);   graphics.drawRoundRect(-segmentHeight / 2,            -segmentHeight / 2,           segmentWidth + segmentHeight,           segmentHeight,           segmentHeight,           segmentHeight);   graphics.endFill();      // draw the two "pins"   graphics.drawCircle(0, 0, 2);   graphics.drawCircle(segmentWidth, 0, 2);  }    public function getPin():Point  {   var angle:Number = rotation * Math.PI / 180;   var xPos:Number = x + Math.cos(angle) * segmentWidth;   var yPos:Number = y + Math.sin(angle) * segmentWidth;   return new Point(xPos, yPos);  } }}
MultiSegmentReach.as
ActionScript Code:
package { import flash.display.Sprite; import flash.display.StageAlign; import flash.display.StageScaleMode; import flash.events.Event; import flash.geom.Point; public class MultiSegmentReach extends Sprite {  private var segments:Array;  private var numSegments:uint = 6;    public function MultiSegmentReach()  {   init();  }    private function init():void  {   stage.align = StageAlign.TOP_LEFT;   stage.scaleMode = StageScaleMode.NO_SCALE;   segments = new Array();   for(var i:uint = 0; i < numSegments; i++)   {    var segment:Segment = new Segment(50, 10);    addChild(segment);    segments.push(segment);   }   segment.x = stage.stageWidth / 2;   segment.y = stage.stageHeight / 2;   addEventListener(Event.ENTER_FRAME, onEnterFrame);  }    private function onEnterFrame(event:Event):void  {   var target:Point = reach(segments[0], mouseX, mouseY);   for(var i:uint = 1; i < numSegments; i++)   {    var segment:Segment = segments[i];    target = reach(segment, target.x, target.y);   }   for(i = numSegments - 1; i > 0; i--)   {    var segmentA:Segment = segments[i];    var segmentB:Segment = segments[i - 1];    position(segmentB, segmentA);   }  }    private function reach(segment:Segment, xpos:Number, ypos:Number):Point  {   var dx:Number = xpos - segment.x;   var dy:Number = ypos - segment.y;   var angle:Number = Math.atan2(dy, dx);   segment.rotation = angle * 180 / Math.PI;      var w:Number = segment.getPin().x - segment.x;   var h:Number = segment.getPin().y - segment.y;   var tx:Number = xpos - w;   var ty:Number = ypos - h;   return new Point(tx, ty);  }    private function position(segmentA:Segment, segmentB:Segment):void  {   segmentA.x = segmentB.getPin().x;   segmentA.y = segmentB.getPin().y;  } }}
i'm just not sure what to do to add some gravity in this. ALSO, this will probably go into a game when the character can walk into this rope/chain, and it just moves and slides over them... i haven't exactly got around to that part yet, but i though i might share...



KirupaForum > Flash > ActionScript 3.0
Posted on: 07-27-2008, 05:52 PM


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread

[F8] Inverse Kinematics Help
I've got a nice little IK chain going on which basically hangs from the top of the flash file, drag any point and it follows and does what any good IK chain should do. The problem i have is that i need the top most parent to be in a fixed position (though still able to rotate an it's axis) but at the moment if you drag the other links about it moves too.

I've figured as much as i need to either stop the user from being able to drag down when they have clicked on the links, thus stopping the downward movement of the parent, or set it up that when you let go of whatever link you dragged the parent would slide back to its original position.

Here's the cose i have:


Code:
//set up
b0.offset = .2;
b1.offset = -0.2;
b2.offset = .2;
b3.offset = -0.2;

b0.vr = 0;
b1.vr = 0;
b2.vr = 0;
b3.vr = 0;

b0.move = move;
b1.move = move;
b2.move = move;
b3.move = move;

b0.rotateTo = rotateTo;
b1.rotateTo = rotateTo;
b2.rotateTo = rotateTo;
b3.rotateTo = rotateTo;

b0.setControlled = setControlled;
b1.setControlled = setControlled;
b2.setControlled = setControlled;
b3.setControlled = setControlled;

b0.child = [b1];
b0.parent = body;
b1.child = [b2];
b1.parent = b0;
b2.child = [b3];
b2.parent = b1;
b3.child = [b4];
b3.parent = b2;

b0.onPress = doDrag;
b0.onRelease = noDrag;
b0.onReleaseOutside = noDrag;
b1.onPress = doDrag;
//b1.onRollOver = doDrag;
b1.onRelease = noDrag;
b1.onReleaseOutside = noDrag;
b2.onPress = doDrag;
b2.onRelease = noDrag;
b2.onReleaseOutside = noDrag;
b3.onPress = doDrag;
b3.onRelease = noDrag;
b3.onReleaseOutside = noDrag;

//
//body.offset = -Math.PI;
body.offset = 0;
body.vr = -50;
body.move = move;
body.rotateTo = rotateTo;
body.setControlled = setControlled;
body.child = [b0];
body.parent = null;
body.onPress = doDrag;
body.onRelease = noDrag;
body.onReleaseOutside = noDrag;
//
onEnterFrame = function () {
body.move(body);
};
function move(source) {
if (this.drag) {
//this.rotateTo(_xmouse, _ymouse, this.dist);
this.rotateTo(_xmouse, _ymouse, this.dist);
trace(source);
var ry = this._y;
if (this._y < ry) {
trace("not down");
}
if (source != body) {
trace("not body");
this.parent.rotateTo(this._x, this._y, 106);
} else if (source == body) {
trace("body");
this.parent.moveTo(this._x, this._y, 106);
}
} else if (!this.controlled) {
var angle = this._rotation*Math.PI/180;
this.vr += Math.cos(angle-this.offset)*5;
this.vr *= .9;
this._rotation += this.vr;
}
var myAngle = this._rotation*Math.PI/180;
for (var i = 0; i<this.child.length; i++) {
this.child[i]._x = this._x+Math.cos(myAngle)*106;
this.child[i]._y = this._y+Math.sin(myAngle)*106;
this.child[i].move(this);
}
}
function rotateTo(x, y, dist) {
var dx = x-this._x;
var dy = y-this._y;
var angle = Math.atan2(dy, dx);
this._rotation = angle*180/Math.PI;
this._x = x-dist*Math.cos(angle);
this._y = y-dist*Math.sin(angle);
this.parent.rotateTo(this._x, this._y, 106);
}
function doDrag() {
var dx = _xmouse-this._x;
var dy = _ymouse-this._y;
this.dist = Math.sqrt(dx*dx+dy*dy);
this.drag = true;
this.setControlled(true);
}
function noDrag() {
this.drag = false;
this.setControlled(false);
}
function setControlled(c, source) {
this.controlled = c;
for (var i = 0; i<this.child.length; i++) {
if (source != this.child[i]) {
this.child[i].setControlled(c, this);
}
}
if (source != this.parent) {
this.parent.setControlled(c, this);
}
}
I've toyed with various bits of the code to try and adapt it but without luck, if anyone can help, or just point me in the direction of a fully working IK chain that covers my criteria, that'd be superb.

ta,
dave.

Inverse Kinematics
How would I go about "linking" 2 objects with IK?

I created this -

http://spamtheweb.com/ul/upload/220908/74057_rope.php

- but It only links to one object: the mouse. For starters, how can I link both ends to the mouse; to make a circle?

Looking For Inverse Kinematics Tutorials In Flash
2 days later and i'm still searching....

anyone know of any inverse kinematic tutorials for flash. all the files and samples i find in search engines lead to dead links. i only need one single chain; very similar to the human arm, two lines with one joint. (ha, ha, he said joint)

thanks.

Inverse Kinematics (IK) SDK Features Are Very Limited...?
Does anyone else find that the IK SDK is severely limited?
You have to create bones in the authoring environment and all you can do with code is read and manipulate an existing skeleton/armature.

Correct me if I'm wrong but it appears that all of these are true:

Must have an instance in the library and export it for actionscript

You can use the classes IKArmature, IKBone, IKEvent, IKJoint, IKManager, IKMover to manipulate the armature in a subset of the things the authoring tools do

IKEvent and IKMover allow fine-tuning of the limit methods (iteration, time, and distance)

Code can traverse the skeleton or jump to a bone by name, adjust movement variables and constraints real-time, and do IK movement and animating

No dynamic construction (no adding bones real-time, etc)

No included ragdoll or animation blending, but possible to develop

No copying or creating instances of skeletons, cannot even move the root via code <<<<< even though the mouse can when the armature is tracked and enable x and y translation is turned on(!)
(i.e. the SDK can obviously move it; why isn't there something to let us move it with code too )

Putting an armature in a movieclip makes it non-interactive (and if you try to bring it back out, it breaks- the bones disappear or become detached)

Seems like it is mostly for animators at this point, but we could use it for some things here and there (posing a doll, put the snake in the box mini-game, etc)

Inverse Kinematics-lock Posistion
Ok, I'm working an a project with Inverse Kinematics. I'm using the code from gotoAndPlay.it. I've done this before and I'm quite comfortable with the code of the tutorial. The IK works great except:

I am trying for the life of me to lock a point in the IK chain, but the rest still are able to be dragged away. Ok, imagine a chain, i can grab either end of it and drag it and the rest will follow and look all pretty and realistic. Now, what i want to do is bolt one end of that chain to a spot on the stage and i cannot drag it any further than that, it just has no slack and wont allow me to drag it anymore. Make sense?

If anybody has dealt with this issue before, let me know.

Inverse Kinematics Tutorials / Flas?
Hi

I've been hunting for info on inverse kinematics for a game I'd like to make.

Does anyone know of any articles / flas / tutes / anything that is a good starting point for this type of thing? I started reading some in depth articles but my brain began to shrivel by the 2nd paragraph.. :'(
Would be awesome to have a bit of a working version to start from.


Here are some examples of the type of thing I'd like to do:
http://www.ashesclashes.com.au/

The only good article + source I've found so far is this:
http://www.gotoandplay.it/_articles/...Kinematics.php

Anybody got anything else on this? Please!!

Thanks,
Nick

[CS4] Incorporating The Inverse Kinematics (Bones Feature) In AS3
im just messing around with bones and i got about 10 circles next to each other and lined up up in a straight line (left to right) with the bones feature. Now what i wanna do is basicly try and achive this effect: http://theflashblog.com/?p=347

the site says it hanst used any codes but what i did was to write a basic start and stop drag in the document class but i found that the IK did not work. anyone can tell me how its done?

Inverse Kinematics (IK) SDK Limitations Features ... Very Limited?
Does anyone else find that the IK SDK is severely limited?
You have to create bones in the authoring environment and all you can do with code is read and manipulate an existing skeleton/armature.

Correct me if I'm wrong but it appears that all of these are true:

Must have an instance in the library and export it for actionscript

You can use the classes IKArmature, IKBone, IKEvent, IKJoint, IKManager, IKMover to manipulate the armature in a subset of the things the authoring tools do

IKEvent and IKMover allow fine-tuning of the limit methods (iteration, time, and distance)

Code can traverse the skeleton or jump to a bone by name, adjust movement variables and constraints real-time, and do IK movement and animating

No dynamic construction (no adding bones real-time, etc)

No included ragdoll or animation blending, but possible to develop

No copying or creating instances of skeletons, cannot even move the root via code <<<<< even though the mouse can when the armature is tracked and enable x and y translation is turned on(!)
(i.e. the SDK can obviously move it; why isn't there something to let us move it with code too )

Putting an armature in a movieclip makes it non-interactive (and if you try to bring it back out, it breaks- the bones disappear or become detached)

Seems like it is mostly for animators at this point, but we could use it for some things here and there (posing a doll, put the snake in the box mini-game, etc)

Are all of these true?

AS3 - Inverse Kinematics (IK) SDK Features ... Severely Limited?
Does anyone else find that the IK SDK is severely limited?
You have to create bones in the authoring environment and all you can do with code is read and manipulate an existing skeleton/armature.

Correct me if I'm wrong but it appears that all of these are true:

Must have an instance in the library and export it for actionscript

You can use the classes IKArmature, IKBone, IKEvent, IKJoint, IKManager, IKMover to manipulate the armature in a subset of the things the authoring tools do

IKEvent and IKMover allow fine-tuning of the limit methods (iteration, time, and distance)

Code can traverse the skeleton or jump to a bone by name, adjust movement variables and constraints real-time, and do IK movement and animating

No dynamic construction (no adding bones real-time, etc)

No included ragdoll or animation blending, but possible to develop

No copying or creating instances of skeletons, cannot even move the root via code <<<<< even though the mouse can when the armature is tracked and enable x and y translation is turned on(!)
(i.e. the SDK can obviously move it; why isn't there something to let us move it with code too )

Putting an armature in a movieclip makes it non-interactive (and if you try to bring it back out, it breaks- the bones disappear or become detached)

Seems like it is mostly for animators at this point, but we could use it for some things here and there (posing a doll, put the snake in the box mini-game, etc)

Are all of these true?

Library Recommendations, Inverse Kinematics, And Pixel Bender
A few questions:


1) I'm looking for any recommendations on libraries to accomplish the following:
Popup/draggable windows, Audio libraries, and Input libraries
Do you have any suggestions?


2) Does anyone else find that the CS4 AS3 IK SDK is severely limited?
You have to create bones in the authoring environment and all you can do with code is read and manipulate an existing skeleton/armature.

Correct me if I'm wrong but it appears that all of these are true:

Must have an instance in the library and export it for actionscript

You can use the classes IKArmature, IKBone, IKEvent, IKJoint, IKManager, IKMover to manipulate the armature in a subset of the things the authoring tools do

IKEvent and IKMover allow fine-tuning of the limit methods (iteration, time, and distance)

Code can traverse the skeleton or jump to a bone by name, adjust movement variables and constraints real-time, and do IK movement and animating

No dynamic construction (no adding bones real-time, etc)

No included ragdoll or animation blending, but possible to develop

No copying or creating instances of skeletons, cannot even move the root via code <<<<< even though the mouse can when the armature is tracked and enable x and y translation is turned on(!)
(i.e. the SDK can obviously move it; why isn't there something to let us move it with code too )

Putting an armature in a movieclip makes it non-interactive (and if you try to bring it back out, it breaks- the bones disappear or become detached)

Seems like it is mostly for animators at this point, but we could use it for some things here and there (posing a doll, put the snake in the box mini-game, etc)

Have you tried this? Are all of these true?


3) And finally I've written a Pixel Bender shader and it works fine in the toolkit but when I view it in flash it gets white/background color in the area where I'm doing a wave effect; oddly it works better on an older computer but I can post the source code if anyone wants to take a look. If it just seems to be a common problem with flash player 10, then please let me know that, too.


Thank you!

How To Make A Balloon? Kinematics, Gravity And More
Hi All!

So! We're making this campaign ad for a client. It should have some Balloons i.e. one peice of helium balloon and a string attached to it. You should be able to drag the string and the balloon should follow it, if you release it it should head upwards. Well, you get it. It's a freaking balloon!

I've been able to create the ballon and attached a string to it using som forward kinematics stuff, my problem though is to apply the gravity to the string itself and how the make the string behave correctly when dragging it...

here's my code sofar


Code:
package {
import flash.display.*;
import flash.events.*;
import flash.geom.Point;

public class setTail extends MovieClip {

private var tWidth:Number;
private var tHeight:Number;
private var ta:Number;
private var segments:Array = new Array();

private var headTarget:MovieClip;

private var vx:Number = 0;
private var vy:Number = 0;
/*
private var friction:Number;
private var spring:Number;
private var gravity:Number;
*/

public function setTail(t:MovieClip) {
//headTarget is the Ballon, it has all the gravity and movement stuff, the Tail just follows it.
headTarget = t;

/*
friction = headTarget._friction;
spring = headTarget._spring;
gravity = headTarget._gravity
*/
tWidth = headTarget.tailWidth;
tHeight = headTarget.tailHeight;

ta = headTarget.tailNum;

//generate the Tails
setupTails();

}
private function setupTails():void {
//make the ballon the first object in the tail array
segments.push(headTarget);

//add segments
for (var i:Number = 0; i < ta; i++) {
var c:Segment = new Segment(tWidth, tHeight, 0xc19f4f);
addChild(c);
segments.push(c);
}

addEventListener(Event.ENTER_FRAME, onEnterFrame);

}

private function onEnterFrame(event:Event):void
{
//set i to 1 so that we'll skip the balloon mc.
for (var i:uint = 1; i < segments.length; i++) {
//get the tailsegments
var segmentA:MovieClip = segments[i];
var segmentB:MovieClip = segments[i - 1];
//make som movement!
drag(segmentA, segmentB.x, segmentB.y);
}
}

private function drag(segment:MovieClip, xpos:Number, ypos:Number):void {

var dx:Number = xpos - segment.x;
var dy:Number = ypos - segment.y;
var angle:Number = Math.atan2(dy, dx);
segment.rotation = angle * 180 / Math.PI;

/*
There should be somekind of gravity applied here but I can't figure it out...
I tried adding:
segment.vy += gravity;
but that just drags the tile apart....
*/


//getPin returns a Point
var w:Number = segment.getPin().x - segment.x;
var h:Number = segment.getPin().y - segment.y;
segment.x = xpos - w;
segment.y = (ypos += segment.vy) - h;

}


}

}

How To Make A Balloon? Kinematics, Gravity And More
Hi All!

So! We're making this campaign ad for a client. It should have some Balloons i.e. one peice of helium balloon and a string attached to it. You should be able to drag the string and the balloon should follow it, if you release it it should head upwards. Well, you get it. It's a freaking balloon!

I've been able to create the ballon and attached a string to it using som forward kinematics stuff, my problem though is to apply the gravity to the string itself and how the make the string behave correctly when dragging it...

here's my code sofar


Code:
package {
import flash.display.*;
import flash.events.*;
import flash.geom.Point;

public class setTail extends MovieClip {

private var tWidth:Number;
private var tHeight:Number;
private var ta:Number;
private var segments:Array = new Array();

private var headTarget:MovieClip;

private var vx:Number = 0;
private var vy:Number = 0;
/*
private var friction:Number;
private var spring:Number;
private var gravity:Number;
*/

public function setTail(t:MovieClip) {
//headTarget is the Ballon, it has all the gravity and movement stuff, the Tail just follows it.
headTarget = t;

/*
friction = headTarget._friction;
spring = headTarget._spring;
gravity = headTarget._gravity
*/
tWidth = headTarget.tailWidth;
tHeight = headTarget.tailHeight;

ta = headTarget.tailNum;

//generate the Tails
setupTails();

}
private function setupTails():void {
//make the ballon the first object in the tail array
segments.push(headTarget);

//add segments
for (var i:Number = 0; i < ta; i++) {
var c:Segment = new Segment(tWidth, tHeight, 0xc19f4f);
addChild(c);
segments.push(c);
}

addEventListener(Event.ENTER_FRAME, onEnterFrame);

}

private function onEnterFrame(event:Event):void
{
//set i to 1 so that we'll skip the balloon mc.
for (var i:uint = 1; i < segments.length; i++) {
//get the tailsegments
var segmentA:MovieClip = segments[i];
var segmentB:MovieClip = segments[i - 1];
//make som movement!
drag(segmentA, segmentB.x, segmentB.y);
}
}

private function drag(segment:MovieClip, xpos:Number, ypos:Number):void {

var dx:Number = xpos - segment.x;
var dy:Number = ypos - segment.y;
var angle:Number = Math.atan2(dy, dx);
segment.rotation = angle * 180 / Math.PI;

/*
There should be somekind of gravity applied here but I can't figure it out...
I tried adding:
segment.vy += gravity;
but that just drags the tile apart....
*/


//getPin returns a Point
var w:Number = segment.getPin().x - segment.x;
var h:Number = segment.getPin().y - segment.y;
segment.x = xpos - w;
segment.y = (ypos += segment.vy) - h;

}


}

}

AS3 - How To Make A Balloon? Kinematics, Gravity And More
Hi All!

So! We're making this campaign ad for a client. It should have some Balloons i.e. one peice of helium balloon and a string attached to it. You should be able to drag the string and the balloon should follow it, if you release it it should head upwards. Well, you get it. It's a freaking balloon!

I've been able to create the ballon and attached a string to it using som forward kinematics stuff, my problem though is to apply the gravity to the string itself and how the make the string behave correctly when dragging it...

here's my code sofar


Code:
package {
import flash.display.*;
import flash.events.*;
import flash.geom.Point;

public class setTail extends MovieClip {

private var tWidth:Number;
private var tHeight:Number;
private var ta:Number;
private var segments:Array = new Array();

private var headTarget:MovieClip;

private var vx:Number = 0;
private var vy:Number = 0;
/*
private var friction:Number;
private var spring:Number;
private var gravity:Number;
*/

public function setTail(t:MovieClip) {
//headTarget is the Ballon, it has all the gravity and movement stuff, the Tail just follows it.
headTarget = t;

/*
friction = headTarget._friction;
spring = headTarget._spring;
gravity = headTarget._gravity
*/
tWidth = headTarget.tailWidth;
tHeight = headTarget.tailHeight;

ta = headTarget.tailNum;

//generate the Tails
setupTails();

}
private function setupTails():void {
//make the ballon the first object in the tail array
segments.push(headTarget);

//add segments
for (var i:Number = 0; i < ta; i++) {
var c:Segment = new Segment(tWidth, tHeight, 0xc19f4f);
addChild(c);
segments.push(c);
}

addEventListener(Event.ENTER_FRAME, onEnterFrame);

}

private function onEnterFrame(event:Event):void
{
//set i to 1 so that we'll skip the balloon mc.
for (var i:uint = 1; i < segments.length; i++) {
//get the tailsegments
var segmentA:MovieClip = segments[i];
var segmentB:MovieClip = segments[i - 1];
//make som movement!
drag(segmentA, segmentB.x, segmentB.y);
}
}

private function drag(segment:MovieClip, xpos:Number, ypos:Number):void {

var dx:Number = xpos - segment.x;
var dy:Number = ypos - segment.y;
var angle:Number = Math.atan2(dy, dx);
segment.rotation = angle * 180 / Math.PI;

/*
There should be somekind of gravity applied here but I can't figure it out...
I tried adding:
segment.vy += gravity;
but that just drags the tile apart....
*/


//getPin returns a Point
var w:Number = segment.getPin().x - segment.x;
var h:Number = segment.getPin().y - segment.y;
segment.x = xpos - w;
segment.y = (ypos += segment.vy) - h;

}


}

}

Tan Inverse
How do i find the tan^-1 of a number

If You Think You Can Handle It Inverse Sin()
hi,

I am trying to do the equation sin(theta)=o/h;

but i need to do an inverse sin

sin-1() how do i do this in flash?

any help would be great--
jimi mudgett

Inverse Sine
anyone know if there is an inverse sine function? i have two squares with a line in between them and i have to rotate it so that it correlates with the position of the squares.

anyone have any ideas? thanks, patrick.

Inverse Cosine
I'm trying to compute a set of angles using the inverse cosine. I can't seem to figure out if this is built in to MX or not. I know that there's a bunch of new Math functions, but I can't find the inverse cosine.

If it doesn't exist, does anyone know of a way to compute the inverse cosine using the existing Math functions?

Thanks.

Inverse Text ?
I'm hoping there's an easy way to do this: I have a text box that displays a string of numbers read from the URL that sits on an image. However, now I want to show the reverse of the image, and as such, the text would need to be displayed in inversely (flipped horizontally).

Is there a way to set the properties of a text box to write inversly? Any help is appreciated, thanks!

Inverse Rotation
Hi

I'm just trying to figure out how to make an MC rotate the other way...

My script so far:


PHP Code:




var total = _root.getBytesTotal();
var loaded = _root.getBytesLoaded();
var perc = loaded/total*100;
percent = Math.round(perc);
setProperty("rotator", _rotation, _root.rotator._rotation+perc);
setProperty("rotator2", _rotation, _root.rotator2._rotation+perc);
_root.mcperc.GotoandStop(percent);
if (loaded == total) {
    gotoAndPlay("Main", 1);
}







I want to get the "rotator2" to rotate in the opposite direction to the "rotator"

I've tried putting a string infront of the expression as:


PHP Code:




setProperty("rotator2", _rotation, "-"&_root.rotator2._rotation+perc);







But that didn't work

Any ideas?

-W3bbo

BeginFill() Inverse?
Hello,

I have a series of coordinates defined by an XML file. These coordinates form a rectangular shape with a "hole" in the middle.



I am able to fill this defined shape using lineTo() and beginFill().

What I would really like to be able to do is fill the INVERSE (inside) or "hole" instead of the rectangular/outside portion, so I may use this as a mask.

Is there any way to do this?

One idea I had would be to draw a normal rectangle first, then draw my plotted shape and fill it, then delete the plotted shape, leaving just the "hole" are with a color fill. Sadly, I do not know how to do this, as clear() deletes everything.

Does anyone have any ideas?

Inverse Loader
Hi there, I'm a newbie probably bugging with this question but at Web Design's class we did a really simple loader. A movie clip of a bar, a keyframe for this action
_root.stop;
porcentaje=_root.getBytesLoaded()/_root.getBytesTotal()*100;
if(porcentaje!=100){
_xscale=barrita/5
setProperty(barrita,_xscale,porcentaje);

}else{
gotoAndStop("cargado");
}


now the loader works perfectly, but the thing is that the professor asked us on how to make the bar disappear instead of appearing.
I know it has to be something with the _xscale, but I just can't get my finger on it. So, somebdoy has an idea on how to make an inverse loader?
Oh yeah I can't use masks or any of the sort, just plaina ction script.
Thank you so much for your attention.

How Can I Inverse A Mask?
Hello,

I've got a problem with masks. I want to be able to have a movieclip, and then with a marquee type tool I want to be able to select a portion of that moviclip and drag it away.

Essentially what I've started doing is the user drags along the movieclip, using lineTo's to create another movieclip. I then mask original movieclip with the marqueee movieclip.

The problem is that now all I have is the piece that I selected. I want the part of the moviclip to showbut have the marquee selection removed from it.

Am I making sense?

Can I do this?

Inverse Mask
How can i do to make the mask work exactly the inverse of how it works now in Flash?
Like now in the mask layer i have some object moving with actionscript, i want this objects hide, not show.
How can i do?

Lol Howdo You Do Inverse Tan?
ahhhhh lol im trying to work out the angle of a right angled triangle........

Code:
var a = 60; //opposite
var b = 30; //adjacent
var temp = 60/30;
var abc = Math.tan(temp);
LOL............. i need the inverse tan!!!!!!!!!!!!

Inverse Tangent?
I'm trying to get an angle out of the X and the Y values of the mouse. If there is an inverse tangent, it would be someingthing like invtan(x,y).

Inverse Proportion
alright here's my situation, i am creating 10 Circle movie clips dynamically and giving each of them a width and height random from 1 to 50, I am creating these CELLS to react to eachother in an environment that I create, well anyway everything is going good but this, SPEED

i would like the smallest cells to have a speed of .05 and from then on the larger the cell the smaller the speed, Every ... property i guess you could say... of the cell is proportional to it's width. thanks so much in advance!
-Michael

Inverse Colors
I have a main movie where after i load a movie. The problem is that i would invert the color of the movie that i load. How can i do ? Thanks!

Math.cos Inverse?
Does a Math.cos inverse method exist? If not, anyone know the code to make that method? Thanks

icekube12jr

Inverse Tangent?
I'm trying to get an angle out of the X and the Y values of the mouse. If there is an inverse tangent, it would be someingthing like invtan(x,y).

Inverse Proportion
alright here's my situation, i am creating 10 Circle movie clips dynamically and giving each of them a width and height random from 1 to 50, I am creating these CELLS to react to eachother in an environment that I create, well anyway everything is going good but this, SPEED

i would like the smallest cells to have a speed of .05 and from then on the larger the cell the smaller the speed, Every ... property i guess you could say... of the cell is proportional to it's width. thanks so much in advance!
-Michael

Inverse Tangent
Is it possible to get the inverse tangent in Flash?

I know, that Math.tan(0.785) will result in 1, but what if I want to get the inverse tangent to 1?

How do I write that?

Greetings

rasmus

[AS Of:] Inverse Tangent?
to find tangent of 30° i do
Math.tan(30/57.3);

what about inverse tan of suppose 0.5 ?

what is the AS for finding inverse tan?

Inverse Tangent
guys i'm not getting any answer at [AS of:] inverse tangent? and its actionscript+math related.. please check/help?

Inverse Sine Function
I'm not exactally a newb to flash, but I feel like one right now. I am trying to make a gravity program and in order to calculate angles, I'm trying to do something that requires the inverse sine of something, and I can't find that function in the Math class. Is it just the Math.asin... I'm not sure. Any help would be great.

[F8] Kind Of Inverse Inheritance ?
Hi all,

I am working on a small game.

I made a class Game with the overall methods.
I made two classes GameType1 and GameType2 (extends Game) with more specific methods to define two different versions of this game.
Then I made several classes Level1 and Level2 (extends GameType1) as well as Level3 (extends GameType2).

In the class Level1 I define a few levelspecific functions and things like the used grid, f.i.
private var grid:Object = {xnr:20, ynr:20};

Now what I want to do is use these values in methods defined in class Game, f.i. in method
code: class Game
{
private function initGame()
{
makeMyGame(grid.xnr, grid.ynr);
}
{
}

Anybody got a suggestion how to use these data from class Level1 in class Game?

Set The Inverse Color For A Textfield
I am working with Flash Player 6. I am dynamically setting my background color and dynamically creating my textfield. Sometimes the background color is set to black, the same color as my textfield, or some other relatively dark color. I know that I can change the color of my TextField with the textformat but I am wondering if anybody knows of a slick way of setting the the color to the inverse of another color?

How Do You Get The Inverse Tangent In Flash...?
Trying to get the inverse tangent so i can calculate the closest point around a circle to a collision object for accurate collision detection of a circle. Does anyone know how to accomplish this or what the equation is for the inverse tangent. Thanks..

How Can I Calculate (sin Inverse) In Flash?
How can I calculate (sin inverse) in flash?

Inverse Mask Script AS3 > AS2
I have a project that has been built in AS2 but I need to create an Inverse Mask.
I can do it in AS3 with:

clipToMask.cacheAsBitmap = true
clipToMask.mask = inverseMask(mask_mc)

function inverseMask(mc:MovieClip) {
var _BMP:BitmapData = new BitmapData(stage.stageWidth,stage.stageHeight,true,0xFFFFFFFF)
var invert:ColorTransform = new ColorTransform(0,0,0,1)
var matrix:Matrix = new Matrix()
matrix.translate(mc.x,mc.y)
_BMP.draw(mc, matrix,invert)
_BMP.threshold(_BMP,new Rectangle(0,0,_BMP.width,_BMP.height),new Point(0,0),"<",0xFFFFFFFF,0x00FF0000)

var BMP:Bitmap = new Bitmap(_BMP)
var maskMC:MovieClip = new MovieClip()
maskMC.addChild(BMP)
maskMC.cacheAsBitmap = true
this.addChild(maskMC)
mc.visible = false
return maskMC
}


BUT.....
I need to convert this to AS2. The project is almost built, so rewriting the whole job in AS3 isn't an option any longer.
Can anyone help?
So far I have (see below) but it doesn't work.


import flash.display.BitmapData;
import flash.filters.BitmapFilter;
import flash.filters.ColorMatrixFilter;
import flash.geom.ColorTransform;
import flash.geom.Matrix;


clipToMask.cacheAsBitmap = true
clipToMask.setMask(inverseMask(mask_mc));

function inverseMask(mc:MovieClip) {
trace("mask: " + mc);

var _BMP:BitmapData = new BitmapData(stage.stageWidth,stage.stageHeight,true,0xFFFFFFFF)
var invert:ColorTransform = new ColorTransform(0,0,0,1)
var matrix:Matrix = new Matrix()
matrix.translate(mc.x,mc.y)
_BMP.draw(mc, matrix,invert)
_BMP.threshold(_BMP,new Rectangle(0,0,_BMP.width,_BMP.height),new Point(0,0),"<",0xFFFFFFFF,0x00FF0000)



var BMP:BitmapData = _BMP.clone();
var maskMC:MovieClip = this.createEmptyMovieClip("mc", this.getNextHighestDepth());
maskMC.attachBitmap(clonedBitmap, this.getNextHighestDepth());
maskMC.cacheAsBitmap = true;
mc._visible = false
return maskMC;
}

What Is The Math Calculation To Inverse A Numer
i.e.
-200 becomes 200

-342 becomes 342

-999 becomes 999

i've been trying to work it out with a calculator but i just cant :P

Put Alpha On Mc But Obtain Inverse Result
i would like to put this script on my mc so i would like the inverse result. 0 to 100 alpha not 100 to 0... thanks


onClipEvent (enterFrame){
if(this._alpha > 0){
this._alpha-=5;
{
{

thanks

Inverse Mouse-activated Motion
I've been trying to figure out the following 3 issues regarding mouse-activated motion:

1. How to make an object go in the opposite direction of the mouse.

2. How to make this movement have an ease in and out.

3. How to make the movement of this object be bounded to a certain limit.

So far all I've gotten is a simple mouse follow motion with the following srcipt I developed:

onClipEvent (enterFrame) {
if (_root._xmouse <= 264) {
this._x = 264;
} else if (_root._xmouse >= 264) {
this._x = _root._xmouse;
if (_root._xmouse >= 387) {
this._x = 387;
} else if (_root._xmouse <= 387) {
this._x = _root._xmouse;
}
}
}
onClipEvent (enterFrame) {
if (_root._ymouse <= 164) {
this._y = 164;
} else if (_root._ymouse >= 164) {
this._y = _root._ymouse;
if (_root._ymouse >= 235) {
this._y = 235;
} else if (_root._ymouse <= 235) {
this._y = _root._ymouse;
}
}
}

Can anybody out there help me figure this one out or add or enhace the code?

I'm adding a copy of my file so that you can have an idea of what I'm trying to do.

thanks

iam2001

Inverse Scroll Bar - Formula + Help Needed
arrrgh, i knew i should've buffed up on my maths when i had the chance to...

i need a formula that makes the content of a bar scroll within the bar inversely according to the size of the bar... so when ur mouse is on the extreme left, the mouse will be on the 1st item, and if ur mouse is on the extreme right, the mouse will be on the last item...

attached is a rough idea... plz help!! thanks!!!

Getting The Inverse (increasing) Distance Between Converging MC's
Hi everyone...I'm not sure if anyone here remembers a game called "Star Control"...but I thought it'd be a fun exercise to try to put something similar together in Flash.

Unfortunately, I've hit my first roadbloack. If you've never played the original game - here's a quick overview:
-It's one-on-one spaceship 'combat'
-It's a top-down "Asteroids" sort of view, but the playfield scrolls a bit as the players move around. Both the player's ships and any debris appear on the bottom if they scroll off the top, and appear on the left if they scroll off the right side(like the old Mario bros.-before he was Super)
-As the two ships get closer, the 'camera' zooms in. As the two ships get farther apart, the camera pulls back to reveal the whole playfield

Of course, there's a lot more to it than that. But as far as the play dynamics, it's the "Zooming In" that's giving me the problem. I had the idea that I could somehow tie the scale of everything in play to the distance between the ships somehow. I set some variables, used the Pythagorean theorem for the distance between the ships, and put it into an onClipEvent that loops endlessly at runtime:

dist = Math.sqrt((deltaX * deltaX) + (deltaY * deltaY));

And it worked! Variable "dist" decreases as they get closer, and increases as they get further apart.

Problem is, if I try to tie "dist" into the scale properties of each clip involved, they get smaller as they get closer together (because dist is decreasing) instead of getting larger and zooming in.

Is there a way to calculate the inverse of the Pythagorean theorem, so that the final value increases as they get closer?

I've attached a FLA file to show you what I mean.

When you first test the movie, move toward the other ship (which is kind of on 'auto-pilot'for testing, always heading towards the top). Everything gets smaller. Move away, and everything gets bigger. I haven't set min or max levels yet so it gets pretty large/small.

If you delete "'Zoomer' movie clip" you'll see what the base playfield is like without the zoom.

Oh yeah - the arrow keys move the little ship around.

Command A Movie Clip From A Timeline (and Inverse)
help!

I made a menu that contain 5 frames. each frame is representing a scene of my main flash. When the user enters a scene, I want to tell my MovieClip to jump to the frame of that scene (to give a visual feedback of where the user is). So I wrote this code at the begining of each scene:

menu_top.gotoAndStop(n);

(where menu_top is the instance name of the menu and "n" is the frame number, or the scene.

This works in the first scene but in the other scenes it always goes to the first frame of the movie clip... Why?

Also, the menu must act as... a menu. So in my 5 buttons I made a code so that the main flash goes to the correct scene. This is the code I used:

on (release) {
_root.gotoAndPlay("1", 1);
}

Where "1" is the scene (1 to 5 in the case of my movie) and 1 is the frame.

This doesn't work. I send me to the second scene of the movie, which is named "login"! (first I thought that it was sending me to the first frame of the movie clip, but it doesn't.)

It doesn't seem to be a bug in the reference as the good timeline is changed, but it doesnt do the good thing!

I cannot understand the bugs, as it seems that I do everything by the book! Can anyone show me the obvious thing I seem to be missing?

Passing An Array As Arguments - The Inverse Of ...rest
I'm thinking about ways to add undo history to a web app I'm working on. Some undo methods need many arguments, some only need one.

I know that myFunction(... args) will give me an array, args, containing each item passed. I want to do the opposite - what's the proper syntax to dynamically call this:


Code:
myFunction(myArray[0], myArray[1]);
for any myArray with the same number of elements as myFunction has arguments?


For simplicity's sake, I'd like to use the same functions I already use to do for undo/redo without modification. That is, I want to avoid taking this:


Code:
function myFunction(arg1:uint, arg2:uint)
and modifying it like this:


Code:
function myFunction(arg1:*, arg2:uint = null){
if (arg1 is Array){
arg2 = arg1[1];
arg1 = arg1[0];

Trace Bitmap Makes The Colors Go Inverse
When I try to trace a B&W bitmap, it makes the colors go "negative". So, the black turns white and the white turns black. What gives?

[Code Snippet] Inverse Eased Scrolling
Ok, for some reason I had more trouble figuring this out... So after finally doing so, I figured if anyone else has trouble, here's something already made:

Just set a speed variable in the root timeline and drop this AS on your MovieClip

ActionScript Code:
onClipEvent (enterFrame)
{
 
    ratio    = _root._xmouse/Stage.width;
    endX     = (Stage.width * ratio - this._width * ratio);
    distance = endX - this._x;
    this._x += distance / _root.speed;
 
}

I haven't tested it with clips that are narrower than the stage width... Might not work with those.

Hope this helps someone.

Math Help Inverse Coordinates On Zoomed Image
I can't seem to wrap my mind around the simple algebra needed to accomplish my task (it is a Monday morning ...)

In one .swf (say 240 x 140) sits an image thumbnail, (say 210 px by 108 px, padded left and top: x:15, y:15).

When you roll over the thumbnail, in another, larger .swf on the same page (say 600 x 340) a larger, full-sized (1280 x 657 at x:0, y:0) view of the image appears, cropped of course by the .swf dimensions.

You move your mouse over the thumbnail, towards the right, and the large, full-sized image moves to the left. You move your mouse down, and the full-sized image moves up.

When you reach the far right of the thumbnail (x:210 + 15) you should be seeing the far right of the large image whose coordinates should be (x:-680). When you reach the bottom of the thumbnail (y:108 + 15) you should be viewing the bottom of the large image (y:-317).

What I have works in part, in that the image moves the correct direction ... but it moves WAY too much, which indicates that my proportions, or percentage is wrong, though I'm not sure how or where.

In the thumb swf:

ActionScript Code:
// when you roll over the thumbnail ...
sending_lc.send("popViewer_zoom", "imageData", thumb_width);
    //
    _root.onMouseMove = function(){
sending_lc.send("popViewer_zoom", "moveImage", magnifier._x-sidePadding, magnifier._y-topPadding);
    }


In the large swf:

ActionScript Code:
receiving_lc.imageData = function(thumb_width:Number) {
percentDif = (thumb_width/currentImage._width)*100;
};
//
receiving_lc.moveImage = function(X:Number, Y:Number) {
    currentImage._x = -(X*percentDif);
    currentImage._y = -(Y*percentDif);
};

Copyright © 2005-08 www.BigResource.com, All rights reserved