ActionScript 3.0 :: Finding X And Y Co-ords At Which Line Hits Movie Clip?

Jan 8, 2010

Im making a game, where a player controls a character moving around the screen using the mouse.the player moves using a tween, using the current x y pos and the click x y pos to move the character around here's the thing, i have objects on the screen (such as rocks, etc) that i do not want the user to be able to walk through. i do not want to use hit test to simply chuck the character off the object in real time because that's messy and it would mean the tween continued and stuff.. instead, i want to add some code to the top of the "movePlayer" function that checks to see if an object (such as some rocks) is going to be hit, and if it does, i want the tween to only go to this point (yellow in the below diagram)

Here's what i mean:the player clicks on the screen ( the blue dot) and instead of walking straight to the blue dot, the code determines the point at which the player will hit the big orange block, and only tween to that point, if there are multiple orange blocks in the way, the tween will stop the closest block.

View 9 Replies


Similar Posts:


ActionScript 2.0 :: Get A Movie Clip To Play Once When My Character Hits It?

Aug 24, 2007

I've got a problem with a game I am creating, I want a movie clip to play once when my character hits it, it has a stop function at the end of the movie clip, but as long as the character is on top of it, it continues to loop, how do I get it to stop at the last frame?
Here is the script applied to the movie clip:

onClipEvent (enterFrame) {
if (this.hitTest(_root.bubMC)) {
play();
}
}

All I've been able to do was make the last frame extremely long and load an alternate movieclip without the hittest function applied that runs the animation.Essentially, I am asking, "How do I make a piece of actionscript run only once", like:

onClipEvent (enterFrame) {
if (this.hitTest(_root.bubMC)) {
play(ONLY ONCE BUT AFTER THAT DON'T DO IT AGAIN);
}
}

View 1 Replies

Professional :: Make Background Move Over / When Movie Clip Hits Edge

Mar 25, 2012

the conent will not be able to be seen unless the user hits the arrow keys on there key board. So i need to make a group of objects i can make into a movie clip and than inside that movie clip make an animation that plays the squirrel running. i will pause here to ask two things i dont know how to do i want the squirrel to have an animation when standing still where it flicks its tail (like a real squirrel would). and also how would i flip the squirrel so when the left key is pressed it points left and when the right arrow is pressed it faces left? and my main question when it reaches the edge of the stage the extended background that runs off stage moves over to reavel more content. as well as not have the squirrel run off stage? in short i am using the squirrel to view the full pages content.

View 2 Replies

ActionScript 2.0 :: Getting A Movie Clip To Change It's Alpha When It Hits A Certain Frame In An Attached MC?

May 27, 2005

I'm trying to get in the habit of using AS in the first frame on the main timeline as much as possible. but sometimes i hit a snag. like getting a movie clip to change it's alpha when it hits a certain frame in an attached MC.

View 8 Replies

ActionScript 2.0 :: Movie Clip To Blur When The Main Scene Hits Certain Frames

Jan 22, 2009

Is there any code that basically says, if root frame = 2 then do this.. I basically need my movie clip to blur when the main scene hits certain frames. The movie clip pans around though with script thats why i cant just add a blurred image to a layer in the main scene.

View 6 Replies

ActionScript 2.0 :: Finding The Angle Of A Movie Clip?

Oct 5, 2009

Wat's the difference between to find angles of two points which is (x1,x2) and the other point be (_xmouse,_ymouse).

To find the angles we subtract from one point to the other

like
method 1:
target x = (_xmouse - mc._x)
target y= (_ymouse - mc._y)

[Code].....

View 1 Replies

ActionScript 3.0 :: Finding Total Max Width And Height Of Movie Clip?

Apr 6, 2011

How do I find the total maximum width and height of a movie clip with respect to every frame of that movie clip?

So for instance if the movie clip was circles of radius 5 registered at their center at various positions where:

frame 1:circle.x=-30
frame 2:circle.x=0
frame 3:circle.x=30

The total maximum width of movie clip would be 30--30+5+5=70.

View 1 Replies

ActionScript 2.0 :: Error : Frame=1: Line 5: Clip Events Are Permitted Only For Movie Clip Instances?

Jun 8, 2002

i've tried placing the code in the actions pnel of the mc; on the mc at the main time line and in various other unspeakable places... but i always get the same error warning me that this code can only be used in movieclip instances and that my stupidity levels are reaching dangerous levels. (error: 'Symbol=stage_mc, Layer=actions, Frame=1: Line 5: Clip events are permitted only for movie clip instances

onClipEvent(enterFrame){'

i fear somebody will reply to this with:'the code goes on the movieclip instance'...at which point i will take up a career in knitting (i knew i shouldn't have given up the course in the first place)

View 12 Replies

ActionScript 2.0 :: Create A Line That Goes From The Movie Clip

Feb 2, 2008

i have a movie clip that rotate with up and down keys. the player walks on the ground, there are walls. now, i want to create, (with actionscript 2) a line that goes from the movie clip, that goes in the direction the movieclip is facing and that stops when it touches the ground or a wall.

View 2 Replies

ActionScript 3.0 :: Reflect A Movie Clip Across An Angled Line?

Apr 7, 2011

I'm trying to build a tool similar to this.I'm using movie clips for the shapes.I am placing the reflected shape by figuring out the point on the line perpendicular to the original shape's registration point, then using the distance and angle. The part I'm stuck on is how to actually reflect it.It seems that if I was just drawing a shape I could use each point to determine new ones as I did above and redraw it, but I also have to reflect more irregular movie clips like illustrations and bitmaps. I tried rotating and Any insights on the best way to approach this? Is there a way to use a matrix?

View 2 Replies

Professional :: Line Added To Movie Clip Doesn't Appear?

Nov 13, 2010

I'm trying to add a line to a movie clip. When I trace the width of the lineadded it traces correctly, but the line doesn't appear. If I do everything the same but add the line to the stage instead of the movie clip it does appear. I know this is one of those cases where I can't see the forest fro the trees but

Here's the relevant code:
var xAxis = new Shape(); graph_mc.addChild(xAxis); xAxis.graphics.lineStyle(2, 0x000000, 1) xAxis.graphics.moveTo(startX, startY); xAxis.graphics.lineTo(maxX, startY) xAxis.name =

[code].....

View 3 Replies

ActionScript 3.0 :: Random Movie Clip On A Fixed Line?

Jul 8, 2009

Here is what im trying to do:

I have created a movie clip which contains a bubble inside it which floats upwards. On my main banner i want this symbol to appear randomly (time and location) but at the same height measurement everytime, but a random width value.

View 3 Replies

IDE :: Moving A Movie Clip Across The Screen In A Straight Line

Jun 7, 2009

I am trying to move a playing card across the screen from the deck to the players hand. The deck is in a stationary position and each player has 2 card places in front of them which are also stationary. The deck is a movie clip called "deck" and the player cards are named "p1c1" and "p1c2"....(player # card #). The animation I am trying to accomplish is to duplicate the "deck" movie clip and move it to the players card. Once it reaches the players card, the stationary card will load the card image and the duplicated movie clip will be removed to make it appear as a smooth transition.

View 11 Replies

IDE :: Moving A Movie Clip Across The Screen In A Straight Line?

Jan 25, 2011

I am trying to move a playing card across the screen from the deck to the players hand. The deck is in a stationary position and each player has 2 card places in front of them which are also stationary. The deck is a movie clip called "deck" and the player cards are named "p1c1" and "p1c2"....(player # card #). The animation I am trying to accomplish is to duplicate the "deck" movie clip and move it to the players card. Once it reaches the players card, the stationary card will load the card image and the duplicated movie clip will be removed to make it appear as a smooth transition.

View 1 Replies

ActionScript 2.0 :: Draw A Line / Circle And Place A Movie Clip On It?

Aug 6, 2009

I was wondering if anyone could tell me how and if it is possible to draw a line/ circle and place a movie clip on it and get the movie clip to go round the circle by placing the left and right arrow keys on the keyboard.

View 0 Replies

ActionScript 3.0 :: Movie Clip Time Line And Button Listeners?

Apr 4, 2011

I have a Movie Clip with two key frames. One Button sits on key frame 1 and changes its position in frame 2 (its instance name remains the same.) The Movie Clip is created dynamically and placed on the stage via code, then mouse click listeners are added to the button. My question is this: When the Movie Clip transfers from fram1 to frame 2, will I need to add the listener back to the button? In addition, I noticed that when I use key frames to move a Graphic Object, sometimes the object behaves like a singe object that is moved and sometimes it behaves like several objects that are created and destroyed in different locations.

View 2 Replies

ActionScript 2.0 :: Have A Character Movie Clip Walk Along A Line/curve?

Jun 26, 2008

Using AS2, how can I have a character movie clip walk along a line/curve without falling through it? By this I mean the character could say, walk over a hill whilst jumping (falling back down due to gravity physics) but would not fall through the curve that represents the hill.An example of this would be BMX star or BMX backflips and any game that is a side-on view of a character walking.

View 1 Replies

ActionScript 3.0 :: Input Text Control Time Line And Movie Clip?

Apr 3, 2011

I would think this would be pretty simple, but I don't really know anything about actionscript 3.0. Please put this into terms I can understand. Basically, I want to be able to input text in a text box and have the movie jump to another frame based on what is typed into the box after the "enter" key is pressed. For example, If you type "Frame 2" and press enter, It could go to frame 2 and stop.

Additionally, I want to beable to have it control movie clips within the frame. For example, if you type "MovieClip1 Frame 3" it could seemingly transform an individual element in the frame by making the movie clip go to and stop at it's third frame.Finally, in the case that something is typed that doesn't match up (that the movie "doesn't understand,") I would like a movie clip to switch from being invisible (frame 1 of the movie clip) to showing an error message (frame 2 of the movie clip).The idea is, I want to make a visual text-based adventure game. Like, you could type "go north" and it would go to frame 3 where there's the northern part of the village.

View 5 Replies

ActionScript 2.0 :: Make A Movie Clip Move Dynamically Following A Path Given By A Line?

Jun 25, 2005

How can I make a Movie Clip move dynamically following a path given by a line?? Like.... the user can draw a line and the movlieclip moves following it ? how ?

View 1 Replies

ActionScript 3.0 :: Finding If Line Passes Through Object?

Jun 21, 2009

I have two points and an object with a given width(or length). I'm trying to find out if the line between those two points passes through the object.

View 3 Replies

ActionScript 3.0 :: Finding And Replacing New Line Characters

May 10, 2010

I am making some string variables to use in an animation. Another person in the office has has written all of the text using Word. Some of these strings have up to 50 lines and each new line has some sort of special character in there which creates an arror in AS. I can manually go through and place the cursor at the end of the line at that point, hit delete and then type in " ". This eliminates the error but I have a lot of these strings, days of work. I have not been able do a simple find and replace. Has anyone experienced this before? Is there a way to use notepad++?

View 2 Replies

ActionScript 3.0 :: Copy The Movie Clip And Paste It Further Down The Time Line - Error 1009

Jul 1, 2009

I am having a problem with the error above as follows i have a video which is working fine on frame 12, but when I copy the movie clip and paste it further down the time line to work on a different page I get

[Code]...

View 3 Replies

ActionScript 3.0 :: Rewind The Time Line Inside A Movie Clip Using The Enclosed Code?

Aug 10, 2009

I am trying to rewind the time line inside a movie clip using the enclosed code - it works fine on Rollover but only for 2 frames on Rollout - what do I need to add to repeat the prevFrame function and go back to the beginning?
 
home_mc.buttonMode = true;
home_mc.addEventListener(MouseEvent.ROLL_OVER, buttonOver);
home_mc.addEventListener(MouseEvent.ROLL_OUT, buttonOut);

[code]...

View 3 Replies

Professional :: Going Back To The Main Frame, From Inside A Movie Clip Time Line?

Mar 29, 2011

In flash CS5 I want to go back to the main time line, from inside a movie clip button, so when i click the the movie clip it goes to another frame on the main time line.. 

View 5 Replies

ActionScript 2.0 :: Use The Var ClipName To Find The Location Of Each Movie Clip Found On _root In The Next Line?

Jan 20, 2005

// code to find out all the movieclips on _root
for (var property in _root) {

if (typeof _root[property] == "movieclip") {
var clipName = _root[property]._name;

// I am trying to use the var clipName to find the location of each movie clip found on _root in the next line

//the next line gives me "undefined" why?

clipBounds = [clipName]getBounds(_root);

}
}

View 2 Replies

ActionScript 2.0 :: Set Interval With In A Movie Clip Affectin Buttons On Main Time Line?

Apr 2, 2011

i'm kema and i have a problem with the setInterval and clear Interval function with in a movieclip i created.the interval seems to still be running even though it is with in a movieclip and not on the main time line. how do i stop it from affecting the buttons on the main time line. i tried applying the clearInterval function to the button on the main time line but still no change. i would be very grateful if anybody can profer a solution to this problem,

View 1 Replies

ActionScript 2.0 :: A Line From One Point Past Another Point And Whether It Hits An Object?

Aug 19, 2009

I am using AS2 with Flash 8 Professional So, my problem is that I currently have a man in the middle of the screen, who shoots a line towards the mouse when I click. However, when I use hitTest to see if the line collides with another object, Flash recognizes the line as a large box if it is diagonal, so the hitTest isn't very accurate. The line only satys there for one frame, so I can't have the usual moving-bullet-style. I am either looking for a way to create an imaginary line with AS from the starting point to the mouse and beyond, and tell whether or not this line intersects with an object... or some other way that I haven't thought of to fix my problem. Keep in mind that the line rotates from a center point towards anywhere around it for 360 degrees.

View 1 Replies

IDE :: Converting X - Y Values - Create An Animation That Automatically Draws A Line Onto The Movie Clip Which Ends Up Being Curved

Jan 12, 2009

I'm trying to simulate the coriolis effect and have managed to create a drawing application that lets the user draw on a rotating movie clip. However, I would like to now create an animation that automatically draws a line onto the movie clip which ends up being curved, but I can't figure out how to convert the x, y coordinates of the pixels on the stage to the corresponding x, y values of the movie clip. Here's what I have so far:

[Code]...

View 1 Replies

ActionScript 2.0 :: Shift The Co-ords Of The Mouse?

Jul 30, 2006

Am having a poke around with an area when pressed, it will reloated the mouse position.I dont think it is this simple.

_root.nozone.onPress = function(){
_root._ymouse = 10;
_root._xmouse = 10;
}

View 1 Replies

Actionscript 3.0 :: Export A Region Of SWF Movie To PDF (image) When The User Hits A Button?

Feb 7, 2009

I want to export a region of my SWF movie to PDF (image) when the user hits a button. How do I do that?

View 2 Replies







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