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




[CS3] Find Highest Point And Farthest Point Of A Parabola



Hi Guys, I've been using for forum extensively over the past few weeks and have found almost everything I needed until now...

I'm moving a ball using something similar to the following code:


Code:
var spx:Number = 3;
var spy:Number = 7;
var g:Number = 0.1;
var bmove:Boolean = true;

onEnterFrame = function() {
if (bmove) {
move_ball();
}
stop_ball();
}

function stop_ball() {
if (ball._y > 350) {
bmove = false;
}
}

function move_ball() {
spy = spy-g;
ball._x += spx;
ball._y -= spy-g;
}
Is there a way to find the maximum height and farthest point of the parabola it describes? I want to display a path guide using curveTo which shows the route of the ball.

Thanks.



FlashKit > Flash Help > Flash ActionScript
Posted on: 10-16-2008, 08:12 AM


View Complete Forum Thread with Replies

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

Find Highest Point And Farthest Point Of A Parabola
Hi Guys, I've been using for forum extensively over the past few weeks and have found almost everything I needed until now...

I'm moving a ball using something similar to the following code:


Code:
var spx:Number = 3;
var spy:Number = 7;
var g:Number = 0.1;
var bmove:Boolean = true;

onEnterFrame = function() {
if (bmove) {
move_ball();
}
stop_ball();
}

function stop_ball() {
if (ball._y > 350) {
bmove = false;
}
}

function move_ball() {
spy = spy-g;
ball._x += spx;
ball._y -= spy-g;
}
Is there a way to find the maximum height and farthest point of the parabola it describes? I want to display a path guide using curveTo which shows the route of the ball.

Thanks.

Is It Possible To Find The Color At A Point?
Is there any way to test what color appears at a given (x, y) location in a movie clip?

For instance, I create an empty movie clip, then do some lineTo() and similar vector drawing commands. Then I want to test what color appears at the point (_xmouse, _ymouse). I know I could do this by keeping track of all the drawing commands, and doing lots of calculations. But I'm wondering if there's an easier way.

Any suggestions?

How To Find Out The Intersect Point?
Hi Everybody..!

This is my first querry in actionscript.org.

I have an angled straight line. And I have an object(ball), which is moving towards the line. What I want to know is..At what coordinate the ball will intersect the line?

Which formula I need to use? Can anybody help me doing this?

Thanks in advance..

How To Find Out Colour At A Specific Point?
is it possible to find out colour hexcode at a given point in flash mx?

Find Point On Dynamic Curve?
Im generating a line dynamically to simulate a wobbling stack of books.



The image shows the line which the book stack will follow. however im struggling to find a simple method of snapping my books to the line.

Any suggestions?

Math - How To Use 3 X,Y Cords To Find Any Given Point On A Arc?
Hi there...

I have 3 known points on screen. I am trying to find code that will allow me to find any given point of teh arc that moves though these three points.

See Pics
example01 - http://www5.picturepush.com/photo/a/...mg/1296823.png
example02 - http://www1.picturepush.com/photo/a/...mg/1296819.png

What we know
We know the X,Y cords of A,B and H.
We know the ANGLE of D.

What we want
Is the X,Y cords of any given point on the arc that connect A,B and H them.


My thoughts... If I can find the Center Point of the circle, I can than use that to work out the arc....

Can you guys help me out?

How Do You Find An Object's Center Point?
Hi,

I'm trying to find an object's center point. I've been using .x and .y (eg. object.x) to find the registration point. From there I've been calculating the center point by adding half the objects width to object.x and half the objects height to object.y. The code below is an example of what I've done.

Or is there a way to set an object's registration point to the center of the object?

Is there a method or property that will give me an object's center point automatically without me having to calculate it?







Attach Code

center.x = object.x + (object.width / 2);

center.y = object.y + (object.height / 2);

Find Point Between Two And Do It Again And Again. Making Grid
HI there, i'm triying to make a dinamic generated plane, that plane has a grid with lines in X and Y, by now i'm able to generate a grid clicking and dragging points to make 4 lines and i generated 2 lines between the midles of the opposites lines like this:


here is the app so far:

http://www.theguaz.com/grilla_lines.swf

U have to click and drag to make a line, try making a surface in the table.

now i have this also:

http://www.theguaz.com/sodimac/draw_lines_v2.swf

that one makes the subdivision, but now i need to make that same thing in the previous swf so when u subdivides one side that same subdivision occurs in the other 3. By now i have used the Point.interpolate funtion to find the middle point between the 2 points i mark:

Code:
var puntoIni:Array = new Array(0,0);
var puntoFin:Array = new Array(0,0);
var cardinales:Array = new Array(0,0);
contador = 0;
contaMarcas = 0;
var iniciado:Boolean = false;
var poderDibujar:Boolean = false;
var drawP = true;
//
//
var ref = this;
import flash.geom.Point;
//
#include "lmc_tween.as"
//
MovieClip.prototype.soyMarca = function():Void {
this._alpha = 50;
this.useHandCursor = false;
this.onRollOver = function():Void {
this.alphaTo(100, 1);

};
this.onRollOut = this.onReleaseOutside=function ():Void {
this.alphaTo(50, 1);

};
};
//

//
functionDrawLines = function (init:Array):Void {
if (contador<4) {
ref.onEnterFrame = function():Void {
puntoFin[0] = ref._xmouse;
puntoFin[1] = ref._ymouse;
//
//
ref["line_mc"+contador].removeMovieClip();
ref.createEmptyMovieClip("line_mc"+contador, ref.getNextHighestDepth());
ref["line_mc"+contador].lineStyle(2, 0xFFFFFF, 65);
ref["line_mc"+contador].moveTo(init[0], init[1]);
ref["line_mc"+contador].lineTo(puntoFin[0], puntoFin[1]);
//
};
ref.attachMovie("marcame_mc", "marcame_mc"+contaMarcas, ref.getNextHighestDepth(), {_x:init[0], _y:init[1]});
ref["marcame_mc"+contaMarcas].soyMarca();
contaMarcas++;
contador++;

}
};
calculaMitad = function (coords_one:Array, coords_two:Array):Point {
var point_1:Point = new Point(coords_one[0], coords_one[1]);
var point_2:Point = new Point(coords_two[0], coords_two[1]);
var interpolatedPoint:Point = Point.interpolate(point_1, point_2, .5);
return (interpolatedPoint);
};
creaNuevoPunto = function (punto:Point):Void {
var puntoNew:Point = punto;
cardinales[contador-1] = punto;
};
//
///
var mouseListener:Object = new Object();
//
mouseListener.onMouseDown = function() {
puntoIni[0] = ref._xmouse;
puntoIni[1] = ref._ymouse;
//
functionDrawLines(puntoIni);
};
//
dibujaParalelas = function ():Void {
if (drawP == true) {
ref.createEmptyMovieClip("linePara_mc"+0, ref.getNextHighestDepth());
ref["linePara_mc"+0].lineStyle(0.5, 0xFFFFFF, 35);
ref["linePara_mc"+0].moveTo(cardinales[0].x, cardinales[0].y);
ref["linePara_mc"+0].lineTo(cardinales[2].x, cardinales[2].y);
//
ref.createEmptyMovieClip("linePara_mc"+1, ref.getNextHighestDepth());
ref["linePara_mc"+1].lineStyle(0.5, 0xFFFFFF, 35);
ref["linePara_mc"+1].moveTo(cardinales[1].x, cardinales[1].y);
ref["linePara_mc"+1].lineTo(cardinales[3].x, cardinales[3].y);
}
};
//
mouseListener.onMouseUp = function() {
if (contaMarcas<8) {
delete ref.onEnterFrame;
//
//
ref.attachMovie("marca_mc", "marca_mc"+contador, ref.getNextHighestDepth(), {_x:calculaMitad(puntoIni, puntoFin).x, _y:calculaMitad(puntoIni, puntoFin).y});
ref.attachMovie("marcame_mc", "marcame_mc"+contaMarcas, ref.getNextHighestDepth(), {_x:puntoFin[0], _y:puntoFin[1]});
ref["marcame_mc"+contaMarcas].soyMarca();
creaNuevoPunto(calculaMitad(puntoIni, puntoFin));
contaMarcas++;
}
if (contaMarcas == 8) {

dibujaParalelas();
ref._parent.redraw_mc._visible = true;
ref._parent.redraw_mc.alphaTo(50, 1);
drawP = false;
removeListener(mouseListener)

}
trace(contaMarcas)


};
Mouse.addListener(mouseListener);
//

//
stop();

How in hell i can make a function that takes two points and makes equal intervals in every line i create ???

Thanks a lot to everyone who read this.

theguaz

Can't Find A Point And Click Game Tutorial
Hey i'm really interested in making a room escape game but i can't find a tutorial anywhere. I have very basic flash experience but i think if i could find a good tutorial i could manage pretty well.

Can anybody point me in the direction of a tutorial like this?

Find Corner Of Mc Regardless Of Registration Point Position
Hello again,
Does anyone know of a way to find the top left corner (for example) of an mc regardless of where it's registration point is?

What I mean is how do I determine where the registration point is for an MC?

This is kinda what I am trying to accomplish: A user mouses over something and no matter what size it is, or where it's registration point is a box will appear right at the top left corner. Not including curves - there are no curves.

Thanks for the help.
webg

Find A Point On A Dynamic Curved Line
Im generating a line dynamically to simulate a wobbling stack of books.



The image shows the line which the book stack will follow. however im struggling to find a simple method of snapping my books to the line.

Any suggestions?

Creating A Point-line With Increasing & Decreasing Point Size
hi,
i want to creating a point-line with increasing & decreasing point size, that the final result looks like a wave form.
i guess i have to do that with sine and cosine values...?
i would be very happy for any help or hint.

Rotation, Find Out Degrees Of A Point, Soooo Simple
I want to find out the angle of a point, which is always on the outline of a circle. I wrote a little function for that, dividing the circle into 4 divisions and using tangens. Anyway, the script seems to be correct, but the results are wrong. Can anybody help me, please????


Code:
/*
mx = _x position of the center of the circle (M)
my = _y position of the center of the circle (M)
px = _x position of the point
py = _y position of the point
*/
Math.circA = function(mx, my, px, py){
var a = 270;
if (px>mx && py > my) {
a = Math.atan(Math.abs(px-mx)/Math.abs(my-py));
} else {if (px<mx && py>my) {
a = 180 - Math.atan(Math.abs(mx-px)/Math.abs(my-py));
} else {if (px<mx && py<my) {
a = 180 + Math.atan(Math.abs(mx-px)/Math.abs(py-my));
} else {
a = 360 - Math.atan(Math.abs(px-mx)/Math.abs(py-my));
}}}
trace("circA() " + arguments.toString() + " = " + a);
return a;
}


/* 1. set dot to a position on the circle, i.e. 225 degrees
M is on _x:160 and _y:160, radius is 100
*/
this.dot._x = 160 + 100 * Math.cos(225 * (Math.PI / 180));
this.dot._y = 160 + 100 * Math.sin(225 * (Math.PI / 180));

// 2. Get the angle of the dot on the circle (usually between 0 and 360)
trace(Math.circA(160, 160, this.dot._x, this.dot._y));

Find Point On Rect Edge Based On Angle
I did not find anything that helped me with this anywhere on the net, and I racked my brain for what seemed like...
Well... just too long to figure it out. I'm not a math guru so I had revisted my old homework assignments to finally get it.
But I thought I would post it here to help anyone who might want it.
The example is done with a square, but it could easily be modified for a rectagle since I had to use quadrants anyway. The hardest thing was working with the degrees, because of flash's geometry system is so wonkey when it comes to degrees. But anywho...

Check out the example here (you may drag the squares):
http://www.jimisaacs.com/test/geomTest3/

The fla for it is here:
http://www.jimisaacs.com/test/geomTest3/geomTest3.zip

toodles

Draw A Line From Any Point A To Any Point B Dynamically Through Actionscript
I am trying to make a file where there are several locations made on a map. If a person clicks on one location A and then another location B, there is a plane that flies from A to B and there are 2 text fields that get populated with the names of A and B destinations. This animation is scripted. I wanted to animate a dotted line from point A (from destination of the plane) to point B(to destination of the plane) through action script too so that there is a dotted line following the plane animation.

Thanks

Aneesha

Moving Object From Point A To Point B - Mathematical Problem
Hi,
I have mathematical problem.

I want to move object from point A to point B but not just X or Y aixis. For example point A(0,0) and point B(500,500).

Please if somebody can send me generic equation to put in ON_ENTER_FRAME event so on each frame object is a little bit closer to point B.
Thanks,

How Do I Dynamically Find The New Farthest Left X Post OnResize?
I am trying to have something always stick to the left side of the stage, when it is resized.

i have a flash file set to 100% width and height in a browser...

Any ideas?

Thanks!

Drawing Line Dynamically From Point To Point
Here is what I am looking to do, I will try and be specific:

I would like to create an MC:
when loaded, draws a line dynamically from the first x/y point released on the stage to the next x/y point released, then from there to the next x/y point released, and so on. Creating a path from point to point, wherever you release. Tracing the path of the user (based on onRelease points).

This could be a closed set, where, for example, I would have 10 MC's on the stage that are all potential points for the line. The catch is that I want the user to define the order, selecting the MC's in any order and having a line drawn that traces the users selections.

Or it could allow the user to release anywhere within the parent MC.

I am moderately familiar with drawing a line dynamically, but don't know how to write what I am looking for.

Any help??


Thanks so much.

How To I Move From Point To Point And Leave A Trail
What i'm doing is have a word appear and then a line come from it and move to a point, while the line is moving what i want it to leave a trail behind it as if someone was drawing the line from 1 point to another, I hope i have explained it ok,

If anyone knows how to do this can you let me know.

thank's

Using Flash Actionscript To Do Point To Point Linkage
hiya..
do anyone has any idea how to using flash actionscript to do a point to point linkage?

Move An Object From One Point To Another Point On Graph
Basically what I like to ask is how to move a object from one point to another point based on the point tat you have clicked on a graph. For example, If I click on this coordinate (2,3) on graph, the object (movie clip) will move to that point.

Registration Point Vs. Transformation Point
I'm extremely frustrated with the behavior of Flash MX 2004's registration/transformation points. I just learned that the distinction between the two just happened with the release of Flash MX 2004. I'd like to know how in the world I'm supposed to transform a symbol relative to its corner or side, seeing how the transformation point insists on being in the center of the symbol every time.

Let's say I have a 200x200 square shape. If I want the transformation point to be in the lower left corner, it looks like I have to:

1. Put the registration point in the center when I create the symbol
2. Double click on the symbol
3. Move the shape 100 px to the right
4. Move the shape -100 px up
5. Exit out of symbol editing mode

which is five times more complicated a process than if they had kept the behavior like it was. Or at the very least, change the Symbol Creation dialog box to this:



Or am I missing something?

Move An Object From One Point To Another Point
Basically what I like to ask is how to move a object from one point to another point based on the point tat you have clicked on a graph. For example, If I click on this coordinate (2,3) on graph, the object (movie clip) will move to that point.

Laser From Point X Go To To Point Z. Sort Of
ok i need help! here is what i have so far, this code that i show u is on the laser movie clip (it has been duplicated allready and this is just the code that is on it:

Code:
onClipEvent (load) {
this._x = _root.mech._x;
this._y = _root.mech._y;
laserMoveSpeed = 10;
this.targetAngle = Math.atan2(aim._y-mech._y, aim._x-mech._x);
this._rotation = this.targetAngle/(Math.PI/180);
}
onClipEvent (enterFrame) {
//here is code that will move laser in direction of where
//the mc instance named: aim was when clicked
this._x += Math.cos(this.targetAngle)*this.laserMoveSpeed;
this._y += Math.sin(this.targetAngle)*this.laserMoveSpeed;
}

mech is the instance name for the point the laser shot will start at, aim is the mouse mc whhere you click and then it duplicates the mc, and then this code should get run , the only thing that works is when u click, one of the laser mc shows up, so u can keep clicking and u will get tons of lasers on the screen, but they dont move and just stay at the point where the mech was when shot. how come this code isnt making the laser move in the right direction, so why dont it move?
EDIT: on the onload part i just added a trace(targetAngle); it displays the output of NaN. what does that mean>?

Add Point And Deduce Point In Flash
Hello everyone,

I am a beginner in Flash and currently I am doing my final year project on a website development. I plan to create a happening website by providing members to actually collect points while they perform some activities like membership sign up will earn them 500 points, submit photo will earn them 100 points and so on.

They can collect point under they membership account and use the point to redeem some stuff. As they redeem their point in their account will automatically deduced accordingly. So the problem here is I am unable to figure out what actionscript is this called- able to add points and deduce point according to the activities the member do in the website. I would be really grateful if you guys can help. Really really need help. I have no idea where to start off. Thank you in advance.

cheers

From Point To Point With Smooth Rotation
I want to max the stage size to 2880x2880 then make a huge symbol with buttons that say move to point x... y... and have this much rotation...

My problem is if I move from point to point how would i get a smooth move not just a jump? With the rotation gradually happening?

Point-Point Character Rotation
Alright, so I am working on a point-point character slope rotation system, and for all the different point locations I try, the rotation seems to be off just by abit everytime...

Quick note: "chara" is a box on the stage, also you can probably just copy/paste after putting an mc called chara on the stage


ActionScript Code:
var p1:Point = new Point(10, 10);
var p2:Point = new Point(150, 130);

//var char:Point = new Point(18, 11); //pretty much un-needed

var p1p2rot = Math.atan2(p2.y-p1.y, p2.x-p1.x);
var p1p2rot2 = Math.round((p1p2rot*180/Math.PI))+90;

trace(p1p2rot2);
trace(p1p2rot2-90);

var charrot = 180-(p1p2rot2-90);

trace(charrot);

chara.rotation -= charrot;


what the heck?

Rotating A Point Around Another Point Using X,y,z Axes
I have a point (a camera) that i want the player to be able to rotate around another point(a 3D mesh) which is centered on 0,0,0. And i want the camera to always point at the object.

implementing rotation around the Y axis is easy. I do it like this..


ActionScript Code:
var camRotation=0;
var camDistance=50;
function enterFrameHandler(e) {
    if (leftIsDown) {
        camRotation-=.1;
    }
    if (rightIsDown) {
        camRotation+=.1;
    }
    camera.x=Math.sin(camRotation)*camDistance;
    camera.y=Math.cos(camRotation)*camDistance;
    camera.rotationY=camRotation*180/Math.PI;
}
and it works the way i want it to.
Now I want to be able to also press up and down to be able to change the camera from side-view to top-view, but thats where im stuck.. i dont know how to add a third dimension to the rotation..

Would anyone help me with this?

Point A, To Point B... In A Straight Line?
Hello everyone, l'm working on a script that is similar to the old "missile command" game from the 80's, and l just got started.

In any event, the user Clicks on the screen which executes the
"fireMissile(_root._xmouse,_root._ymouse);" function. As you can see, this function duplicates my missile MC, and starts it off with the X/Y coordinates of: 273,312. From that point, l want the MC to move in a *straight line*, from it's starting point, to the point where the mouse *was* when the fireMissle() function was called.

I've ripped some code from one of my actionscript books, but l can't seem to fine tune the scripting correctly, and l'm getting all types of haywire effects that l'm not looking for. IE missiles going every which direction, but where I clicked the mouse.

here's the portion of the code where l'm running into problems... what's wrong here?

Code:
xdiff = x-startX;
ydiff = y-statY;
angle = Math.atan2(ydiff, xdiff);
angle = angle*180/Math.PI;
_root["missile"+missleCount]._x = startX;
_root["missile"+missleCount]._y = startY;
_root["missile"+missleCount].finalX = missleSpeed*Math.cos(angle);
_root["missile"+missleCount].finalY = missleSpeed*Math.sin(angle);
And the entire script (less some of the extra garbage that's been thrown in):


Code:

mouse.hide();
missleCount = 0;
startX = 273;
startY = 312;
missleSpeed = 5;
shotsOnScreen = 0;
maxShotsOnScreen = 100;

function fireMissle(x, y) {

duplicateMovieClip("missile", "missile"+missleCount, missleCount);
xdiff = x-startX;
ydiff = y-statY;
angle = Math.atan2(ydiff, xdiff);
angle = angle*180/Math.PI;
_root["missile"+missleCount]._x = startX;
_root["missile"+missleCount]._y = startY;
_root["missile"+missleCount].finalX = missleSpeed*Math.cos(angle);
_root["missile"+missleCount].finalY = missleSpeed*Math.sin(angle);
missleCount++;
shoutsOnScreen++;

}
and the code on the actual missleMC

Code:
onClipEvent (enterFrame) {
if ((finalX) && (finalY)) {
this._x += this.finalX;
this._y += this.finalY;
}
}

How Do I Tween To Point B Without Knowing Where Point A Will Be
I have a slide show that resizes depending on what photo is showing, and the users can pick any tab that they want to. How do i shape tween the slide show without knowing what the urrent size is?

Do I need scripting? (AS3)

Point-to-Point Line-of-Site
Point-to-Point Line-of-Sight* Oops
Man that sounds so cool.

edit:
Since this original post I have learnt of the world of Raycasting. You can see my attempts of it in this post:
http://www.kirupa.com/forum/showthre...88#post1746388

Here's the script. I have used Flash 8's BitmapData and Rectangle classes, but the theory could easily be applied to another tile-based world without any of these, these classes were simply used to display everything.

Use the Arrow keys to move the character, and the character aims to the mouse position.

http://icio.co.uk/random/files/flash/sight.swf


ActionScript Code:
import flash.display.BitmapData;import flash.geom.Rectangle;Stage.scaleMode = "noScale";Mouse.hide();//*********************************************************// Variablesvar tileSize:Number = 10;var map:Array = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1], [1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 1], [1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]; // This is an awesomely-long line, y0. (762 characters before comment)var baseBitmap:BitmapData = new BitmapData(map[0].length*tileSize, map.length*tileSize, false, 0xEEEEEE);   _root.attachBitmap(baseBitmap, _root.getNextHighestDepth());   // var objBitmap:BitmapData = new BitmapData(baseBitmap.width, baseBitmap.height, true, 0x00000000);         _root.attachBitmap(objBitmap, _root.getNextHighestDepth());        //  |- The bitmaps used in the gamevar hitBitmap:BitmapData = new BitmapData(baseBitmap.width, baseBitmap.height, true, 0x0000FF00);         _root.attachBitmap(hitBitmap, _root.getNextHighestDepth());        // /var tileRectangle:Rectangle = new Rectangle(0, 0, tileSize, tileSize); // A Rectangle object for drawing tiles onto the base bitmap.var objects:Array = [];                      // An array of all the objectsvar player:Object = {y:10*tileSize, x:1*tileSize, color:0xFFFF3399, xspd:0, yspd:0}; objects.push(player);  // The player objectfor (y=0; y<map.length; y++) { for (x=0; x<map[0].length; x++) { if (map[y][x] == 1) {  // Cycle through the numbers in the map and process, then    tileRectangle.x = x*tileSize; tileRectangle.y = y*tileSize;       // Reposition the tile rectangle    baseBitmap.fillRect(tileRectangle, 0x999999);                              // Draw it onto the base bitmap} } }// Draw the objects onto the object bitmapfunction drawObjects() { objBitmap.fillRect(objBitmap.rectangle, 0x00000000); for (i in objects) { objBitmap.fillRect(new Rectangle(objects[i].x, objects[i].y, tileSize, tileSize), objects[i].color); } objBitmap.fillRect(new Rectangle(_xmouse-1, _ymouse-1, 3, 3), 0xFFFF0000); }    //****************************************************************************************// THE IMPORTANT FUNCTION - THIS IS WHAT IT'S ALL ABOUT !! *******************************//****************************************************************************************function lineOfSite(x1:Number, y1:Number, x2:Number, y2:Number) {    var dist:Number = Math.sqrt(Math.pow(x2-x1, 2)+Math.pow(y2-y1, 2));  // The distance from the start point to end point    var angle:Number = Math.atan((y2-y1)/(x2-x1));              // The angle from start point to end point (in radians)        angle += x2-x1<0 ? Math.PI : 0;           // angle correction        angle += x2-x1>=0 && y2-y1<0 ? 2*Math.PI : 0;                     // angle correction        hitBitmap.fillRect(hitBitmap.rectangle, 0x0000FF00);                // (Eye-Candy)    var pos:Number = 0;              // Where we're going to start from on the line    while (pos < dist) {                                                    // Loop until we've tested further than, or to the same distance as, the total distance        pos = pos+1<=dist ? pos+1 : dist;                           // Move onto the test position. (Increasing/Decreasing '1' increases/decreases accuracy)        var x:Number = Math.floor(pos*Math.cos(angle)+x1);            // Calculate the new x-coordinate for testing        var y:Number = Math.floor(pos*Math.sin(angle)+y1);            // Calculate the new y-coordinate for testing        if (map[Math.floor(y/tileSize)][Math.floor(x/tileSize)] == 1) {  // Check to see if the current point's relative tile is '1' or '0'            break;                              // Exit the loop if the tile is a '1'. Upon exitting, `x` and `y` maintain the coordinates        }            hitBitmap.setPixel32(x, y, 0xFF666666);       // (Eye-Candy)    }        hitBitmap.fillRect(new Rectangle((pos==dist?x2: x)-1, (pos==dist?y2:y)-1, 3, 3), pos==dist?0xFF0000FF:0xFF000000);    // (Eye-Candy)    return pos==dist;                                          // Will return true if the target was reachable and false otherwise.}//****************************************************************************************//*********************************************************// Player Movement - Can't be assed commenting all of this.function movePlayer() {    player.xspd += Key.isDown(Key.RIGHT)?1: (Key.isDown(Key.LEFT)?-1:0); player.xspd = Math.abs(player.xspd)>tileSize?tileSize*player.xspd/Math.abs(player.xspd):player.xspd;    player.yspd += Key.isDown(Key.DOWN)?1: (Key.isDown(Key.UP)?-1:0); player.yspd = Math.abs(player.yspd)>tileSize?tileSize*player.yspd/Math.abs(player.yspd):player.yspd;    if (!Key.isDown(Key.RIGHT) && !Key.isDown(Key.LEFT)) { player.xspd *= Math.abs(player.xspd)<0.1?0:0.8; }    if (!Key.isDown(Key.UP) && !Key.isDown(Key.DOWN)) { player.yspd *= Math.abs(player.yspd)<0.1?0:0.8; }    var xL:Number = Math.floor(player.x / tileSize); var xR:Number = Math.floor((player.x+tileSize-1) / tileSize);    var yT:Number = Math.floor(player.y / tileSize); var yB:Number = Math.floor((player.y+tileSize-1) / tileSize);    var maxL:Number = xL*tileSize; var maxR:Number = xR*tileSize;    var maxU:Number = yT*tileSize; var maxD:Number = yB*tileSize;    var cL:Boolean = !(map[yT][xL-1]==1 || map[yB][xL-1]==1);    var cR:Boolean = !(map[yT][xR+1]==1 || map[yB][xR+1]==1);    var cU:Boolean = !(map[yT-1][xL]==1 || map[yT-1][xR]==1);    var cD:Boolean = !(map[yB+1][xL]==1 || map[yB+1][xR]==1);    var xmove:Number = player.xspd; var ymove:Number = player.yspd;    if (!cL && player.x+player.xspd < maxL) { xmove = maxL - player.x; player.xspd = 0; }    if (!cR && player.x+player.xspd > maxR) { xmove = maxR - player.x; player.xspd = 0; }    if (!cU && player.y+player.yspd < maxU) { ymove = maxU - player.y; player.yspd = 0; }    if (!cD && player.y+player.yspd > maxD) { ymove = maxD - player.y; player.yspd = 0; }    player.x += xmove; player.y += ymove;}// Call Everything_root.onEnterFrame = function() { movePlayer(); drawObjects(); lineOfSite(player.x+tileSize/2, player.y+tileSize/2, _xmouse, _ymouse); }


Dam, smilies make it difficult to post code

Update:
Problems upload .swf at the moment, so here's the .fla:

MC From Point A To Point C Curving Via Point B
Hi,

I need to move a clip from point A to Point C, but I want it to curve out gradually then two thirds of the way up I want it to come back in more sharply, but slowing down all the way.

I can get the user to define the C point, which would work out the speed of the clip, and i want the user to define the extent of the curve. any ideas?

I know there are a few bezier curves going around, how can they be translated into a math loop on a clip to move.

cheers
tim

Find X-intercepts & Slide Parabola?
I'm using the parabola script from here . I've adjusted it so that the vertex is affected by the vertex slider (a), and adjusts itself when you slide the x-intercept sliders.

Here's the new problem...any idea what the math would be to:
a) identify the two x-intercepts so they display in their respective text box
b) and this is the big one, what equation will keep one x-intercept stationary while the other one slides back & forth?

Code:
this.createEmptyMovieClip("mygraph2", 100);
mygraph2.onEnterFrame = function() {
clear();
var drawScale = 0;
_global.var_a = (this._parent._parent.sliderPara_a.slide._x/5)+(this._parent._parent.sliderPara_p.slide._x/2)+(this._parent._parent.sliderPara_q.slide._x/2);
//_global.var_p = this._parent._parent.sliderPara_p.slide._x*10;
_global.var_p = 0;
//_global.var_q = this._parent._parent.sliderPara_q.slide._x*10;
_global.var_q = 0;
_global.var_x1 = 0;
_global.var_x2 = 0;
//each slider sets a variable, depending on which one you are dragging...I think this
// will be the way to adjust this._parent._x based on which slider you're dragging, but
// the math here is completely wrong...
if (_global.x1) {
this._parent._x = this._parent._parent.sliderPara_p.slide._x;
} else if (_global.x2){
this._parent._x = this._parent._parent.sliderPara_q.slide._x;
}
//trace(this._parent._parent.sliderPara_q.slide._x);
//trace(this._parent._x);
this._parent._parent.display_a = _global.var_a;
//solve for x1
this._parent._parent.display_p = -.6;
//solve for x2
this._parent._parent.display_q = .6;
if (this._parent._parent.display_p>0) {
temp_p = "- "+this._parent._parent.display_p;
} else if (this._parent._parent.display_p<0) {
temp_p = "+ "+(this._parent._parent.display_p*-1);
} else if (this._parent._parent.display_p == 0) {
temp_p = "- 0";
}
if (this._parent._parent.display_q>0) {
temp_q = "- "+this._parent._parent.display_q;
} else if (this._parent._parent.display_q<0) {
temp_q = "+ "+(this._parent._parent.display_q*-1);
} else if (this._parent._parent.display_q == 0) {
temp_q = "- 0";
}
this._parent._parent.display_function = "y= "+this._parent._parent.display_a+"(x "+temp_p+")(x "+temp_q+")";
lineStyle(1, 0x006600, 100);
for (i=0; i<=250; i++) {
_global.newX = i;
_global.newY = ((((Math.pow(_global.newX, 2)*_global.var_a)+(_global.newX*_global.var_p))/50)+_global.var_q)+_global.var_a*-20;
//_global.newY = _global.var_a(_global.newX-_global.var_p)(_global.newX-_global.var_q);
if (_global.newY>250) {
_global.newY = 251;
}
if (_global.newY<-250) {
_global.newY = -251;
}
if (i == 0) {
moveTo(_global.newX, _global.newY);
} else {
lineTo(_global.newX, _global.newY);
}
}
for (i=0; i>=-250; i--) {
_global.newX = i;
_global.newY = ((((Math.pow(_global.newX, 2)*_global.var_a)+(_global.newX*_global.var_p))/50)+_global.var_q)+_global.var_a*-20;
//_global.newY = _global.var_a(_global.newX-_global.var_p)(_global.newX-_global.var_q);
if (_global.newY>250) {
_global.newY = 251;
}
if (_global.newY<-250) {
_global.newY = -251;
}
if (i == 0) {
moveTo(_global.newX, _global.newY);
} else {
lineTo(_global.newX, _global.newY);
}
}
};
Any ideas or suggestions would be much appreciated! Here's the fla so far...

Thanks!!!

Find X-intercepts & Slide Parabola?
Okay, I've given up on my previous attempt here and am trying a different tact.

I'm using the original parabola script from the parabola movie here . I've adjusted it so that the vertex is affected by the vertex slider (a), and adjusts itself when you slide the x-intercept sliders.

Here's the new problem...any idea what the math would be to:
a) identify the two x-intercepts so they display in their respective text box
b) and this is the big one, what equation will keep one x-intercept stationary while the other one slides back & forth?

Code:
this.createEmptyMovieClip("mygraph2", 100);
mygraph2.onEnterFrame = function() {
clear();
var drawScale = 0;
_global.var_a = (this._parent._parent.sliderPara_a.slide._x/5)+(this._parent._parent.sliderPara_p.slide._x/2)+(this._parent._parent.sliderPara_q.slide._x/2);
//_global.var_p = this._parent._parent.sliderPara_p.slide._x*10;
_global.var_p = 0;
//_global.var_q = this._parent._parent.sliderPara_q.slide._x*10;
_global.var_q = 0;
_global.var_x1 = 0;
_global.var_x2 = 0;
//each slider sets a variable, depending on which one you are dragging...I think this
// will be the way to adjust this._parent._x based on which slider you're dragging, but
// the math here is completely wrong...
if (_global.x1) {
this._parent._x = this._parent._parent.sliderPara_p.slide._x;
} else if (_global.x2){
this._parent._x = this._parent._parent.sliderPara_q.slide._x;
}
//trace(this._parent._parent.sliderPara_q.slide._x);
//trace(this._parent._x);
this._parent._parent.display_a = _global.var_a;
//solve for x1
this._parent._parent.display_p = -.6;
//solve for x2
this._parent._parent.display_q = .6;
if (this._parent._parent.display_p>0) {
temp_p = "- "+this._parent._parent.display_p;
} else if (this._parent._parent.display_p<0) {
temp_p = "+ "+(this._parent._parent.display_p*-1);
} else if (this._parent._parent.display_p == 0) {
temp_p = "- 0";
}
if (this._parent._parent.display_q>0) {
temp_q = "- "+this._parent._parent.display_q;
} else if (this._parent._parent.display_q<0) {
temp_q = "+ "+(this._parent._parent.display_q*-1);
} else if (this._parent._parent.display_q == 0) {
temp_q = "- 0";
}
this._parent._parent.display_function = "y= "+this._parent._parent.display_a+"(x "+temp_p+")(x "+temp_q+")";
lineStyle(1, 0x006600, 100);
for (i=0; i<=250; i++) {
_global.newX = i;
_global.newY = ((((Math.pow(_global.newX, 2)*_global.var_a)+(_global.newX*_global.var_p))/50)+_global.var_q)+_global.var_a*-20;
//_global.newY = _global.var_a(_global.newX-_global.var_p)(_global.newX-_global.var_q);
if (_global.newY>250) {
_global.newY = 251;
}
if (_global.newY<-250) {
_global.newY = -251;
}
if (i == 0) {
moveTo(_global.newX, _global.newY);
} else {
lineTo(_global.newX, _global.newY);
}
}
for (i=0; i>=-250; i--) {
_global.newX = i;
_global.newY = ((((Math.pow(_global.newX, 2)*_global.var_a)+(_global.newX*_global.var_p))/50)+_global.var_q)+_global.var_a*-20;
//_global.newY = _global.var_a(_global.newX-_global.var_p)(_global.newX-_global.var_q);
if (_global.newY>250) {
_global.newY = 251;
}
if (_global.newY<-250) {
_global.newY = -251;
}
if (i == 0) {
moveTo(_global.newX, _global.newY);
} else {
lineTo(_global.newX, _global.newY);
}
}
};
Any ideas or suggestions would be much appreciated! Here's the fla so far...

Thanks!!!

Mouse Point At Target/follow Point "challenge"
hiya.

I ve got a self made cursor to use on my flash site. Ihave mad it follow the mouse and Ive used code to hide the mouse. so at the momment it looks like a custom cursor. great!

What I want to happed is to have this new cursor (arrow) always point at a certain point on the screen (say for now the center) so say the cursor was on the left of the screen it would point right (to the center.)

Im guess this would be fairly simple but I just cant get my hea round it.

Any helpers???


I would have thought it would be simillar to the script which has and object fix in a postion but always point to the mouse location.

Uploading: From Point A To Point B?
This isn't so much a question geared towards Flash as it is pertains to Dreamweaver, but they're both made by the same company so I figure this is the best forum for my question. So here's my question:
I got a site made in Flash. I have server space purchased somewhere out there. I'm going to use Dreamweaver as my compiler. In the dreamweaver help section it says your page must be labeled "index.html" to be uploaded correctly. Does this mean that my published flash file (.swf) should be renamed "xyz/index", or should I just change the published html's filename to "xyz/index.html"?? Where does this "index.html" come into play?
Help! I'm not sure how to get from Point A to Point B!

Point A To Point B Lines
I'm looking for some help to be able to draw lines on a flash movie by clicking two points (Point A to Point B). I've seen many posts with help with drawing but nothing exactly like what I need.

Any push in the right direction will be appreciated.

Ease To Point B Via Point C
Hi guys ... does anyone know a formula that allows you to ease to a given position via another set position? .. for example i might have an mc with its xscale set at 47 ... i want to be able to ease its xscale to 100 via 234.

I have tried using an ease in and ease out tween together, but can't get the smooth motion that i want, i would like to be able to do this with just one tween.

thanks in advance

Bongo

Is There A Way To Find The Next Highest Level?
The subject basically says the question. I had a controller movie that loads a right side or a left side, and when u click on a button from one of the sides, it loads another movie. Is there a dynamic way to define the next available level? or do i have to keep track manually? thanks.

---
also out of curiousity, can you delete a level? other than loading a blank.swf?

How To Find The Highest Number?
Hi,

Does anyone know a command to find the higher number from a list of numbers?

Thanks,
Rik

Find Highest Value In An Array
Can anyone tell me if there is a way to find the highest number in an array?

numbersArr(314,2613,221,103,77);

is there a way to loop though this, compare all the numbers to each other and find the highest value while keeping the array in order?

Thank you

[F8] Arrays: Find The Highest Score AND Tell Me Whose It Was?
I have an array with 5 numbers in it. I need to find the highest number, I can do that part. But I also need to be able to tell whose value that belongs to. Can anyone give me a nudge?

For example:


Code:
FavoriteMeat = Ham, Turkey, Chicken, Bologna, Squirrel
15 25 30 35 115


So I can figure out that the highest number is 115, but I can't figure out how, using a regular array, to show that it's squirrel that equals 115. Especially since array value is [4].

I can't use an associative array.

Please, please, please help!

Play "in Point" To "out Point" Of Mp3 (audio Editor)
I am trying to create an audio editor/player. I want to be able to load a mp3 sound (which i can do) but then play it from lets say a set "in point" to the set "out point" and only that part.

The way i have these set is i have a 15 second slider that you can slide across the waveform. I am able to get the in point and out point via actionscript but what i need to do is lets say i'm at "in point" number 56 which would be 56 seconds into the song and the out point is set to "71" i want it so that when i scrub to that position in the waveform to play just that selection when i hit play.

So basically i am trying to get it to play a selection of the audio piece rather then the whole thing.

What i'm trying to pretty much kind of do is exactly what the itunes ringtone creator does in the new version of itunes. Any code or actual fla example would be greatly appreciated.

Reset Transformation Point/Set Transformation Point
When I right-click a symbol the options "set transformation point" and "reset transformation point" come up. They don't seem to do anything for me. I thought it would center them or something. This is not the case. I have the white transformation point in one corner in one keyframe and a different corner in another keyframe I click "reset transformation point" on both frames and they don't move.

How do these options work?

How To Zoom From One Scale/point To Another Scale/point
I'm trying to get this effect where an image is zoomed at a specific scale and point, then it zooms out to another scale and point on a button click.

Check out this site and click on the menu buttons and you'll see what I mean: http://www.so-reckless.com

I figure you can use a motion tween but I'm looking for the script for better effect.

Thanks.

How To Zoom From One Scale/point To Another Scale/point
I'm trying to get this effect where an image is zoomed at a specific scale and point, then it zooms out to another scale and point on a button click.

Check out this site and click on the menu buttons and you'll see what I mean: http://www.so-reckless.com

I figure you can use a motion tween but I'm looking for the script for better effect.

Thanks.

Point Me
Could someone please point me in the direction of an article which will show me how to do the following:

I wish to have a vertical line, and a horizontal line in my movie, which cross wherever the mouse is, so as one moves the mouse in the movie, the horizontal and vertical lines too.

Many thanks

We Come To The Point
Is it possible to code just once? 'cause the boutons are already on a movieclip (that looks like a control), with your solution I'll have to create as many boutons as they are scenes.
To be really precise I'm doing tutorials and I'm makin' a command in pop up (wich is in drag'n drop). So I'd like to use the same mvc in every scenes.
I've tryied wath you adviced me but it only works to go to the next scene and that's it.
Some more advices??

What Is The Point Of 'this.something'
I understand that:
test = "something"
trace (test);
and
trace (this.test);
are the same thing. But what is the point? What does 'this.something' really do? Why do i use it? How come if i don't use it in some places, my code doesn't work?

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