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.
how to randomly animate circles moving around inside a bigger circles? the small circles will have a collision effect on each other and on rollover of each individual circle, the name of it will come out in the bottom.. so the big circle will act as a wall preventing them from coming out..
I have 2 container MovieClips (mc1, mc2), each of them has a separate x,y, rotation. I want to take a child from mc1 and addChild() it to mc2 while keeping the same x, y, and rotation on the screen so you see the added child mc as if it didnt change position or rotation, just moved to the other MC.
I am encountering a strange problem. I am trying to generate a matrix with value of elements either 1 or 0 (filled randomly). I am storing the values into a 2D array. This is code on the first frame. Everything seems to be working fine.
I have a list of countries that are in an xml document. I was wondering if here was a way to randomly load ten of these and place them on the stage in random places. I want to get the effect of this intro: [URL]. (not the one with the black background)
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.
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;
Currently the problem is that the label actually do not leave borders of the first canvas (I see scrollbars instead of it).I think this is related to globalToLocal conversion problems, but do not understand how to use it.Also another question is how to animate the movement corretly, because move function performs movement without any visible action.
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.
is there any way I can link a button inside a MC on frame1 to a frame inside another MC that is located on another frame.Ive got 2 frames in total. On the first frame Ive got an Mc and inside this one Ive got a button that needs to be linked to frame number 50 which is inside a MC located on frame number 2.
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.
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:
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?
I need to add a small amount of physics to some moving elements.I found flade, but it looks like overkill for what I'm looking for. Also, all the examples are side-views with gravity.
Basicaly, I have a top-down view, and have square shapes that I want to be able to slide along a wall when they hit it at an angle. They don't even need to rotate when they make impact. I tried comming up with my own solution, based on the relative rotations and quarants they collide on, but it is very clunky. I can't help but feel there is a better way to do this. Heck, there might even be some usefull ActionScript function that I don't know about.
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..
I have a bunch of dots moving randomly on the screen. They are all copied and pasted versions of one MC with some script attached.Over the top of them is a giant invisible button. When I click the button (anywhere on thescreen) a VISIBLE button appears. When I click again (anywhere onthe screen) I want all the randomly moving dots to move towards the VISIBLE button.
I have a sub menu with two movie clip buttons, let's call them mc1 and mc2. They both have a MOUSE_OVER event and a MOUSE_OUT event that work correctly. I'm trying to get them so that if mc1 is clicked then it will stay at the "over" frame and if mc2 is clicked mc1 will revert back to the "out" frame while the second will stay on its "over" frame.What seems to be happening in my code is that the MOUSE_OUT event is overriding the MOUSE_DOWN event. So, when I take the mouse off after I've clicked mc1 the over state goes away.I've tried many of my own failed ideas and search the internet for hours trying to figure this out.Here's my code thus far:
I making an animation for a preloader.In the animation, a 'line' draws a picuture.There are many lines,and I would like a mask to follow the lines so that it appears that they are being drawn.There are so many that it would be difficult to do this manually by moving a mask frame by frame with motion tweens.
What are the inbuilt functions available in flex,actionscript that I can use to find a node with a specific name inside xml variable and what functions could help me manipulate it? Something like Xquery in SQL! I dont want to use for loop everytime I want to manipulate a xml variable. For example, if I want to "cut" node inside this xml and add another attribute to it named enabled pro grammatically. Or how could I find "Find Next" node and delete it?
I have 10 images in 10 frames ( 1 image per frame ). So I'm trying to make the frame to go to the next one when the mouse is moved to the right, and make the frame to go to the prev one when the mouse is moved to the left.
If myXML.person.length() gives me the number of person nodes in my XML file, then how do I count the number of elements inside each person node if each one has a different name (such as address,zip, etc.)?
From one main movie, I'm calling a movie, put it into a target (everything goes fine here), then when I call the movie everithing goes fine but the elements inside the movie don't respond I'll tell you how it works. The loaded movie, has a movie clip that plays a few others clips in the main time line. When this movie get loaded into the main movie I mentioned above these few clips don't work, I see the movie getting loaded but these few clips don't work.
My site in progress has some large graphical buttons that uses sIFR to display their headings. The structure looks like this:
[Code]...
I'm replacing the <h2> element with sIFR 3, revision 436. Everything works great until I activate sIFR. The font is replaced just fine, but the heading can no longer be clicked even though the rest of the button can. I tried to add another <a> inside the <h2> heading but that broke the whole layout since multiple <a> tags can't be nested. Is there a "correct" way to fix this or should I work around it with something ugly like a z-indexed clickable blank.gif on top of the whole thing? Or is there something else wrong that I've missed?
Isn't there a way to loop over each image in the hgroup and add the eventhandler? Something like this:
[code]...
My teacher told me this isn't possible but in case of 10+ images, I can't imagine doing it for every image separately. There has to be a better way to do this, no?
I've been using this code to try and stop a main movie clip and all of the movie clips inside it. My problem is that this code only stops the main movie "elements" but none of the nested clips, can anyone spot a glaring mistake.
function stopAllClips(clip) { clip.stop(); for (var i in clip) { if (typeof clip[i] == "elements") { if (clip[i] != clip) { stopAllClips(clip[i]); [Code] .....