ActionScript 2.0 :: OnEnterFrame - Moving Object On Stage And Change Direction

Mar 22, 2006

I'm trying to set up a script which would force an object to move through the stage until a particular point and than change direction. I wrote something like that:

onClipEvent (enterFrame) {
moveUp = function () {
this._y -= 1;
if (this._y<-30) {
this.onEnterFrame = moveDown;
}};
moveDown = function () {
this._y += 1;
if (this._y>600) {
this.onEnterFrame = moveUp;
}};
this.onEnterFrame = moveUp;
}

But it doesn't work. the object moves only one direction and does not change it.

View 1 Replies


Similar Posts:


ActionScript 3.0 :: HitTestPoint To Change Direction Of Moving Object

Jan 5, 2011

I'm having a problem changing the direction of a movieclip using hitTestPoint. I have some balls on the screen that only move left, right, up and down. and pending the way they are moving they have to change direction. if they're moving right they have to change to up. left to down, up to right and down to left. I tried the following code for getting a ball moving moving right to change to up. note: movingDir is just a string i use to keep track of how the ball is moving and is defined initially in another class. here is a snippet from the ball class:

[Code]...

View 8 Replies

Actionscript 3.0 :: HitTestPoint To Change Direction Of Moving Object?

Jan 5, 2011

I'm having a problem changing the direction of a movieclip using hitTestPoint. I have some balls on the screen that only move left, right, up and down. and pending the way they are moving they have to change direction. if they're moving right they have to change to up. left to down, up to right and down to left. I tried the following code for getting a ball moving moving right to change to up.

note: movingDir is just a string i use to keep track of how the ball is moving and is defined initially in another class.

here is a snippet from the ball class:

Code: Select allthis._movingDir = "right";
this._speedR = 5;
this.x += this._speedR; 

[Code]....

View 1 Replies

ActionScript 2.0 :: [flash 5] Random Motion - Object To Flip Horizontally Depending On The Direction It Is Moving

May 9, 2006

i'm using the an actionscript for random movement that i found here... [URL] but my problem is that i need the object to flip horizontally depending on the direction it is moving... the object that is moving around is a bug, and i need it to face left if it's moving left or face right if it's moving right.

View 1 Replies

ActionScript 3.0 :: Moving Vehicle On The Stage, Which Should Change Directions According To Where Click On The Stage?

Oct 24, 2010

I have a moving vehicle on the stage, which should change directions according to where I click on the stage.I already made it work using this formula:var angle:Number = Math.atan2(dy,dx)*180/Math.PI+90;However, I need the car to tween to the correct angle, instead of just "jumping" to it. While this is easy enough to do, the car sometimes takes the longer turn (especially when I click in the bottom-left quarter of the stage), and it seems unnatural.

View 0 Replies

ActionScript 3.0 :: How Does One "detect" If The Object Is Currently Moving To Its Own Left Or Right Direction

Sep 29, 2010

using trig, when moving an object based on its current rotation, how does one "detect" if the object is currently moving to its own left or right direction? example: right side up: left moves the car to its left, which is left. upside down(180 rotation): left moves it the car to its left, which is right. based on movement alone, how can i say its moving to its own oriented left or its right?

[Code]....

View 7 Replies

ActionScript 3.0 :: Moving An Object Around The Stage

Apr 28, 2011

i'm trying to use code so if i type in -10 to 10 the object will move up or down the y axis. The code i'm using at the moment calculates how far to move it from the number inputed, then it removes te object and places it in the required position. However doing the removeChild technique messes up when having many on the stage. I was wondering if anyone knew a way of calculating the rating and then using it to move the object on the stage without removing it and adding it. Here is the code i'm using to move it. OR a way in which i can remove certain objects on the stage using remove child

[Code]....

View 3 Replies

ActionScript 3.0 :: Moving An Array Of Object Across The Stage

Jun 30, 2010

I have MovieClips in the library that are instantiated and loaded to an array. From that array I want to add them to the stage and move them across one by one at specific intervals. I've chosen not to use a tween because it acted finicky and the MCs get stuck for whatever reason. So I've taken a different approach by changing the x coordinate of the individual MC with a timer to make it move (sort of like a particle system.) The problem is that each one needs to be assigned it's own timer function. As of right now every time the timer fires it just resets to the next item in the array and nothing moves. The only solution I can think of is to write an individual timer function for all 18. This seem impractical and there has to be a better way. I guess idealy I would need a function that can write a new function for each array item but I have no idea how to do that. Here's some of my code:

var myTimer:Timer = new Timer(4000);
var moveTimer:Timer;
myTimer.start();

[Code]....

View 1 Replies

ActionScript 3 :: Centering Moving Object On Stage Resize

Nov 19, 2010

I want to center a big movieclip (1400 px wide) on my stage on stage resize. This big movieclip moves to the right on certain events so I can't use code like this:
currentPage.x = ((stage.stageWidth/2) - (currentPage.width/2))
Is there a way to maybe use its offset from 0 (the left side of the stage 'viewport') and use that offset in centering? The movieclip only changes in x.

View 2 Replies

ActionScript 3.0 :: Moving This Out Of OnEnterFrame?

Sep 12, 2011

Ok, This actually works butI want it out of EnterFrame. what is going on is this... The user moves a movieClip called selector.selectorCollisionBox over the movieClip called fG.buidling1 Then the string buildingName is no longer NULL or "", it becomes whatever I set it to. Also a Button is added to the top of the selector so the user can click that and 'enter the building' to view info about it.(or that last part is the plan down the road)

[Code]...

problem is, it seems like it is checking this constantly because I have it on EnterFrame. Is there a way to make an event that just specifically looks for if (selector.selectorCollisionBox.hitTestObject(fG.bu ilding1)) ?? Or better yet, maybe I can have a boolean, overBuilding1 = true that fires all those properties off once instead of every EnterFrame? That way onEnterFrame just fires off a condition? I am so close to understanding this.. I feel like I am at my last brain hurdle.

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

ActionScript 2.0 :: Moving Multiple Items Using OnEnterFrame?

Jul 19, 2007

I am trying create to move objects (boxes, named box_1, box_2 etc) to positions on the stage (xPos_1, xPos_2 etc) using onEnterFrames. I can make all the boxes move individually, but I cant get them to move together. I am using the following code in an attempt to move 3 boxes.

[Code]....

View 2 Replies

ActionScript 2.0 :: OnEnterFrame=null - OnEnterFrame=undefined & Delete OnEnterFrame

Mar 29, 2008

onEnterFrame=null, onEnterFrame=undefined & delete onEnterFrame....

Which one to use??? What are the performance considerations. If all my movieclips on-stage are running a MovieClip.prototype.onEnterFrame = function() {run initial stuff before setting onEnterFrame=null/undefined... }, will there be performance hits? It's sad that delete onEnterFrame doesn't work unless I delete the prototype enterFrame as well, which would make the clips reinitailise itself again once you declare the enterFrame prototype again (i need to do this since there's more movieclips that end up appearing on-stage, and they need to automatically initialises themselves the moment they appear).

[Code]...

View 5 Replies

ActionScript 3.0 :: Rotate Slowly Based On The Direction Hes Moving?

Nov 13, 2010

currently I have a movieclip that follows my mouse cursor simply using

char.x = mouseX
char.y = mouseY

the movie clip is always upright, how do i add rotation so the char will rotate slowly based on the direction hes moving?

View 2 Replies

Creating A Background Which Moves In The Direction That Cursor Is Moving?

Sep 8, 2009

so i have a project where i will be making a website. I will be using flash to make it interactive and visually appealing. I found a website with a really cool entrance page,please view it he mouse moves, the background looks like its moving.

View 3 Replies

Flash :: Moving Layers In X & Y Direction With Depth By Mouse

Aug 30, 2011

Could you take a look at this site , it's official web site of Coraline animated movie , is there any related article or tutorial to do such navigation technique [URL] If not i will try to explain , layers of movieclips are ordered in z direction when you move your mouse in x & y they move based on depth like semi 3d side walk games

View 1 Replies

ActionScript 2.0 :: Constantly Moving Forward In The Direction It Faces?

Sep 3, 2009

I have recently been developing a sailing game and my boat turns with the arrow keys. On the turn i would like to keep the boat constantly moving forward in the direction it faces. What is the simplest way to do this?

(When i rotate the boat to the right/left, i want the boat to move that direction)

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.0 :: Make An Object Point In The Direction Of Another Object And Move Towards?

Aug 19, 2009

I'm still new to AS3, and I was wondering how to make an object point in the direction of another object and move towards it if they are a certain distance from one another. I haven't been able to find out how to do this from the Adobe devnet, so I thought I'd ask here.

View 1 Replies

ActionScript 3.0 :: Change Text On Stage From Movieclip Object?

Sep 9, 2009

I have created an accordion object and within the timeline of the accordion, I have a data element that I want to pass to a dynamic text field on the stage, but can't seem to do it.

View 2 Replies

Flash8 :: Remove OnEnterFrame Upon Frame Change?

Sep 21, 2009

I am using an AS to create a 3D Carousel gallery. I have button on the same page as the carousel gallery. My problem is that when I click on the button and the frame is changed, the carousel gallery stays on top of my other pages. Hos do I remove this? I have attached the AS code for your reference.

Code:
stop();
var numOfImages:Number = 5;

[code]......

View 2 Replies

Flex :: How To Change Box Components Direction

Sep 11, 2009

With mx:Box I can set the direction to be either "horizontal" or "vertical". I'd like to reverse the order of the components in the box though. For example:

Before:
|button1| |button2| |button3|
After:
|button3| |button2| |button1|

I've created a custom component that lives in a mx:Box and would like to do this in as simplest a way as possible.

View 1 Replies

Professional :: Change TLFTextField Direction At Runtime?

May 3, 2010

I create a TLFTextField object at design time and need to change its direction at runtime, how this could be possible? the following code did not work and simply ignored: var myText:TLFTextField = MyText;myText.textFlow.direction = "rtl";

View 12 Replies

ActionScript 3.0 :: Change Dropdown Direction Of Datefield?

Jul 15, 2010

I want to change the dropdown driection of the calender of  datefield.since my width of the application is small.and also i want to reduce the size of the datefield's calender control.

View 1 Replies

ActionScript 3 :: Conditionally Change Direction Of For Loop?

Nov 17, 2010

Is it possible to conditionally change the direction of a for loop in ActionScript?
Example:
for(if(condition){var x = 0; x<number; x++}else{var x=number; x>0; x--}){
//do something
}

View 3 Replies

ActionScript 2.0 :: Change The Direction Of A Movie Clip?

Feb 12, 2003

how I change the direction of a movie clip. And how to make it change in the same it's moving.

I have random movement code on the clip, I just want it to rotate, in the direction it goes.

View 2 Replies

ActionScript 2.0 :: Arrow Key Movement: Change Direction?

Mar 10, 2009

function moveStuff(){
if(Key.isDown(Key.DOWN)){
this._y += 5;
}
if(Key.isDown(Key.UP)){

[code]...

thats my basic Arrow key functions to move a movie clip lp_mc is my character in the left position so when left key is pressed it moves forwards but when right is presssed it moves backwards... i have a movieclip called rp_mc which is the same thing but facing the other way when right is pressed how do i swap the lp_mc for rp_mc so it changes direction?

View 3 Replies

ActionScript 3.0 :: Follow Cursor And Change Direction?

Mar 30, 2010

How could I get an object to follow the cursor and rotate to change direction as the cursor changes direction?

View 5 Replies

ActionScript 3.0 :: Animate By Increment And Then Change Direction?

Nov 15, 2011

i'm trying to animate a movie clip by subtracting from its y value and then when it reaches a negative value change direction and animate by adding to its y value until it's back to 0 and loop back and forth. what i have isn't working.

Code:
function Bodyloop(e:Event):void{
var direction:Boolean;
if(body.y > 0){

[Code].....

when it reaches -500 is jumps back and forth.

View 3 Replies

ActionScript 2.0 :: Calculate The Direction And Speed A Circle Has After Colliding With A Static (non-moving) Circle?

Mar 8, 2005

I'm developing a game atm, and I need some help on the mathematics/coding of colliding circles (and their change in x/y speed). What i need to know is how to calculate the direction and speed a circle has after colliding with a static (non-moving) circle. I know how to detect a collision between the two, but I'm not sure about the maths I need to give the circle the right speed and direction after the collision

If i do know how far away the two circle-points (in the middle of each) are to each other (in both x and y coords) would it be easy for me to find the new speed and direction of the large circle in the example above? I know that I somehow should use the angles to pretend the circle hits a flat "wall" (as it only hits one point), and then calculate the new speed/direction. My only problem is that I'm not sure how to decide the angle of this flat "wall" and how x and y speeds should change when colliding with a wall that is angled. Does anyone here have any insight, links or tips on how I can du this?

View 6 Replies







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