ActionScript 3.0 :: Moving Sprite Along Drawn Line?

Sep 18, 2009

I want to the user to be able to draw a line and then have a sprite follow the line as its path. Also, it would be nice if the line could be cleaned up after the user draws it with his/her mouse so that it is made up of clean curves/spline.

View 1 Replies


Similar Posts:


ActionScript 3.0 :: Line Games - Transform A Line Drawn By The Player Into A Hit Detectable Sprite ?

Feb 13, 2009

I'm trying to work out how to create a simple demo that works as follows: A ball falls from the top of the stage.Player is able to draw a line anywhere on the stage. The ball will bounce/roll along the line such that the player can guide it at will. I don't think the coordinate rotation will be a problem for me but I can't figure out how to transform a line drawn by the player into a hit detectable sprite -- or realkly any way that I can get those line coordinates into my coordinate rotation routine. To keep it simple, I'm just working on the first part of the problem, getting the line to where I can hit test or know its position.Here is my code so far:

package
{
import flash.display.Sprite;
import flash.events.MouseEvent;[code]........

It always traces 0,0 instead of my current line coordinates - and even those I don't think would be sufficient.

View 4 Replies

Flash :: Check Collision In A Drawn Curve / Instead Of Sprite's Bound Box?

Aug 23, 2010

There are two Sprite's hit tests, one check the object (and have no precision on the curves) and the other check a specified (x, y) point. But, having curves drawn using Graphics.curveTo(), how do I check if 2 drawn curves are colliding?I'm not sure if this is an actionscript or a math problem..I want to check all (x,y) of a curve to all (x,y) of the other curve..

View 1 Replies

ActionScript 3.0 :: Add Mclips Over Drawn Line?

Nov 2, 2010

On mouse move i have a line drawn using lineTo method. This works like in Paint or most drawing programs: the mouse drawing like a pencil. What i need now, and dont know how to accomplish, is to add a number of mclips over that line. And this mclips should be over the line but separated to each other (different x and y of the drawn line). So in the end when moving the mouse the user should get a line and, every certain distance, a number of mclips over it.

View 2 Replies

ActionScript 3.0 :: Detect Angle Of A Line Drawn With API?

Jun 26, 2011

I'm drawing a simple line with API and I would like to know how to detect what angle the line has and where a ball hits it.Scenario: the player draws a random line in a random angle, a ball comes in from random points and hits the line, the ball then bounces off the line depending on where it hit the line (and of course depends on the line's angle).I draw the red line with this: (on a 400x400 stage)Actionscript Code:graphics.lineStyle(2, 0xFF0000, 100);graphics.moveTo(150, 150);graphics.lineTo(250, 250);The grey, green and purple lines are just demonstation of the ball movement, comming in from outside the screen, hitting the line and bouncing off in different directions. I just made a guess on the angle they will bounce off in.

I just can't figure out how to detect the line's angle and where the ball hits it. So all I have is a ball flying in from random positions and hitTests the line (not coded yet, but no problem to do ball movement and hitTesting with line), I don't know where to go from there until I know how to detect where it hits the line.I know this is a double post (from the Games section), but I realized this place seems to have more activity and not many seem to visit the Games place anymore.

View 11 Replies

Edit Stroke Width After Line Is Drawn?

May 29, 2009

In Flash CS4, I'm trying to change the stroke width of my line or shape, with it selected, but the stroke width slider is greyed out (thus, unadjustable). Is it possible to edit a stroke width after something has been created? If so, how can this be done? I've tried selecting the line in all kinds of crazy ways, but still can't edit it.

View 3 Replies

ActionScript 2.0 :: A Red Line Is Drawn To The Exit Link?

Sep 10, 2009

[URL]go to the menu and select education, click the first sub link under education, once there allow for the screen to load, and then click anywhere outside the black border where the text is. You should notice a red line is drawn to the exit link.

View 5 Replies

Actionscript 3 :: Wait For Each Line Of Code In A Function To Be Executed Before Moving On To The Next Line?

Jun 29, 2011

I am trying to dispatch an event but not sure when I should do it to get the right results. The first event "submitClicked" is in the right spot and works great. However, the second event "dataReady" seems like it might be a problem. I need it to be dispatched after this.compiledFormData is set.Does AS3 wait for each line of code in a function to be executed before moving on to the next line?

// --------------------------------------------------------------------
public function submitForm()
{

[code].....

View 2 Replies

ActionScript 3.0 :: Find Slope / Angle Of A Drawn Line?

Jun 20, 2010

At the moment I am using two mini objects within the line to calculate the slope of the line I have.

I was wondering if there was some easy function within as3 to find the slope of a line that had been drawn out, if not... I suppose I have my own theories on how to do it, such as checking for hit tests in a circle until I find the line.

View 5 Replies

ActionScript 3.0 :: Add Mc Over Some Points Of A Line Drawn With LineTo Method

Nov 1, 2010

this is the thing: Using "lineTo" i get a line drawn on stage when dragging a mc. Then i should have four mc (note1, note2, note3, note4) added randomly over this line. I mean, the line is drawn and then over some parts of this line, using x and y of some of the points drawn there, this movie clips should be added randomly. I can make the mc appear randomly, but always in the same point (mouseX, mouseY); i cannot access others x and y of the drawn line. This is my code (noteContainer is a sprite):

Code:
private function drawingAPI(event:MouseEvent):void{
sprite1.graphics.lineTo(mouseX, mouseY);
}

[Code]...

View 9 Replies

ActionScript 3.0 :: Toggle Line Drawn With Graphics.DrawPath?

Mar 7, 2011

I have an application that creates a chart dynamically. This chart has a lot of information plotted on it (4-6 stock trends). I want to be able to toggle some of those lines with a button. Each trend is drawn with something like this:

Code:
// establish a new Vector object for the commands parameter
var line_commands:Vector.<int> = new Vector.<int>();
line_commands.push(1,2,2,2);
// establish a new Vector object for the data parameter
var line_coord:Vector.<Number> = new Vector.<Number>();
// use the Vector array push() method to add a set of coordinate pairs
line_coord.push(0,0, 75,50, 100,0, 125,50);
graphics.drawPath(line_commands, line_coord);

How would I toggle the line I just drew? My first idea would be to put some of this code inside a function and redraw the line with the same color of the movie's background color. I don't know if this is the best option, I was wondering if I could draw this line inside a Sprite or Movie Clip and just toggle its visibility?

View 2 Replies

Actionscript 3.0 :: Get Objects To Follow A Path (a Drawn Line)?

Mar 30, 2010

is there a way using AS3 to get objects to follow a path (a drawn line) or will i have to set waypoints?

View 3 Replies

ActionScript 2.0 :: How To Make Drawn Line To Be Under Oval Clip

May 20, 2003

Attached is the .fla. I can't seem to figure out how to make the line drawn to be under the oval (right now it's drawing above it....)

View 2 Replies

ActionScript 2.0 :: Changing The Thickness Of The Line Being Drawn At Runtime?

Apr 17, 2007

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.

Code:

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

View 1 Replies

IDE :: HitTest The Line Drawn In ^ With A Clip Called Enemy?

Mar 3, 2010

im making a game where when you click a line is drawn in the direction you clicked. I need to use hitTest with it, how would i go about doin that? here is the stuff.This is on the main timeline, it links to the gun. "bullet" is an empty clip

Code:

gun.onEnterFrame = function ()
{
var angle:Number = Math.atan2 (_root._ymouse - this._y, _root._xmouse - this._x);[code]....

i Need to hitTest the line drawn in ^ with a clip called enemy. How would i go about doing that?

View 3 Replies

Actionscript 3 :: Get Ending Point Of A Line Drawn With LineTo In Flash?

May 10, 2011

I have drawn a series of lines using flash's graphics.lineTo command, and placed them in an array to be referenced later. Based on certain user interactions, the clips that hold these lines can be shifted to the right, causing the lines to move with them, no longer connecting to the point they originally connected to. So I need to extend the lines by the amount their parent clip was shifted (I've called this incVal). So what I need to do is find the point at which each of these lines ended at, and draw from that point to the left by incVal. How do I get that ending point of the line?

This is my code:

To draw line and add it both to the clip and to an array for future reference:

line.graphics.lineTo(localPoint.x,localPoint.y-10);
membersRef.addChild(line);
parallelArr.push(line);

[Code]....

View 2 Replies

ActionScript 3.0 :: Flash - Creating A Shape From A Randomly Drawn Line?

Jun 15, 2010

I have a line randomly being drawn and moved across the stage. Here is the code:PHP Code:

import flash.display.Sprite;
var xValue:Number= 0; 
var yValue:Number = 150; 

[code].....

View 2 Replies

ActionScript 2.0 :: SetMask - Make Rectangle Clip Visible Through Drawn Line?

Jun 17, 2010

I've got a movieclip of a rectangle in my library which I place on stage to attachMovie. Then I create an empty movieclip which I want to use as a mask on that rectangle clip through setMask. Users kan draw into that empty movieclip. My intention is that only those areas of the rectangle clip become visible where the user is drawing a line. So I used this:

Actionscript Code:
_root.attachMovie("clip", "clip", 0);
_root.createEmptyMovieClip("line", 1);
clip.setMask(line);_root.onMouseDown = function() {
line.moveTo(_xmouse, _ymouse);
line.lineStyle(10, 0x00FF00, 100);
this.onMouseMove = function() {
line.lineTo(_xmouse, _ymouse);
updateAfterEvent();};};
_root.onMouseUp = function() {
this.onMouseMove = null;};

But that doesn't work: both the line drawn and the rectangle clip become invisible. I know it works because without the setMask part the line is drawn. The other way around does work (line.setMask(clip)): the rectangle clip is now masking the drawn line so only the line becomes visible within the rectangle region. But I want it the other way around: the rectangle should become visible through the lines that are drawn!

View 3 Replies

ActionScript 3.0 :: Add Texture (image Fill) To A Line Drawn With Graphics.lineTo()?

May 15, 2009

I am trying to draw a  line from x1, y1 to x2,y2 and i want it to be a line that repeats a pattern from an image. All I can see is that you can only draw lines and change their color or thickness but I would like it to repeat an image. Is that possible or do i have to use a really long and thin rectangle with a bitmap fill?The problem is I am making a game where the user will be able to actually draw the line so i have to make it be created dynamically. The game fantastic contraption [URL] has in the game a feature where you draw lines of any length and position that are filed with a picture.

View 13 Replies

ActionScript 2.0 :: Make An Animation Of Hand Drawn Line By Motion Tween?

Jun 1, 2010

I want to make an animation of hand drawn line by motion tween. That is when test movie, a line is slowly drawn from left to right. How do I do that ?

View 1 Replies

ActionScript 3.0 :: Moving A Sprite Across The Screen?

Feb 24, 2010

If I use mySprite.x += 1; //it's choppy
 
if I use mySprite.x += .1; //it's smoother but slow
 
if I use mySprite.x += .5; //it's only slightly choppy but speed is better
 
Is there a way to guarantee perfect movement(the sprite moves subpixels), yet still have an adjustable speed?

View 1 Replies

ActionScript 3.0 :: Moving A Sprite In Both Directions Of X-axis?

Jul 27, 2009

am trying to make a game whre i want the sprite to move from positive x-axis to negetive x-axis for 30 seconds and after dat it has to down along y-axis one step.

View 1 Replies

ActionScript 3.0 :: Senocular's Path Class - Take Line Paths - Drawn And Convert Them Into A Path Object?

Feb 15, 2010

I was wondering if it possible to write up some AS that will take line paths that you have drawn and convert them into a Path object? For example say you drew a jagged line from left to write, would there be a way to have AS convert that into a Path object.

View 11 Replies

ActionScript 3.0 :: Moving Sprite Based On Perlin Noise?

Jan 26, 2012

affect the position of a sprite using perlin noise? Looking at this flag example:

[URL]

If you imagined a sprite with say just a circle drawn in it positioned on the top right corner of the flag, is there a way to calculate the change in position to keep it in-sync with the flag corner as that animates? What I'm after is the fluid motion but not the distortion.

View 1 Replies

ActionScript 3.0 :: Simple Moving Sprite Across Screen Amensia!?

Apr 14, 2010

I want a sprite to be added to the stage, then move along the stage, I guess using the ENTER_FRAME listener. Then when it reaches a certain point, for example ball.x = 200; it is to stay there. Also when it reaches that point, another iteration of the ball sprite is added to the stage at another point on the stage, and then do the same thing as the previous on (like move across the screen until it reaches the stop point (like the one before).This adding of Sprites and then moving, checking if it reaches a point, if so, stop this sprite from moving, then add another sprite in the initial position, would be on a loop until a condition is met, i.e counter = 100;I can't seem to get it down on code, (cue people going "man this is easy"!!) So in short1) add sprite to stage at sprite.x = 100; sprite.y = 150;2) move sprite across stage 10 pixels per frame3) when sprite.x => 500; stop the sprite.counter++;4) add another sprite instance in the original location (sprite.x = 100; sprite.y = 1505) repeat steps 3)-4) until counter == 100, then go to 6

View 6 Replies

Actionscript 3.0 :: Changing Sprite Line Color?

Jan 31, 2009

Is it possible to smoothly change the color of the line in this sprite over a period of time?Code: Select allvar sp:Sprite = newSprite();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.

View 3 Replies

ActionScript 3.0 :: Cannot Assign 'Class' To 'Sprite'. Found 'newparam1;' At Line 22?

Feb 19, 2010

I have some code from a library which actually compiles and runs fine, even though it seems like it shouldn't.

Code:
public class MyClass extends Object
{
public var clip:Sprite;[code].....

Code: You cannot assign 'Class' to 'Sprite'. Found 'newparam1;' at line 22 but the compiler lets it through just fine and it runs perfectly.

View 2 Replies

Tween A Line That One End Is Moving And The Other Is Fixed?

Mar 2, 2012

i wanna do the shape tween or should i say tween a line...one end of the line should stay still while the other should expand and contract moving on a designated path..so its not just an shape tween where line will expand..i want the moving end to go along some path.

View 14 Replies

ActionScript 3.0 :: Draw A Line That Keeps Moving Using Just It?

Feb 22, 2011

I'm trying to draw a line that just keeps moving using just AS3. Like when a heart beat monitor flat lines. The reason is I'm adding this to arduino project so when you breath into an alcohol sensor the line will move up if you have been drinking. I just want to be put on the right path.

View 1 Replies

ActionScript 3.0 :: Moving A Line In A Circle?

Mar 2, 2011

I am trying to move a line around in a circle, around a fixed point (not 0,0). As in the way a clock hand moves around with one end at the middle and the other end traveling in a circle. I tried the rotation function but that moves the entire object around (0,0), I need the point in the middle stationary and at a non (0,0) point.

View 9 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved