ActionScript 2.0 :: Setting Maximum X Coordinate Movement For Object?
Feb 5, 2009
I have a menu, that moves left and right using a move left and move right button that makes more of the menu come into view in the left and right direction.I want the object to stop moving when it's at the beginning and stop moving at the end.I thought I could set a 'max x coordinate' so that if previous was hit the object would not move anymore to the left but it still does.Here is the code I tried to use that doestn' work:
Code:
My Previous Button:
on(press) {
currentX = _root.years._x;
_root.years._x = currentX + 400;
[code]....
View 3 Replies
Similar Posts:
Apr 11, 2007
I'm having a little difficulty getting to grips with the getBounds() Movie Clip function. I assumed the getbounds() method simply got the boundary coordinates for the movie Clip, that one could use to draw a rectangle. This is what I'm trying to do;I'm trying to get a movie clips coordinate bounds, and use the min and max values of x and y to draw rectangle around the object. Simple right? But in my case, I'm getting some unexpected results. I wonder does ther registration point of the object determine the coordinate values? Also are the coordinate values local to the clip instance or global to the stage?
[Code]...
View 5 Replies
Mar 31, 2010
I've been trying to stop an input textbox from adding more lines after I've set it to multiline no wrap and setting max chars. Is there a way for it to stop adding lines?
View 1 Replies
Jun 30, 2010
How do you set a max and min value for a variable? I have defined a variable, myVar, to have a default value of 10 at run time. The user can then use buttons to increase and decrease the amount. How do I set the limits?
View 1 Replies
Jul 28, 2011
i have a darkBlueRect rectangle sprite and a copy of the same sprite with a larger scale and a lighter color - lightBlueRect.i'm attempting to shift the location of the lightBlueRect according to the mouse.x location when the mouse is moving over the darkBlueRect. this way if the mouse is on the right of the darkBlueRect than the location of the scaled up lightBlueRect will be on the opposite side and shifted towards the left proportionate to the mouse position and scale. in addition, the lightBlueRect must appear "locked" to the darkBlueRect so lightBlueRect.x must never be more than darkBlueRect.x and lightBlueRect.x + lightBlueRect.width must never be less than darkBlueRect.x + darkBlueRect.width.
[code]...
View 1 Replies
May 12, 2011
I need to change the starting and ending dates, so that the earliest date that can be chosen is January 1, 2011 and the latest date that can be chosen is April 30, 2011. Also, the user should only be able to select 30 days at a time.
View 1 Replies
Mar 31, 2010
I have 3 square. smallest square s3 is inside s2. s2 is in side s1. each is 10px larger [code]how can I find the coordinate of child in its parent's coordinate system?
View 1 Replies
Aug 2, 2009
I'm a noob on this forum & pretty desperate now. I've been on a research & trial&error odyssey for days now, but this problem remains unsolved. I am creating a game with an mc (say "target_mc") randomly moving around. Everything is working beautifully, except for one thing: My stage was initially 900x600 and the game took up all of that space. target_mc's movement was accordingly set for a width of 900 and height of 600.
I have now resized the stage height to 958 with the game (still 900x600) being centered vertically. The top border is now at 170.8 (y). The bottom y border is at 770.8. But target_mc still thinks the top border is at 0. As a result, it is still covering the same area as before, hence floating off the actual game area into the stage margin area between 0 and 170.8. As I have other frames following which require my new and larger stage size, going back to the original 900x600 is not an option.
I have tried and tried but not managed to tell target_mc to keep its random movement within <=170.8 and >=770.8. I have tried all variations of "if statements" and other tricks at my disposal. And since I'm not an expert, I'm at my wit's end. Everywhere I looked, the solutions offered were for draggable objects or cursor movements, but not for movieclips moving randomly as soon as the frame is loaded. My script & codes are very, very elaborate and there is a lot happening on the stage, so a mask is not an option for me. Surely there's got to be a way to set variables and commands in the script...? I just don't know which to go for...
Do I work with some kind of math involving the total stage height of 958? I have tried setting variables for xMin, xMax, yMin, yMax, but must have done something wrong in implementing them in the rest of the random motion code cos nothing worked.
View 3 Replies
Aug 26, 2009
Using Flash 8, and ActionScript 2, what is the max value that an _x property on a MovieClip can be? For instance, is it okay to position a movieclip at _x = 60000?
View 3 Replies
Mar 27, 2009
It also need to have some random scaling to it, maybe something like this code below.
Code:
targXscale = 50;
targYscale = 200;
[code]....
View 1 Replies
Sep 3, 2009
I have a movie clip that jumps around over the course of my movie using standard keyframe animation. At every keyframe, it calls a function that moves a dynamic text box on top of it, autosizes the text box, then alters the movie clip's _width and _height to fit that of the text box.
The problem is, while the resizing code works fine and the text always fits, the act of altering the _width and _height seems to cancel out the keyframed positioning. The movie clip changes size, but it's forever locked to the position of the first keyframe.
[Code].....
View 1 Replies
May 4, 2011
trying to loop out some pictures using a for loop and cant get them to be posiotioned directly beneath the previous picture, I have set the height number in my xml where I get the pictures from.[code]This is how the code should look like if you are trying to place pictures directly beneath the previously added picture using a class with parameters, in this case the "LoadExternaly" is that class.
View 1 Replies
Jan 8, 2011
how i can stop the movement of one object when one other object is over one third object
View 1 Replies
Jun 11, 2010
I'm stuck thinking about the best way to go about setting a line segment's position, I have a class Line(length, angle, previous) being called from a class Polygon. Right now I have:
public class Line extends Sprite {
public function Line(length:Number, angle:Number, previous:Line = null) {
if (previous != null) {
this.x = previous.end.x;
[Code].....
View 1 Replies
Oct 9, 2009
I made a code which is supposed to move an object (Character) to the location of a button (1). I tested it, and it won't work.[code]I've attached the code directly to the button, but I just can't figure out what is wrong. Does anyone know?
View 21 Replies
Mar 16, 2011
I have an object who's movement I want to limit to a small rectangle on the stage.
View 6 Replies
Jul 27, 2006
well I have this frame as a movieclip called field. And inside it, there's another mc that is moved by the cursor keys called box. Now I have created another movie clip called boxclone. I want boxclone to make the same movement as the box in the field. I know it has something to do with localToGlobal but I don't know how to setup the code correctly...
View 3 Replies
Feb 5, 2010
I've made a sort of sliding menu in Flash (CS4) which is basically a movie clip that has a function assigned to it that if the cursor goes over a button it starts moving in a direction.
Code:
_root.right.onRollOver = function() {
goRight = true;
};
[Code]....
Now, I don't want that "content" object to slide all the way out of the screen. How can I make it stop at certain position, say x=770? Or is there any better way?
View 3 Replies
Nov 17, 2010
So I have so parts of actionscript which I am figuring out on how to make them one. What I am wanting to do is move an object to the right and fadeout. Here is my code to animate right 10 pixels, this works perfectly.
[Code]....
View 2 Replies
Jun 13, 2011
Trying to use an enterFrame event in conjunction with two functions that combined I want to move my object (a square) from the right to the left side of the screen and rotate it AROUND THE CENTER.When I use the following functions individually, they both work fine:
Actionscript Code:
//Centering function function rotCenter (ob:*, angleDegrees:Number, ptRotationPoint:Point) { var m:Matrix=ob.transform.matrix; m.tx -=
[code].....
View 1 Replies
Apr 20, 2009
I am trying to get an object to track my mouse on press and i am using a tween. However, the nature of the tween is such that the time taken for the object would move would always be constant despite the distance.
I would like to make the object travel at a constant speed regardless of the distance. Is it correct for me to use a tween? If not what should I be using?The code for my tween is as follows.
map_mc.tracker_mc._x = map_mc._xmouse;map_mc.tracker_mc._y = map_mc._ymouse;startx = map_mc.crosshair_mc._x;endx = map_mc.tracker_mc._x;starty = map_mc.crosshair_mc._y;endy = map_mc.tracker_mc._y;
trackTweenx = new Tween(map_mc.crosshair_mc, "_x", Regular.easeIn, startx, endx, spd, true);trackTweeny = new Tween(map_mc.crosshair_mc, "_y", Regular.easeIn, starty, endy, spd, true);
map_mc.tracker_mc is the mouse cursor that would appear when onPress while the map_mc.crosshair_mc is the object that would track my cursor's movements.
View 1 Replies
Jan 23, 2009
I have an object that is being moved along it's x axis a certain amount each time an button is pressed. I want to be able to restrict the movement of that object along it's x axis so that it can not go past a certain point.
View 2 Replies
Jan 18, 2010
Let's say you have a room, and a little circle representing the player. Let's say also that you decide to draw a shape overlapping the room, set alpha to 0%, and use hitTestPoint() between this shape and the player to create the movement boundary. In short, as long as the player's centerpoint is overlapping the invisible shape, he/she is free to move around.Now, I decided to make things more complicated and add an obstacle to the room - a table in the center. One would think that cutting a rectangle out of the middle of the invisible shape would prevent the player from being able to move there. No dice, the player passes right through the hole in the middle of the invisible shape. The problem, as I see it, is that when the shape is converted to a symbol for use in actionscript, the entire volume of the movie clip is used for collision detection, not just the shape's volume. No matter what options and settings I play with, I can't get the hole in the shape to stay cut-out when I convert the whole thing to a symbol.
Now, I know I could probably add an extra shape to represent the obstacle, and add extra collision detection into my actionscript. However, given that there will be a large number of rooms in the game, and a variable number of obstacles in each room, this is not an elegant solution. The most elegant solution would be to figure out a way to map the playable area in a room with a single movie clip (/graphic).So, I turn to you fine folk. Can anyone tell me how to convert a shape to any kind of symbol, and preserve features like holes within the shape (as in, not have them glazed over as part of the symbol's body
View 5 Replies
Mar 24, 2005
I am looking for the AS for moving an abject with WASD. I had it working with Key.Left, Key.Right, Key.Up, and Key.Down but I want to change them to WASD.
Code:
if (Key.isDown(Key.LEFT)) {
this._x+=moveSpeed;
} else if (Key.isDown(Key.RIGHT)) {
this._x-=moveSpeed;
} if (Key.isDown(Key.DOWN)) {
this._y+=moveSpeed;
} else if (Key.isDown(Key.UP)) {
this._y-=moveSpeed;
}}
View 12 Replies
Apr 4, 2005
I hope that this topic hasn't been discussed ad nauseum; I searched the forums for similar discussion threads to no avail. I completed the Flash MX object movement tutorial found at [URL].I then wanted to add a second instance of the beetle symbol to the stage and assign it both a new instance name and a different set of keyboard keys that would control its movement.
When I test the movie, I am able to control each symbol instance with its assigned keys. (The instances move and rotate as they should.) However, when the first instance rotates and moves to the right, the second instance "slides" with it. That is, the second instance's assigned keys have not been pressed and it doesn't rotate, but it moves right in unison with the other instance.
View 6 Replies
May 21, 2009
making a game, and in html, on press arrow key up or down, moves the object and the screen
View 2 Replies
Jun 24, 2009
make snap object on the mouse movement. As, I have made the code but getting issue on removing from snapping. I have attached the file. you can look in the [URL]
View 1 Replies
Jun 26, 2009
I have made a class file player and another class file landscape. The player class file has methods that allow the player to move. Where would I put code to make the landscape move with the player? Would the code go into the player class file or the document class file? I don't know how I could link the landscape movement with the player movement
player.as class file
Code:
//the package
package actionscript{
import flash.display.*;
import flash.events.*;
import flash.media.*;
[Code] .....
View 2 Replies
Oct 11, 2004
i need a movement script that makes an object move to where i want it to then stop. i cant seem to find a script for this anywhere.
View 4 Replies
Apr 4, 2005
I searched the forums for similar discussion threads to no avail.I completed the Flash MX object movement tutorial found atI then wanted to add a second instance of the beetle symbol to the stage and assign it both a new instance name and a different set of keyboard keys that would control its movement.When I test the movie, I am able to control each symbol instance with its assigned keys. (The instances move and rotate as they should.) However, when the first instance rotates and moves to the right, the second instance "slides" with it. That is, the second instance's assigned keys have not been pressed and it doesn't rotate, but it moves right in unison with the other instance.
View 6 Replies