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




[F8] Changing Angle Of A "line"



Hey, I am making a shooting game that a man is holding a gun and the gun's rotation points to the mouse. If you click the mouse, then a bullet movieclip is attached. I am wondering how to change the angle of the bullet, which is a thick line, so that it looks like the gun is shooting it out. I hope you understand this, if not ill try better. Just ask.



FlashKit > Flash Help > Flash ActionScript
Posted on: 12-21-2006, 09:59 PM


View Complete Forum Thread with Replies

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

Calc Degree/angle From Line
When I draw a line with the drawing api from flash I want to calculate the angle. How can I do that

Changing The Gun. Angle Detection Already Done.
Heeey

I'm trying to get a picture of a gun to addapt to the location of the mousepointer.
So the gun would always aim where the mousepointer would be.
I've done angle detection so i know the angle of the mousepointer in relation to the gun.
Simply rotating the picture only works in 2D. And my game looks 3d so can't do that.

Anybody any advice?
The game i'm working on is HL2 Total Mayhem
Play here: http://www.top-download.net/games/ha...tal-Mayhem.php

Cheers
Thierry

Changing Angle Of Projectile
Hi,

I am trying to change the angle of the projectile depending on its roatation

ie
ActionScript Code:
if ( its rotation this){

the angle of movement should be that


ActionScript Code:
/////////////**** Here is the issue *********//////////
//the direction of the arrow ie angle , should be decided
// by the rotation of the arrow when the mouse was pressed///

dx = x_diff;
dy = y_diff;
//_root.direction = _root.arrow._rotation+90;
//direction =Math.round((_root.rotationangle*180/Math.PI));
direction = Math.atan2(dy, dx);
speedX = Math.cos(direction)*power;
speedY = Math.sin(direction)*power;
arrow._x += speedX;
arrow._y += speedY;
trace(direction+" direction");
}
};







thanks

Pen Tool: Changing An Angle To A Curve
Quick question..

When editing a shape with the pen tool I was curious how one could turn a sharp corner angle into a curved one?

I tried various keyboard techniques to do this to pull out the bezier arms but couldn't seem to figure it out.

Any help is appreciated. Thanks! ~

d

Pen Tool: Changing An Angle To A Curve
Quick question..

When editing a shape with the pen tool I was curious how one could turn a sharp corner angle into a curved one?

I tried various keyboard techniques to do this to pull out the bezier arms but couldn't seem to figure it out.

Any help is appreciated. Thanks! ~

d

[MX04] Drawing A Line At A Certain Angle Untill It Hits A Wall
ok, i am making a top down game and when the player shoots a gun i want there to be a line drawn coming from him and it should stop being drawn when the line touches a wall

eg: if the player is right next to the wall the line will be very short if he shoots at the wall, but if he shoots the other direction then the line will be very long before it hits the other wall...

i thought about doing this by sending out an invisible probe mc that moves in the angle untill it hits a wall and then drawing a line from the player to the probebut that would use a lot of processing power if there could be a player and up to 20 enemies shooting machine guns which fire extremely fast... major hit on performance...

i just need the code that draws a single straight line that stops when it hits a wall with an instance name of wall, but i can't just put the walls on the top layer and hope they cover any excess line up, bcause there could be a wall in the middle of the map...

any help?

Changing Zoom Angle With Transition Manager
Hi guys and gals,

I'm making a map and would like to be able to zoom in and out of counties. I've got most of it down I believe, but would like to be able to control where the zoomed in image ends up. I'm using the transition manager information I found here.

Here is what my code looks like:

_root.img_dunn_mc._x = 82;
_root.img_dunn_mc._y = 235;
mx.transitions.TransitionManager.start(img_dunn_mc, {type:mx.transitions.Zoom, direction:0, duration:.5});

The x and y values are to make it appear that the county is zooming in from a specific spot on the map. When it zooms in, it simply makes the clip bigger. Is there a way to control the x and y coordinates of the zoomed in image?

Wow, I hope that made some sense.

Thanks!
Matt

[F8] Changing The X And Yscale Without Changing Line Thickness
How would I change the x and yscale of an object without it affecting the thickness of the line? Is there another method of changing an image size?

Changing Status Line Within Flash
you know how when you scroll over an html link, it's relative url is displayed in the gray bar at the bottom of the page, right? of course you do. is there any way to set that status line to the url of the button in a flash movie, even if it means manually entering the button's url? i think i'm making sense here...
thanks-

Changing Subject Line After Post
Is there a way to change your subject line after you've posted? I know someone changed mine and I was the one who posted it.

Changing Line Animation Direction
Can "tweening" make animated lines draw at right angles or does this effect have to be done with AS? Does anyone have a sample?

Thanks to all those that volunteer their time.

Changing Line Style At Runtime
hello I have a MovieClip in which I draw a graphic.
I se the border line for the graphic using this code:


Code:
movieClip.graphics.lineStyle(2, 0x101010, 2);
how can I change the color of the lineStyle at run time?
cheers

Changing Line Colour - Advice, Please
Hello

I am having some difficulty colouring the line which goes from left to right in my simple preloader.

I have defined the line colour (a purple shade) in the Properties panel (please see attached image) and, while the colour IS this purple shade when it begins its journey across the screen, it then changes to red!

I am attaching the FLA so that you can see what I mean. If you click on the symbol in the library and then on the forward arrow >, you can see the change of colour in the library 'preview' window.

I would like it to remain the same colour, but cannot see how to change it. Here is the Action Script (2) governing the Preloader, though it does not seem to refer to line colour:


Code:
onClipEvent (load) {
total = _root.getBytesTotal();
}
onClipEvent (enterFrame) {
loaded = _root.getBytesLoaded();
percent = int(loaded/total*100);

gotoAndStop(percent);
if (loaded == total) {
_root.gotoAndPlay(2);
}
}
Many thanks for any help.

Steve

Help Changing An Image By Query Line
Hey all, i am sure this is something easy, but here is what i am trying to do...

In the URL, i am trying to put
http://...../flash.swf?bgcolor=fffff...../somepic.jpg

When the flash loads, i want the default headpic picture to change to whatever i put in the query line as headpic. i just can't figure it out i already have the image set as a movie, and named it as headpic. There are other images that i do not want to change that are on top of the image i am trying to change.

If anyone has an idea on how to do this, please help! I am trying my best to learn this on my own, but i guess i need a little boost.

Thanks!
Tim

Changing Sprite Line Color Through AS
Hello,

Is it possible to smoothly change the color of the line in this sprite over a period of time?

Code:

var sp:Sprite = new Sprite();
addChild(sp);

sp.graphics.lineStyle(3, 0x31FF1A);


I saw a bit of code that used Tweener to do this with a movie clip, but I can't make Tweener work with a sprite.

-Beanpole136

Changing The Thickness Of The Line Being Drawn At Runtime
Hi guys,


I am working on a interactivity wherien i draw lines using a pen/pencil just as in MsPaint application in Microsoft. Ia m done with the pencil/ pen tool and its working fine but I basically want to change the thickness of the line at runtime by using a slider functionality ..can somebody help me with this.


Code:

drawing_mc.lineStyle(1, 0x99CC00, 100);

Better Method Than The Tutorial's "in Line" Code For Changing Colors?
Greetings from new flash user, question #2

O.K. My first project has a component similar to an example i found in the flash help... the flash help example is a car with color swatches. The user clicks on one of four swatches and the car changes color.

Well, that is fine and well, but very VERY limited.
I need a LOT more swatches for my "car".

THe code is ALL "in line"
(i.e. on Release of red button then make the car red
on Release of blue button make the car blue, etc.

So a bunch of things annoy me about this, and i have tried some other approaches to no avail.

First, in defining the swatch buttons, i have to type the hex code of my color into the properties. BUT THEN, i cant seem to GET the hex code, so when the i.e. red button is clicked i have to make the color red (or whatever) by AGAIN entering the hex code. i have a LOT of swatches.. copy and paste has crashed flash, so i hesitate to even do that!

so my vision is to be able to first say something like
"on release ANY button".. get and parse the button name and send it to a function that will retrieve the color from the buttons property.

this "in line" stuff seems really arduous and limited !!

can someone point me in a better direction ?

FINALLY, i would LOVE to be able to SET The button colors in my code as well, so i dont have to visit all those "property boxes". Do i have access to the CODE somewhere ??

many, many thanks for helping me get going here...

-kak5157

Changing Fill Color And Line Color Dynamicly And Seperately
Hi community,

In this case, I am going to load a swf with a looping animation colored in black and white only. I want to change the color of the animation dynamicly so that I could have different color at each time. Here is my code:


Code:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Script>
<![CDATA[
import flash.display.*;
import flash.net.URLRequest;

private function init():void{
myCan.addEventListener(Event.ENTER_FRAME,capMotion);
}
private function capMotion(event:Event):void{
var bmd1:BitmapData = new BitmapData(mySwf.width, mySwf.height, true, 0x00CCCCCC);
bmd1.draw(mySwf);

var bitmap1:Bitmap = new Bitmap(bmd1);
bitmap1.x = 0;
bitmap1.name="org";
if (map.getChildByName("org") != null){
map.removeChild(map.getChildByName("org"));
}
map.addChild(bitmap1);
var bmd2:BitmapData = new BitmapData(mySwf.width, mySwf.height, true, 0xFFFFFFFF);
var pt:Point = new Point(0, 0);
var rect:Rectangle = new Rectangle(0, 0, mySwf.width, mySwf.height);
var threshold:uint = 0xFF999999;
var color:uint = 0xFFFFFF00;
var maskColor:uint = 0x00FF0000;
bmd2.threshold(bmd1, rect, pt, ">=", threshold, color, maskColor, true);

var bmd3:BitmapData = new BitmapData(mySwf.width, mySwf.height, true, 0xFFFFFFFF);
threshold = 0xFF000000;
color = 0xFF00CCCC;
maskColor = 0xFFFFFF00;
bmd3.threshold(bmd2, rect, pt, "==", threshold, color, maskColor, true);

var bitmap2:Bitmap = new Bitmap(bmd3);
bitmap2.name="dup";
bitmap2.x = bitmap1.x + bitmap1.width + 10;
if (map.getChildByName("dup") != null){
map.removeChild(map.getChildByName("dup"));
}
map.addChild(bitmap2);
}
]]>
</mx:Script>
<mx:Canvas id="myCan" x="10" y="10" width="650" height="603">
<mx:SWFLoader id="mySwf" width="100" height="250" horizontalCenter="0" verticalCenter="-7.5" source="dance.swf" complete="init()" scaleContent="false" autoLoad="true"/>
<mx:Image x="61" y="320" width="550" height="152" id="map"/>
</mx:Canvas>
</mx:Application>
It works quite fine but I afraid that it's quite resource consuming using enterframe and bitmap drawing. Is there any better method?
Thanks for help.

[MX04] Dynamically Created Textbox Won't Go To Next Line When Text Exceeds First Line
Hey all,

I've dynamically created a textbox and then applied a new text format with the following code:


Code:
{
createTextField('welcome',4,-100,-25,160,100);

welc = new TextFormat()
welc.font = "Sydnie";
welc.selectable = false;
welc.size = 12;
welc.color = 0xfffafa;
welc.multiline = true;

welcome.text ="Text that exceeds one line."
blackbox.welcome.setTextFormat(welc);
}
How do I make the textbox go to the next line when the first is full and not go beyond it's right border?

Thanks for your time,
Greenham.

Attach A Line To Two Movie Clips. So The Line Moves And Adjusts To The Positionning
Hey

ok I'm working on a project, I have two movie clips moving to different locations, and I want a line connecting both clips.

The line will need to adjust dynamically to the mouvement of both clips.

Can someone give me a heads up on how to accomplish such task.

If more information is needed, post areply saying so, and I will add more information about what I am trying to accomplish.

Thanks
Jean

[F8]Text/Paragraph/String - Line By Line Write Effect
howdy - ive seen some nice text effects recently, and im looking for some resource on recreating them. Ideally im after a nice function / prototype for outputting a line of dynamic text, to a textfield in a nice way, rather than just dumping it on screen. So either letter by letter, or line by line, without having to do all the rubbish faux-effects by masking and tweening.

any ideas?

cheers.

Reading Textfield Line By Line ? Selecting Multiple Textfields At Once ?
OK i need some serious help/advice !

I`m trying to make a sort of program like word , i want to have a text field , but the problem comes when i want to create like borders around each line of text and have DIFFERENT background colors for each line.
So i was thinking if i can read line by line and get get the height of each line by examining char by char for it's size and get the biggest one ( since my text may have different fonts sizes ect on a single line) and then have like BLOCKS that are behind each line and adjust their sizes accoring to the line size and change their color also.

Also another thing that I would also want to do , i want to create a table which i did , but now how do i put the table into my text ...and not just lie on top blocking text behind it ..how do i like "push" the text around it ?? ANY IDEAS would help...thats why i thought maybe create lots of textfields just stacked from top to bottom..but then i will have the problem of selecting them all at once like in a REAL word processing problem...and also if the text becomes too big it will need to "flow" into next textfield...

Is there ANYWAY to do this ??! HELP ME!!!!

THANK YOU

Multi-line Text Field Auto Line Break
When a Dynamic Multiple line text field is used in Flash CS3, it has a very annoying feature that auto inserts a line break at the end of inserted text. It also auto inserts a line break if no text is entered too.

I'm having a problem with this because the text is being saved from flash to a text file on the desktop. With every multi-line text field there's a nasty looking line break.

Any way of "turning off" this auto-line-break-at-the-end feature?

Getting An Angle
I have a helicopter and when you click with the mouse cursor, it adds another helipad, the helicopter starts at the first helipad and flies towards the next one in the array, so when you click, it adds another destination to the list. My problem, I want the helicopter to fly with it's tail to the back, getting the direction iut has to fly and then rotates it aacordingly, anybody that can help me???

it can be previewed at http://subman.deviantart.com

Check the helicopter chaos, this is the flash I'm having difficulty with..

Just click on the helicopter link, thanx for th einput in advance

Arc On An Angle
Hi,

Angles are drawn dynamically. They are measured and shown to users. I'm stuck on making arc for the angles drawn dynamically.

Any links, idea or help?

Angle
I have a two boxes center screen I did action on both as follows

onClipEvent (enterframe) {
_rotation-=2;
_x++;
_y++;
}

The first rotates up to far left corner 2nd bottom right corner.

onClipEvent (enterframe) {
_rotation-=2;
_x--;
_y--;
}

My quest is how would I get a 3rd + 4th box going opersite directions, Many thanks

Regards Barrie

Angle Between Two Mc's
hey
trying to calculate angel between two mc's
came up with this
ActionScript Code:
function angle(ob1, ob2) {
var o1 = eval(ob1);
var o2 = eval(ob2);
xDist = o1._x-o2._x;
yDist = o1._y-o2._y;
return (Math.atan(yDist/xDist)*180/Math.PI)-90;
}


but there seems to be something wrong with that
its only returning negative angels

any ideas whats wrong with it?

Angle
I have a two boxes center screen I did action on both as follows

onClipEvent (enterframe) {
_rotation-=2;
_x++;
_y++;
}

The first rotates up to far left corner 2nd bottom right corner.

onClipEvent (enterframe) {
_rotation-=2;
_x--;
_y--;
}

My quest is how would I get a 3rd + 4th box going opersite directions, Many thanks

Regards Barrie

Txt File Double Spacing Off Line, Single On Line
Has anyone else seen this?

When I'm setting up a .txt file for import (the swf is v5 code, authored in MX), I'm noticing that if the .txt file has a single line break between paragraphs, this represents as a single empty line when the swf file is viewed on-line, but it shows as a double blank line when the same file is opened off-line.

Does anyone know a trick to getting imported txt files to display the same way on- and off-line?

(Or am I going mad and no one else has noticed this...)

Flash Getting PHP To Feed It A Text File Line By Line
Maybe someone can point me in the right direction.

I want Flash to access the text file, separated my newlines, that can get quite large. I want Flash to access each of those lines one by one and process them with Actionscript.

I am getting the idea that I should use PHP to open the text file and store the lines in an array. But how can I access each array element in Flash?

Does anyone have any suggestions about this? Have you seen where this has been done before?

Is It Possible To Get Data Printed To The Screen Line By Line As A Ping Does?
I have a Flash web app using AMFPHP remoting that calls a unix script that runs either a ping or a traceroute command based on some parameters I pass it.

The methods in my remoting method table for ping and traceroute are:


PHP Code:



function doLsPing($addr)
{
    $ping = shell_exec("/path/to/my/pingScript.sh " . $addr);
    return $ping;
}
    
function doLsTraceroute ($addr)
{
    $traceroute = shell_exec("/path/to/my/tracerouteScript.sh " . $addr);
    return $traceroute;





The unfortunate behavior I am getting is that the returns, naturally, just send me the completed data from the ping and traceroute in one big lump. Of course I would like to have the data returning to me line by line as the data is collected...like it would if you ran the script in a shell or terminal window.

You can see the danger in getting the one-big-lump-of-data scenario. If you ran a traceroute on an address that did not exist and say the traceroute did 30 hops then you could potentially be waiting a loooooooong time without anything printing to the screen. Plus the user, if familiar with ping and traceroute, would be expecting to see the results printing to the screen line by line as the command ran.

Now the caveat to this is, my PHP skills are nil to none, so maybe I am just missing something that I could use rather than just a 'return'.

Any help here would be most appreciated!

Make Line Movieclip Turn To Dotted Line
hey Everyone

Just wanting to know how to use actionscript to make a line dotted. I want to have a movieclip (a solid line) and when u click on it it will become a dotted line, then be able to switch it back to solid with another click.

Cheers

Reading Data From Text File Line By Line
I want to read some data from a text file into arrays.
In the text file, I have:

data = 1234567890

This works ok, but I want the text format in the text file to be:

data =
12345
67890

So after reading 'data', i will have 2 arrays.
[1,2,3,4,5] and [6,7,8,9,0]

Any idea how to go about doing this?
It will be even better if I dont need to use any variable.
Like this:

12345
67890

The main thing is just to read the text line by line and get them into arrays.
Thanks.

Line Break Or Line Feed For Dynamic Text
I am usin a textArea so now it is different than the last post about styles.
This text is dynamic and is assigned from within the Flash file it resides.
It comes from a list selection listener and I want to pre-format it with line breaks.

Since it resides in the file I will be using a textArea with HTML on to get the line breaks.
But now I can't Style it the same way with the setStyle methos

Currently I have one line is like this.

myNotes.text = "This is Line one<br>This is another Line<br>and another line";



Any help would be appreciated.

Thank you,
WBell





























Edited: 01/24/2009 at 12:49:08 AM by W_Bell

Two Objects Conected By A Dinamic Line + Physics Of The Line
Hi

I have two Movie clips, and I have to conect them with a dinamic line, like a rope. The movie clip A will be interactive with the mouse, changing X and Y positions, so the line should act like a rope.

Does anybody knows some code to do that or have a example?

Mouse Angle
Hi,

How do I track mouse's angle using trigonometry objects in
Flash 5? I need to find a way to convert any given x and y coordinates to degrees. (0 to 360)

Got any idea?

Thanks Much,
z27

Shooting At Any Angle
Hi,At the moment I have a movie clip that can move left right, up, and down, as well as rotate to any angle by keystroke. I was wondering though how
to write the code so it can shoot at any angle of rotation? At the moment the laser will follow the rotation of the movieclip, but will only go in the _x or
the _y coordinate, never both. Any ideas?

This is on the movieclip:
onClipEvent (keyDown) {
if (Key.getCode() == Key.RIGHT) {
_x = _x+2;
} else if (Key.getCode() == Key.LEFT) {
_x = _x-2;
} else if (Key.getCode() == 40) {
_y = _y+2;
} else if (Key.getCode() == 38) {
_y = _y-2;
} else if (Key.getCode() == 90) {
_rotation += -2;
_root.laser._rotation += -2;
} else if (Key.getCode() == 88) {
_rotation += 2;
_root.laser._rotation += 2;
} else if (Key.getCode() == 32) {
tank_x = getProperty("_root.tank", _x);
tank_y = getProperty("_root.tank", _y);
_root.laser.duplicateMovieClip("laser");
setProperty (_root.laser, _x, tank_x);
setProperty (_root.laser, _y, tank_y);


This is on the laser at the moment:

onClipEvent (load) {
laserMoveSpeed = 20;
this._x = _root.tank._x+60;
this._y = _root.tank._y;
}
onClipEvent (enterFrame) {
this._x += laserMoveSpeed;
if (this._x>600 or this._y<0) {
this.removeMovieClip();


Thanks,

Andy
Art-barn.com

Calculating An Angle
hi,

the math I was tought in highschool has left my brain along the years, so that's why now i have to ask this question here:

what is the correct syntax in actionscript for calculating the angle between two lines.

thanks in advance.

(The teachers told me I would need it some day, why didn't I believe them)

Checking Angle
i'm trying to figure out a way to to get the angle that the cursor is to a movie clip. if the movie clip was the center of a clock and the cursor was at 3 o'clock, it would be 90 degrees, 6 o'clock-180, and so on...
anybody have any ideas?

thanks

dougc

Angle Detection
this is a doddle, but I'm brain dead today.
all I want is some simple code to find the exact angle between the mouse and a movieclip. see I told you it was easy. nothing taxing here. Any ideas then?

cheers

Niall

Mouse Angle
I cant figure out. I need a simple mouse angle that says once the mouse is below 200(vertical) to tell target.


BTW thanks for all the help so far, this site is very cool.

Bubble MC From Different Angle
Please help. What am I missing?

I've decided to go different route with my bubbles. I have created a bubble via attachMovie method on level 4. Have called it "bubbleBottom".

Now I want to make it move and it's not going anywhere. I've tried a dozen different paths. Here is what I have latest:

function moveObject (mcName, number) {
name = eval(mcName);
speed = number;
moveSpeed = speed;
name._x += moveSpeed;
}


The call action on frame 1 is as follows:

moveObject("bubbleBottom",3);

When I debug, the variable level0.name=[movieclip:level0.bubbleBottom] shows in there and the moveSpeed=3.

Why am I having such a hard time passing the mc name when using attached movies on main timeline?

Please help.

Thanks MUCH in advance!

Gradient At An Angle?
I'm having trouble reproducing a gradient I made in illustrator. It is a linear gradient but it comes down at a 50degree angle. I can't seem to find any control that allows you to modify which direction a linear gradient is going in flash. Anybody have any tricks?

- Brian
the humble newbie

Determining An Angle.
I'm trying to find a tutorial or just the code if someone has it, showing how to determine the angle between two movie clips. For example, if I have two movie clips on my stage I want one of them to point towards the other. My trig is very rusty and I'm going crazy trying to find a good tutorial. Any help is appreciated.

Thank you.

The Mouse Angle
i would like to manipulate a frame inside a movie by a certian postion (x,y) on the stage. ive got stops on all frame,s inside the movie clip and i want to gotoandstop on certain ones depending on (lets say for this question )when the mouse rolls over an area between x400 and x500 can anyone help me? version 5 or mx

Help On Angle Formula
Im making a flash sorta 3d engine and I need a reliable angle formula (to get the angle with points X, Y, CX, CY)
Right now I'm using ACOS((X-CX)/Dis) where dis is the distance from X, Y to CX, CY. It seems that ACOS isnt all that reliable, and so I keep getting NaN. Does anyone know one thats fast and effective?

Angle From Coordinates
Hi,

whats a quick simple way of getting an angle (in radians) from an x,y coordinate?

thanks

phil.

Angle Move To X Y
i need to get a movieclip to move to a certain position when its roled over. i also need it to point to the position while its moving twards it. heres what i need.... onrollover change angle of mc and move to position. anybody got any ideas?

Height And Angle
how would i match the angle of a mc to the height of a mc like if its coming down then its facinf down and if its goin up hen its facing up, ect

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