ActionScript 3.0 :: Changing Direction Of A Movieclip Using Enter_Frame?

Jan 3, 2011

Would some wonderful person be willing to take a look at this code and tell me what I'm doing wrong?

I'm trying to use ENTER_FRAME method to get a moving movieclip to change direction when it hits certain x and y coordinates. I want the movieclip to move horizontally, then down, then horizontally again. With this code my movieclip starts off moving down at a diagonal and I can't for the life of me figure out why. (probably something simple I'm overlooking?) I'm a beginner at actionscript.

[Code]...

View 4 Replies


Similar Posts:


ActionScript 3.0 :: Move A Movieclip On Each ENTER_FRAME By Changing The X-value?

Mar 15, 2009

I'm trying to move a movieclip on each ENTER_FRAME by changing the x-value and it seems like x-values below 1 isn't accepted. Am I doing something wrong or is that simply the way it is? Because if it is, is there any work-around to make the clips move slower than += 1 without changing the frame rate or using a Timer?

View 2 Replies

ActionScript 3.0 :: Changing The Tweening Direction?

Sep 21, 2009

I have small popup box which expands from size zero to some size when clicked on the expand button.

The location of this expand button is dynamic.Hence I want to change the the direction in which this expansion happens depending on the position of the expand button.

For example if the expand button is at the bottom right corner of the stage i want the popup box to expand upwards and leftwards.

If the expand button is at the top left then i want the popup box to expand downwards and rightwards.

I have only one movieclip for the popup box with the registration point at the top left corner.

I tried to achieve this by dynamically changing the registration point of the popup box movieclip using the DynamicMovie class. But no luck.

If I manually change the registration point it is working.

View 2 Replies

ActionScript 2.0 :: Changing Direction Of Thumbnail Strip?

Jun 27, 2006

I have been following through the "gallery" tutorials here on Kirupa, and finally got to the third version (the one with the auto-scrolling thumbnails along the bottom, which scroll left / right based on the mouse pointer position, and the keyboard Left / Right scrolling).

I need my thumbnails to scroll UP and DOWN instead of LEFT and RIGHT, and have been trying to modify the ActionScript that came with the downloadable .fla file for the tutorial, but without complete success yet. (The functionality of the whole thing is still intact except for the scrolling thumbnails.)

Here is the portion of the AS that addresses the thumbnail scroller, and I have highlighted in red the variables that I believe need to be swapped around for it to scroll vertically instead of horizontally. I have made the obvious changes such as :-

_width changed to _height
hit_left changed to hit_up
hit_right changed to hit_down
_x changed to _y

[Code].....

Again, this is the ORIGINAL ActionScript, not my modified version. Only the items highlighted in red have been changed in my modified version. Basically when I test the movie now, I get the last two thumbnails of the gallery transposed one over the other, at the point of the movie clip instance, and no scrolling at all. When I use the UP and DOWN keys, I do get to "manually" scroll through the big images, but no change in the thumbnail area.

What have I screwed up or overlooked? I have scanned and scanned and scanned the above section of the AS, and I can't see any other variables that ought to be meddled with.

View 4 Replies

ActionScript 2.0 :: Changing Image Direction In Easing?

May 13, 2008

I'm currently having problems finding anything thats helps me change the direction an image is facing depending on mouse moment. I've found stuff on rotation, but I want my image to flip so its facing the other way.

View 4 Replies

Flash :: Changing The Direction Of A Ball On Collision Base On Speed

Jan 4, 2010

I am creating a ping pong game. And I want to create the ability to control the direction of the ball based on the impact on the paddle. If the ball is coming down at vy = 4; vx = 4;

and the paddle is moving to the left at vx = -5; I want the ball to slightly change its course depending on how fast the paddle is moving. It would probably reduce the balls vx speed on collision, therefore making the ball move more straight (close to the Y axis) when it is moving back up.

I figure the solution for probably doing this would be to measure how fast the paddle is going. My problem is the paddle is controlled by the mouse and has no certain speed. I am trying to figure out how I can measure the speed of my mouse traveling on the x axis.

I am probably going to create a timer that fires every few seconds to determine where the mouse was and where it is at. figure the difference and that will be the speed

View 3 Replies

ActionScript 3.0 :: Flash Changing Direction When Ball Reaches Gutter In A Bowling Alley Type Of Game?

Aug 20, 2011

I am trying to make a bowling alley type of game. I want the ball to change angle when it reaches the gutter, but the problem I am facing is, how can I check when the ball has reached the gutter as the bounding box for a line/box in perspective is bigger and I want to check any point on the line when the ball is passing/crossing that point and moving so that I can change its angle and direction. And also does anybody have a collision method algorithm or physics to create the falling of PINS when the ball hits the PINS.

View 1 Replies

Actionscript 3 :: Flash, Using Event.ENTER_FRAME Or Movieclip?

Aug 20, 2010

I want to create an endless loop, 8 items moving in a circular shape. When you roll over of each item, it will stop the moving, and you should be able to click it.

I dont know what should I use, should I use Event.ENTER_FRAME or the circular shape should be in movie clip, so that when there is a mouse over event, it will stop moving?

Oh ya, I code everything in AS3, including the movement, objects etc. Something like a new class

View 1 Replies

ActionScript-3 :: Difference Between Playing Previously Created MovieClip And Event.ENTER_FRAME

Aug 1, 2011

I am creating game which involves some billiard-like balls to bounce on the screen. I created a MovieClip with only one frame which represented the ball, exported it to the class, extended it to my needs and animated it using Event.ENTER_FRAME. It works fine, but there is something that confuses me -- both, the stage and the ball have only one frame each, so I don't quite understand how Event.ENTER_FRAME works... I mean, if there are no keyframes, how is done the animation? If I used already animated MovieClip, I would have to add keyframes, right?

View 4 Replies

ActionScript 3.0 :: Why Is Penguin Fat After Changing Direction Using "scaleX"

Mar 16, 2010

My Code:

Code:
var facing:int = 1;
if (xspeed<0) {
walker();

[code]....

I have my "hero" as a MovieClip that I placed on the stage, and resized. But when he changes direction his width reverts back to the original thats within the MovieClip.

View 2 Replies

ActionScript 2.0 :: Scrolls Continuously In A Direction Until The Direction Of The Mouse Is Changed?

Feb 24, 2009

i have a scroller developed in as2. it basically scrolls continuously in a direction until the direction of the mouse is changed. the images of course loop in the continuous scroll. now the problem is that for 10-15 photos its ok. but when i feed it with 180 photos, it seems to show only 11. why would this be? any restriction on flash ??

View 1 Replies

ActionScript 1/2 :: Detect A Movieclip's += Direction?

Apr 21, 2011

I want to know how if a movieclip is going += ._y or -=._y

View 1 Replies

ActionScript 2.0 :: Moving MovieClip To X Direction

Apr 29, 2009

I'm moving a movie clip using actionscript (as2) instead of a motion tween (because I want to save file size). I have this code on the first frame of the main timeline ("stone" is the movieclip instance name) and it tells the movie clip how many pixels to move in the x direction:
Code:
xTargetstone = 600;

I have this code on the movie clip itself ("stone" is the mc instance name) to handle the actual moving of the movie clip:
Code:
onClipEvent (enterFrame) {
xstone = getProperty(_root.stone, _x);
movestone = _root.xTargetstone - xstone;
setProperty(_root.stone, _x, xstone + (movestone/5));
}

The movement works fine, but the issue is that it starts out fast and then slows down over time (even though that amount of time is small). The result is that the movie clip seems to wiggle and vibrate before it stops. Is there a way for me to change the code so that it doesn't wiggle and vibrate? perhaps something with the math I'm just not totally understanding? I would like a nice consistent motion from start to finish, while being able to set the time it takes to move etc.

View 1 Replies

IDE :: Telling MovieClip How Many Pixels To Move In X Direction

Apr 29, 2009

I'm moving a movie clip using actionscript (as2) instead of a motion tween (because I want to save file size) and I have this code on the first frame of the main timeline ("stone" is the movieclip instance name) and it tells the movie clip how many pixels to move in the x direction:
Code:
xTargetstone = 600;

I have this code on the movie clip itself ("stone" is the mc instance name) to handle the actual moving of the movie clip:
Code:
onClipEvent (enterFrame) {
xstone = getProperty(_root.stone, _x);
movestone = _root.xTargetstone - xstone;
setProperty(_root.stone, _x, xstone + (movestone/5));
}

The movement works fine, but the issue is that it starts out fast and then slows down over time (even though that amount of time is small). The result is that the movie clip seems to wiggle and vibrate before it stops. Is there a way for me to change the code so that it doesn't wiggle and vibrate? perhaps something with the math I'm just not totally understanding? I would like a nice consistent motion from start to finish, while being able to set the time it takes to move etc.

View 4 Replies

ActionScript 2.0 :: How To Get MovieClip To Move With Mouse Direction

Apr 20, 2004

How do I get a movie clip to move to the mouse when it is clicked and released and have it rotate in the direction that it moves?

View 5 Replies

ActionScript 3.0 :: Direction Of The Ball In The Direction Of The Mouse

Mar 17, 2011

have a ball with the name of mc which can be moved using the keyboard .. when you press the left mouse button shoots the ball, this ball and the other flies in the face where the cursor was in the shot .. but if you move the cursor to another location and shoot a second time then the second ball is also flying in the direction of the cursor and the first ball change direction toward a second shot ..

ActionScript Code:
import flash.display.MovieClip;
import flash.display.DisplayObject;
import flash.events.MouseEvent;

[Code]....

how to make that first ball did not change its direction and continued to fly in the direction of the shot?

View 5 Replies

Professional :: MovieClip Smooth Rotation And Direction Change

May 19, 2010

I want to make a movieclip moves smoothly and when it changes the direction, it can turn smoothly but not a sudden turn, I try out the code below. and the truning is odd:
this.rotation = (Math.atan2(targetY-this.y, targetX-this.x )/Math.PI)*180;

View 2 Replies

Actionscript 3 :: Flip A Movieclip To Face Movement Direction?

Oct 5, 2011

Working on a maze game. When the leftkey is pressed the movieclip (char) should turn 90 degrees to the left.

char.scaleX *= -1;

However, the most important thing is that the character doesnt go through the walls of the maze.And I think thats my problem for implementing the code above.Because it doesnt work properly when i put in here;

if(!mazehit) {
char.y += speed;
char.scaleX *= -1;[code].....

View 1 Replies

ActionScript 2.0 :: Rotate Movieclip According To Mouse Direction, Drag

Nov 8, 2007

Is it possible to rotate movieclip, while dragging, according to mouse direction and mouse x, y on that clip.

on the picture the 0, 0 of the mc containing red box is where the lines cross, the mouse point is indicated with cursor and around it is the circle where clip's x and y should be constrained and movieclip should rotate according to mouse movement direction for example: when mouse is moving straight down then the clip's x, y rotates up and stops when its 12 o'clock...

View 7 Replies

ActionScript 3.0 :: [object Class] Instead Of [object MovieClip] - Delete The Targets ENTER_FRAME Event?

Mar 15, 2009

When I use MouseEvent.MOUSE_OUT the target is [object MovieClip], but when I use MouseEvent.ROLL_OUT I get [object Bildspel] - and Bildspel is my class. The thing is that when I use ROLL_OUT I'm not able to delete the targets ENTER_FRAME event.

[Code]...

View 2 Replies

ActionScript 2.0 :: Moving Movieclip In Opposite Direction Of Mouse Movement?

Jan 3, 2010

I am about to make a gallery where all the pictures are ligned up, in a vertical row collum.I wan to make the Movieclip move in the opposite direction of my mouse movement

View 2 Replies

Actionscript 3 :: ENTER_FRAME Event Over ENTER_FRAME Event?

Oct 29, 2009

Lets say we have a movieclip "Enemy" in the Flash library and a class "Enemy.as" is associated with it which listens to ENTER_FRAME event as follows,

public function Enemy():void
{
//constructor of this "Enemy.as" class

[code]....

View 1 Replies

Copying MovieClip And Changing Properties

Dec 11, 2009

I have a movie clip with a graphic. I want to copy the clip and change its colour. How do I create a copy of the movie clip change its properties without the other movieclip's properties changing as well. I have it now. I was copying the instance not the graphics themselves.

View 1 Replies

ActionScript 3.0 :: Changing The Colour Of MovieClip?

Feb 9, 2010

Basically, I want to change the colour of a component in my fla file that is called 'EDL Arrow' using Actionscript
 
'EDL Arrow' is a Movieclip and is part of another movileclip called 'EDLClipDisplay' - which exports to my actionscript file: 'Export: CIS.FLVPlayer.EDLClipDisplay'
 
How can I change the colour of the component 'EDL Arrow' from the actionscript file 'EDLClipDisplay'
 
I understand how to do colorTransforms but I just don't understand how to connect this component 'EDL Arrow' with my Actionscript file.

View 1 Replies

Professional :: Changing The Speed Of MovieClip

Jan 1, 2011

I am new to Flash and Actionscript and am currently working on some code pulled from another post to try and learn from what others are doing or have done. I have created a star movieclip and am attempting to move it randomly accross the stage in a relatively slow speed. When I run it, it moves randomly but way too fast. I have spent the last 6 hours playing with the code, researching help files and also looking up other discussions but nothing seems to be helping. Here is what I have so far. My apologies if the code looks like a hack. This is being done in CS4 if that matters at all. If anyone could shed some more light on how to handle controlling the speed or rate of random movement with some insight

[CODE]....

View 3 Replies

ActionScript 3.0 :: Movieclip Depth, Changing On The Fly?

Feb 5, 2012

Im trying to keep all my movieclips onto 1 layer/mother mc to speed up the flash display engine
 
I have these takable items(movieclips) that respawn after a while.
 
Initially i build the level starting with all the takable items before adding all the players/npc's. This way the player and npc's walk over the objects if they are not taken.
 
After an items respawns though, i have to re add them to the main mc and then they appear to be over the npc's and they seem to be moving under a carpet of stuff.
Its a nice 3d effect but totally unwanted in this scenario.
 
Is there a way to make sure that items are added as child before a certain clip (like the player). I tried using addchildat but this gives me a index error now and then. I dont really understand how the depths are worked out by flash.
 
I was thinking of storing the original depth of an item movieclip and then on restore, addchild at at its old depth. Or is there a more sensible way?
 
Also: can two movieclips occupy the same index/depth level? or are the incemented or something?

View 1 Replies

Flash :: Changing Y-scale Of A Movieclip?

May 5, 2011

I'm trying to change the y-scale or x-scale of a movieclip. I've tried a few tutorials but they're always talking about "elem._yscale".. However it's no longer supported by AS5.

View 2 Replies

ActionScript 2.0 :: Changing Fill On Movieclip Once Its Set?

Jul 31, 2009

I have created a simple square shape by the following:

penName_mc.moveTo(0,0);
penName_mc.beginFill(0x6548D9,100);
penName_mc.lineTo( 50-startX,20-startY );

[code].....

View 4 Replies

ActionScript 3.0 :: Save A Changing Movieclip A Var?

Oct 13, 2010

Save a changing movieclip as a var

var myclip:blank = MovieClip(holdbutton2.getChildByName("but2" + [myplacerb] ))

View 1 Replies

ActionScript 2.0 :: Changing Instance Into Another Movieclip

Oct 31, 2010

When you're in the flash application, you can watch the properties of an instance. In the properties tab, you can also click "Swap", this will ask you about which instance you would like to use. The original object will now change into another movieclip. So, how do I do this with Action Script?

View 3 Replies







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