ActionScript 2.0 :: Circle MovieClips Moving Around Randomly On Stage

Aug 6, 2005

I want the final result to be a stage with a certain number of circle MC's moving around. I have made the circle MC, and added the AS so that it will start at a random point with a random color, then start moving around randomly. I want to make it so that In the beginning the document will duplicate the movie clip x amount of times, using a for loop. I want to then have all the new circles move around, and when two circles hit each other, they will dissappear, using the removeclip function. You can only use this on duplicated movieclips though, so how would i make all the circles duplicated? Is there a way to duplicate the original movieclip x amount of times then delete it? Or is there a way to remove the original after it is in a collision? Also I don't know how to do the collision detection. I am thinking of using a hittest, but would I just do it with a for loop? Is there a way so that if an MC hits any other MC?

View 3 Replies


Similar Posts:


ActionScript 3.0 :: Randomly Located MC's Moving To Center Stage?

Oct 27, 2011

I'm working on my first game engine with AS3 and I'm hitting my first real setback. The idea is that the player controls a centered "turret" on the screen and can't move. Enemies come from all 4 sides and move towards the player. I have all the enemies spawning, randomly, on the edges of the screen. However their movement is silly, because I've coded it like this:

Code:
if (x > 300)
{

[code]........

View 2 Replies

ActionScript 3.0 :: Send MovieClips Randomly Into The Stage?

Jun 22, 2009

I am generating movieClips outside of the stage I want to send them randomly into the stage in enter frame. Currently it looks like this, so they go like in all directions... How could I direct each of them randomly into the stage?

Code:
function timerEvent(e:TimerEvent):void {
var newObj:MyObj=new MyObj();
//this places them randomly outside of the stage

[Code].....

View 7 Replies

ActionScript 3.0 :: Randomly Generating MovieClips From The Library Onto The Stage?

Mar 10, 2012

I am trying to call objects from the library for a collection game.
 
Having major issues with the best way to assign the good objects and the bad objects to later update a score.
 
how i can first assign the movieClips from the library into a good and bad array and then after randomally fill the stage with them.

View 18 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

ActionScript 2.0 :: Add Scene An Action That Brings Movieclips From Library Randomly On Stage In Every 20 Seconds

Feb 3, 2007

i have an animation and some movie clips. i want to add my scene an action that brings movieclips from my library randomly on my stage in every 20 seconds. how can i do that? the movieclips should be on the stage so we can see them but they should be invisible until they called from the action.

View 6 Replies

Actionscript 3 :: Moving Movieclips Across The Stage On FrameEnter?

Nov 16, 2010

I'm making an image gallery and I want to have a bunch of thumbnails on the bottom of the screen that smoothly slide from side to side when the mouse moves.

I'm working with a custom class for the container (Tiles) and a custom class for the thumbnails (ImageIcon).

I have a ComboBox which allows users to to choose a gallery. When the user chooses a gallery, the following code is run and the thumbnails should reload. The problem here is that the icons appear on top of each other instead of side by side, also switching categories should remove the old one (see the first for loop), but it does not. Also, the Icons are not animating properly. The animation code is below as well. Right now, only one of the icons will move. The icons should move in order from side to side, stopping when the last few icons hit the edge of the screen, so that they don't get "lost" somewhere off to the side.

Gallery Loader Code:

public function loadCategory(xml:XML = null){
if(xml != null){
dp = new DataProvider(xml);

[Code]....

View 1 Replies

ActionScript 3.0 :: Instanced MovieClips Not Moving Across Stage

May 28, 2009

I'm making a screensaver where random characters in different positions and sizes walk/run across the screen. It seemed simple enough, and everything appears as they should. However, none of the Movieclips move forward on the stage. Here's the code on the first frame of the timeline, bolded lines are points of possible concern:

Code:
import flash.utils.*;
var timer:Timer=new Timer(5555);
timer.addEventListener(TimerEvent.TIMER, makeCharacter);
timer.start();
function makeCharacter(e:TimerEvent):void {
[Code] .....

And here's the code found in each movieclip:
var isOnStage:Boolean = true;
With no errors to go off of, I'm unsure how to proceed.

View 2 Replies

Randomly Move A Ball Inside A Bigger Circle?

May 26, 2009

I am trying to figure out a way to randomly move a ball inside a bigger circle. The motion has to be smooth and completely random. 

View 3 Replies

IDE :: Random Movement - Randomly Move A Ball Inside A Bigger Circle

May 26, 2009

I am trying to figure out a way to randomly move a ball inside a bigger circle. The motion has to be smooth and completely random.

View 1 Replies

ActionScript 2.0 :: Creating 10 Circle Movie Clips Dynamically And Giving Each Of Them A Width And Height Randomly?

Mar 8, 2005

i am creating 10 Circle movie clips dynamically and giving each of them a width and height random from 1 to 50, I am creating these CELLS to react to eachother in an environment that I create, well anyway everything is going good but this, SPEED

i would like the smallest cells to have a speed of .05 and from then on the larger the cell the smaller the speed, Every ... property i guess you could say... of the cell is proportional to it's width.

View 4 Replies

ActionScript 3.0 :: Circle Is Not Moving Smoothly?

Jun 1, 2011

I am trying to animate the circle to follow the cursor point. Its working fine, but when you move the cursor little faster the animation struck.

import flash.events.MouseEvent;import fl.transitions.Tween;import fl.transitions.*;import fl.transitions.easing.*;
var moveXY:Number;var speed:Number = 1;

[Code].....

View 8 Replies

Flash :: Moving A Circle Around A Point?

Aug 20, 2011

I have a circle (bounding circle) offset from the centre point of my entity and I'm looking on how to move that circle around the entity as it rotates so that it's always in the same spot of the character.For example,say I have a bounding circle for the front of a car, when the car turns, that bounding circle needs to turn to So I have two points: position which is the position of the entity's centre point and offset which is the offset of the circle from that position. This assumes an angle of 0.

So if my car is facing 0 degrees: position (150, 150) and offset (50, 0) then the bounding circle would be at 200, 150.Now if I rotated the car 90 degrees, the bounding circle should be at position 150, 200.This is what I have now:

var differenceX : Number = _centre.x - _offset.x;
var differenceY : Number = _centre.y - _offset.y;
var rotatedX : Number = differenceX * Math.cos(_angle);[code]........But it's giving me these long ovals and now a perfect circle.

View 3 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

IDE :: Number Of Images Moving Around Circle

Feb 28, 2010

Recently I came across a site showing a no. of images (probably 8 - 10) rotating around an invisible eclipse. When we put mouse-pointer over any of the images it's tip shows a linked site's name and if clicked that particular site opens up. Only one image is displayed perfectly which is on the top while rotating, while other remain blurred out not clickable. How to create such effect as I need to get it implemented.

View 1 Replies

ActionScript 2.0 :: Moving Mc's Randomly?

Mar 13, 2003

I want to have a few movie clips moving randomly over my flashsite. They will look bugs. And I want them to move in the direction the head is pointing.I have tried the random movement tutorial here on Kirupa but can't get the mc to rotate in the direction it's moving.

View 14 Replies

ActionScript 3.0 :: Keep A Moving Object Inside A Circle?

Apr 24, 2010

I have a circle drawn on the screen, wherein I add a moving object. I want it to keep inside. My strategy is to calculate the circle's radius and compare it with the distance the moving object is off its center. I beleive it's the proper solution. However, I'm having a problem with letting Flash know when the running guy should stop, so he doesn't leave the circle and ruin all the fun. Here's the code I'm using (it's not working of course):

function moveTheCreaturesRightwards(event:Event)
{
if(maleMovingRight == true)
{

[Code]....

The line: rayMale.width = maleRadius.width; was added when nothing else had seemed to be working

View 3 Replies

ActionScript 2.0 :: Bounding A Randomly Moving MC?

Apr 26, 2010

I am creating a banner with a "moving target", but the target keeps moving under the copy text of the banner, making it illegible.here is my random movement code (Swiped from kirupa if I recall ) :

//special thanks to Suprabeener for the code
function getdistance(x, y, x1, y1) {
var run, rise;

[code].....

View 0 Replies

ActionScript 2.0 :: Randomly Moving Pictures Over Each Other?

Aug 19, 2003

I use Flash 5

I went to this (click HERE) site. After a moment, it takes you to the main site.

The top banner is moving randomly over 3 or 4 pictures.

View 6 Replies

Flash CS5 - Moving Object Around In Circle One Degree At A Time

Aug 2, 2011

I have an object called point that I can move around the screen with my mouse. This object has a vector mapped through it (_v1) using the center of the stage and "point"s x,y location in order to draw the vector (note all of this is working fine). My problem is occurring when I set up was a button that simply sets a value to true if you press it. The idea behind this button is that when pressed, whatever location "point" is at, it will move 1 degree clockwise in a circle around the center of the stage (this is all happening in the frameHandler so I can keep clicking the button to make it continue around the stage).

The code I am using is based in an if statement listed below:
if(clockwisePressed) {
var v1angle:Number = _v1.angle;
v1angle++; //increase the angle by 1 degree
if(v1angle>180) {
v1angle -= 360; }
[Code] .....

So what is happening here is that clockwisePressed has been set to true so this fires off. My vector (_v1) is set up to tell me the angle (already converted from radians to degrees) but it's a read-only value. So I assign it (_v1.angle) to v1angle so I can mess with it and increase it by 1 so I'm moving clockwise around the center of the stage. Then I just check to make sure that it falls into a range between -180 and 180 (if I trace _v1.angle around the stage, 0 degrees is to the left, 90 degrees is straight up, 180 degrees is to the right, and -90 is straight down). Now using the formula I derived from this thread but converted to work with 0 degrees pointing to the left and the value for Y going up the further down the stage you go, I came up with

x = centerX - radius * cos(angle)
y = centerY - radius * sin(angle)

Now when I make a sample chart on paper and use these values on my calculator, this works like a charm. If I plug in an angle, the radius, and center I get a point right on my circle I draw on a sheet of graph paper. However, when I actually try this in flash, the "point" jumps all over the stage. (Note that _v1.m is just the magnitude of the vector between the center of the stage and "point" which is the same as the radius). So I trace everything and the values for cos and sin don't seem to be coming out right. For example, if my angle is -1.9581 and I take the cos of that on my calculator I get something along the lines of 0.9994 but flash traces Math.cos(angle) to be -0.3777. Isn't using Math.cos(-1.9581) the same as putting -1.9581 into your calculator and hitting cos?

Below is the corrected code that works:
if(clockwisePressed) {
var v1RadAngle:Number = Math.atan2(_v1.vy, _v1.vx); //get angle in radians
v1RadAngle += 0.0174; //increase the angle by ~1 degree more or less
//Now just move the crosshair and get it ready to be redrawn
point.x = centerX - _v1.m * Math.cos(v1RadAngle); //_v1.m = radius
point.y = centerY - _v1.m * Math.sin(v1RadAngle);
clockwisePressed = false; //remove button pressed boolean
}

View 1 Replies

ActionScript 2.0 :: Circle Stop Moving At Obstacle (Square)

Jul 10, 2009

I have a circle and a big square. The circle can be moved using the keyboard. I want the square to act as an obstacle, so the circle cannot be moved into it and the circle stops when it hits it, just like a if i were to try to walk into a building. Is there an easy way to do this?

View 7 Replies

ActionScript 3.0 :: Collisions Between Moving Circle And Rectangle Object

Oct 9, 2010

In AS3 is there an easy way for collisions to take place between a moving circle and a rectangle object. A moving circle has a direction and you need to know how it collides with an object rather than knowing it just hits. In .net you use a points test where you test several points around a circle to see what hits an object and then you can work out what direction it will bounce off.

View 2 Replies

ActionScript 2.0 :: Flash CS3 - Bound A Randomly Moving MC?

Apr 26, 2010

I am creating a banner with a "moving target", but the target keeps moving under the copy text of the banner, making it illegible.

here is my random movement code (Swiped from kirupa if I recall ) :

//special thanks to Suprabeener for the code
function getdistance(x, y, x1, y1) {
var run, rise;
run = x1-x;

[code]....

I have tried modifying the " width = 300; height = 180;" line, but it does not seem to be changing much, if anything. I am trying to bound the random movement to the bottom 180 pixels of the composition.

View 2 Replies

ActionScript 2.0 :: Stop Randomly Moving A Moveclip?

Nov 10, 2003

lets jsut say like were randomly moving a moveclip around how do i click on it and stop it?

View 3 Replies

ActionScript 2.0 :: Dynamically Moving An Object Along A Circle Motion Guide

Jul 5, 2005

I'm trying to move an object along circlular motion guide dynamically using two buttons -- a left button, when pressed down, will move the object counter clockwise, and the right button clockwise.

View 2 Replies

ActionScript 2.0 :: Moving Circle To X Position When User Click On Square

Jun 18, 2008

I have a circle and a square on the stage. When you click on the square the circle will go to "circle._x = 300" when the circle is at 300 I want to make it when you click on the square the circle will go "circle._x = 45"

Code:
moveCircle = function () {
circle._x = 300;
if (circle._x >= 300) {
circle._x = 45;
}} square.onRelease = function() {
moveCircle();
trace(circle._x + "is the position of the circle");
}

View 5 Replies

Actionscript :: Random - Randomly Drop From Moving Plane MC?

May 3, 2011

I wasn't quite sure how to describe my problem in the subject. I have a plane MC and a crate MC. The plane only flies along the y axis from the bottom of the screen to top. Along the way I want it to randomly drop the crate MC. My code is below. The problem is that the crates spontaneously keep spawning and not near the plane.

function movePlane():void
{
var tempY:Number;

[code].....

View 1 Replies

Actionscript 3 :: Box To Circle Collision - Continue Moving And Never Collide When Swapping Values Around

Feb 24, 2012

I'm trying to implement a aabb to circle collision.

[Code]...

Somehow the collision does work as expected. Either they never move at all and "collided" was traced, or they'll continue moving and never collide when I tried swapping values around. Is there something i'm missing in my logic??? My box-box and circle-circle collision are working fine.

View 2 Replies

Actionscript 3 :: Moving Randomly-generated Object Based On Its Rotation

Oct 26, 2011

Making a ship game because I am incredibly original.. With that aside, I have a problem. I have a function to fire bullets from my ship based on its rotation which works.. it uses this code on creation: ember ho jis ny mmujhe block kia hai

[Code]...

The above code is in my Ship class so I can easily make the bullets achieve the correct rotation. And to continually update its position, in the bullet's class:

x += Math.cos(rotation / 180 * Math.PI) * speed;
y += Math.sin(rotation / 180 * Math.PI) * speed;

So that all works well. But I have another class, EnemyBullet, which randomly generates and uses similar code to set its direction and movement. In my ship class:

[Code]...

I gather that the rotation is therefore always horizontal, but can't for the life of me see why? Can anyone give me an answer? Assuming it's simple enough because the code I used to setup the rotation is the same working code I have used to turn a movieclip towards the mouse..

View 1 Replies

ActionScript 2.0 :: Keeping Randomly Moving Elements Inside Frame?

May 30, 2005

I have gone through the tutorial on this site regarding random movement. But I need it to be kept in a frame. This is the code(from this site)

Code:
function getdistance(x, y, x1, y1) {
var run, rise;
run = x1-x;
rise = y1-y;
return (_root.hyp(run, rise));
} function hyp(a, b) {
[Code] .....

Lets say I make an physical border for the element. A "box" 200x100 and this box is centered. How do I keep my random moved element inside this "box" or frame you may call it.

View 1 Replies







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