Random Move With Dragable In Bouded Area
respected sir i m doing hard work since 6 months,u r god 4 me ,if u help me..plzzzMy prb : i want make a object (random movement with dragable in bounded area like a farm hause.----------------------Bounded movementonEnterFrame = function() {with (_root.yash){x1 = _x;y1 = _y;}var shapeFlag = true;if (_root.dragArea.hitTest(x1,y1,true)) {if (dragArea._x < yash._x-20){yash._x = dragArea._x+(yash._x-100)} elseif (dragArea._x > yash._x+20){yash._x = dragArea._x-(yash._x+100)} elseif (dragArea._y < yash._y+20){yash._y = dragArea._y+(yash._y-100)}elseif (dragArea._y > yash._y+20){yash._y = dragArea._y-(yash._y+100)}}}----------------random movement and dragableonClipEvent (load) {//data you may want to changewidth = 550;height = 400;speed = Math.round(Math.random()*2)+1;//initial positionsx = Math.random()*width;y = Math.random()*height;this._x = x;this._y = y;x_new = Math.random()*width;y_new = Math.random()*height;}onClipEvent (enterFrame) {//x movementif (x_new>this._x) {sign_x = 1;} else {sign_x = -1;}dx = Math.abs(x_new-this._x);if ((dx>speed) || (dx<-speed)) {this._x += sign_x*speed;} else {x_new = Math.random()*width;}//y movementif (y_new>this._y) {sign_y = 1;} else {sign_y = -1;}dy = Math.abs(y_new-this._y);if ((dy>speed) || (dy<-speed)) {this._y += sign_y*speed;} else {y_new = Math.random()*height;}}onClipEvent(enterFrame){if(drag){_x = _parent._xmouse;_y= _parent._ymouse;}}
Adobe > Flash General Discussion
Posted on: 09/09/2008 11:00:24 AM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Random Dragable Movement In Bounded Area
Bounded movement
onEnterFrame = function() {
with (_root.yash){
x1 = _x;
y1 = _y;}
var shapeFlag = true;
if (_root.dragArea.hitTest(x1,y1,true)) {
if (dragArea._x < yash._x-20){
yash._x = dragArea._x+(yash._x-100)
} else
if (dragArea._x > yash._x+20){
yash._x = dragArea._x-(yash._x+100)
} else
if (dragArea._y < yash._y+20){
yash._y = dragArea._y+(yash._y-100)
}else
if (dragArea._y > yash._y+20){
yash._y = dragArea._y-(yash._y+100)
}
}
}
----------------random movement and dragable
onClipEvent (load) {
//data you may want to change
width = 550;
height = 400;
speed = Math.round(Math.random()*2)+1;
//initial positions
x = Math.random()*width;
y = Math.random()*height;
this._x = x;
this._y = y;
x_new = Math.random()*width;
y_new = Math.random()*height;
}
onClipEvent (enterFrame) {
//x movement
if (x_new>this._x) {
sign_x = 1;
} else {
sign_x = -1;
}
dx = Math.abs(x_new-this._x);
if ((dx>speed) || (dx<-speed)) {
this._x += sign_x*speed;
} else {
x_new = Math.random()*width;
}
//y movement
if (y_new>this._y) {
sign_y = 1;
} else {
sign_y = -1;
}
dy = Math.abs(y_new-this._y);
if ((dy>speed) || (dy<-speed)) {
this._y += sign_y*speed;
} else {
y_new = Math.random()*height;
}
}
onClipEvent(enterFrame){
if(drag){
_x = _parent._xmouse;
_y= _parent._ymouse;
}
}
Dragable Selection Area
Hi
I am a programmer who is new to Flash, but working with a graphic designer who has basic Flash skills.
We are trying to make a dragable selection area in flash5, mouse down defines the start point, as the user drags the mouse a selection box extends from the starting point to the current mouse position. on mouse up I need to have the x,y of the start point and the x,y of the end point.
Can anyone please help us?
Nick
Dragable Area & Dynamic Text Conflict
Dragable Menu Moves around the screen, But dynamic text on the same script does not move
does any one have any code
on (press) {
setProperty("/MC_dragarea", _alpha, "60");
startDrag("/MC_dragarea" && "/DynamicText");
}
on (release) {
setProperty(("/MC_dragarea") && ("/DynamicText"), _alpha, "100");
stopDrag();
}
Please help PLEASE PLEASE PLEASE
Only Move When Mouse Is Over Certain Area?
Hi,
I am using this photo slider in a site that I am making: http://www.flashkit.com/movies/Inter...8455/index.php
and it works great, except for one thing: It scrolls to the left or right when you move your mouse around on any part of the page. I would like the menu to scroll only when the mouse is over the area where the buttons are. Can someone please help me modify that FLA to do that?
Thanks!
Move To Specific Area Of MC OnRelease?
Hi, I am new to actionscripting, so please be gentle!
On my stage, I have a movie clip called "main." Inside "main," I have 4 other MC symbols (named "green" "red" "blue" and "orange").
I have the MC's placed so that only the "green" MC is showing in the center of the stage. The other symbols are off the stage, out of view.
On the main stage, I also have a navbar, with 4 buttons (named "green_btn" "red_btn" "blue_btn" and "orange_button").
What I want to do is: When you click on "blue_btn" the MCs will rotate clockwise so that "blue" is showing in the center of the stage. When you click on "red_btn," the MCs will rotate clockwise so that "red" is showing in the center of the stage, and so on.
Does that make sense?? I will include an .FLA of the setup.
I don't know how to do this with actionscript. I can only do it with tweening, and that only works if I click the buttons in order. Please help. Thank you in advance!
Object Move To The Clicked Area
Hi all...
I need ur help. I want to make a ball which is , the ball will move to wherever the point I click in the stage. I have tried many times but failed.
thnx
::: Sliding Menu To Move Within Certain Area:::
Hi all,
With the help of u guys, im ALMOST there with this lovely sliding menu! I have attached an example of that im working on (please ignore the overlapping button issue). Please help if u can - how can I get the buttons to move ONLY within the shaded area. Does anyone know what code is needed, becuase i really have no clue!
Disallowing Object To Move Out Of An Area...
Since I tried three or more different combinations of searching via google including this topic's title: Disallowing a flash object to move out of an area; I came here to ask you guys.
If I have a movement dealie like this tutorial shows how would I stop the movement of the object when it reaches a certain point? Specifically: How do I make it so that the edge of the object being moved doesn't move out of a specified area?
Sliding Menu To Move Within Certain Area, Please Help
have attached an example of that im working on (please ignore the overlapping button issue). Please help if u can - how can I get the buttons to move ONLY within the shaded area. Does anyone know what code is needed, becuase i really have no clue! I have even used coordinates to allocate the 'boundary' but it just doesnt work, please help me. your help would be so much appreciated!
Getting An Object To Move To An Area After Clicking A Button?
Hello
I have a layout which includes an animated character, I also have 6 buttons vertically on the left side of the layout
What I want to happen, and what I cant figure out, is how to get the animated character to move to the selected button after it is pushed, I need the character to move from button to button using actionscript and not tweens.
I am extremely confused
Any help would be great.
Thanks alot.
Can't Move Stage Work Area With Hand Tool
I feel like a goof posting this simple question, but I can't understand this...
When you create a new doc in flash, it creates a work area that you can move around with the hand tool (or by pressing the spacebar).
When I resize the work area (stage), I cannot move it any longer. It is always locked to the upper left corner.
Is there a way to unlock this?
Thanks.
Can I Move The Stage To The Left Side Of The Flash MX Working Area?
Hello,
Is that possible to move the Stage to the beginning of the left side of the working area in Flash MX? I have a very long movie clip(4200px wide)which actually starts out the stage of the right side. I cannot include all content because the of stage area allows me to use something not longer than 2880px wide. I am wondering if there are any settings for that or I can move the stage itself to the left side since I am not using that side.
Any ideas are highly appreciated.
Thank you in advance!
[CS4 AS2] Random X And Y, Within A Certain Area
Hey peoples
Im looking for some help with my actionscript. Ive just recently been trying out some stuff and I currently have an image spawning at a random location on stage and changing to a random position every 2 seconds or so.
Now because my registration point is set to the middle it sometimes goes to a position where i cant see the top,left etc of the image. Now i want to restrict the x and y values of my random x-y so it always shows the whole image.
My random code now pretty much looks like this. This code sits within a function with a timer etc that all works well its just about restricting it atm
Code:
stagewidth=550;
stageheight=400;
image._x = Math.random()*stagewidth;
image._y = Math.random()*stageheight;
Now i want to like say restrict my random x and y of my image to be for example say x between 40-500 and my y values between 30-380.
Im kind of clueless here being new to actionscript. Any help much appreciated.
Greetings Jinx
Random Tweening Within A Certain Area?
hey, i want to have a masked tween of a bar that moves only restrained between 2 x points(cause i want it to be within the mask), but in random places in between there tweening from 1 random point to another and keep tweening to random points within the mask
how can i do that?
Random Placing Mc's Around Area
Hello,
I am working on a movie where I would like to have movieclips randomly placed around a middle area.
I've got it working so far, that mc's are placed left or right from the middle area, but above and below there is still a 'gap'.
Could anybody tell me how I can 'fill' these gaps as well?
Thank you.
Regards,
Jorrit
Code:
function placeMC() {
numberOfMCs = XML_mcsDoc.firstChild.childNodes.length;
for (var i = 0; i < numberOfMCs; i++) {
this.attachMovie("mcTemplate", "mc" + i, i);
this["mc" + i]._x = Math.floor(Math.random() * 380) + 10;
while((this["mc" + i]._x > 106) && (this["mc" + i]._x < 294)) {
this["mc" + i]._x = Math.floor(Math.random() * 380) + 10;
}
this["mc" + i]._y = Math.floor(Math.random() * 330) + 60;
}
}
RANDOM Position, Within A Specified Area
I've tried to position 9 MCs on the stage randomly using this code on each MC:
Code:
onClipEvent (load) {
origY = this._y;
this._y = Math.random()*250;
}
This works fine, but i want to create restrictions so that the MCs fall within specific constraints, ie a certain height from the top and bottom of the screen.
Eventually once i get this code to work i would also like to make sure that when they are positioned on the stage there is no overlapping.
Each MC has been exported with AS linkage by calling it word1, word2, word3, etc... all the way up to word 9. so i am aware of the fact that i can use a for loop but sure how to get it working.
SOooooooo.... can anyone help me
1)randomly position MCs but with constraints?
2) prevent them from overlapping?
Oh and one more thing.... they must only be positioned along the y axis because i have already placed them on the stage & they are PERFECTLY aligned along the X axis!!
PLEASE HELP ME!!
Random Movement Around Area
In the middle of my stage I have a circle. I have items outside that circle that are randomly moving. I don't want these items to go inside the cirlce. How can I prevent this from happening?
Thank you.
Random Movement In An Odd Shaped Area.
ok.. ive looked around, but cant find anything even remotely like i need, and have tried to adapt code to what i need, but cant do it.. anyone know how i can have several mc's move randomly, but within a certain space.. not like a rectangle.. its more odd shaped..
what im doing is i would like to have boats randomly move around in the ocean, but the ocean is a cragly and wierd shaped.
can i do a hitTest or something? i have no idea how to procede. thanks
-frank
Random Position Within A Fixed Area
Hi all,
I need to set the _x and _y properties of a movie clip which is in the form of a speech bubble randomly.
This I do using the script:
Code:
setProperty ("bubble", _x, random (375 - 145 + 1) + 145);
setProperty ("bubble", _y, random (225 - 75 + 1) + 75);
The dimension of the stage is 550 x 375
However how do I make sure that the movie clips edges DO NOT overlap or go beyond a frame which is 420 x 290 pixels.
A detailed explanation is appreciated...commented if possible
Thank you
Random Positioning With An Excluded Area
Hi all...
When my movie loads I want to position randomly on stage a bunch of MCs. However up in the top left I have a logo etc that I don't want the MCs to cover.
So my question...is there a way to postion the MCs randomly but exclude a rectangle of about 100px X 400px in the top left?
All help welcome. Cheers!!!
How To Calculate The Area Of A Random Polygon
hello people,
I need to calculate the area of a random polygon/shape. by random, I mean the actually geometry of the shape, not its bounding box. I have looked around for leads but no luck. any ideas or tips on how to nail this problem?
On way I thought about is to triangulate the shape (break it down to triages) then find the sum of the areas of all the triangles. (still experimenting with this).
cheers
Random Movement Within A Limited Area
Hi, I'm trying to get an object to move randomly within a certain area. It almost works, but for some reason, the object seems to favor the upper left corner. My math isn't the best in the world, but I can't really figure out what's off. I imagine it'll be something embarassingly simple.
If anyone has any ideas, I'd love to hear them.
-Saito
Random Movement In Defined Area
I want to have about 15 verticle lines moving randomly along the X axis
Now I have modified the Kirupa random movement tutorial to this code:
ActionScript Code:
onClipEvent (load){//data you may want to change width = 300;speed = Math.round(Math.random()*4)+1; //initial positions x = this._x=Math.random()*width;x_new = Math.random()*width;} onClipEvent (enterFrame) { //x movement if (x_new>this._x) { sign_x = 1; } else { sign_x = -1;} dx = Math.abs(x_new-this._x); if ((dx>speed) || (dx<-speed)) { this._x += sign_x*speed; } else { x_new = Math.random()*width;} }
But I noticed the starting point of the verticle line is always in the same spot and is not confined to where I want it positioned....How would I define an exact stage for it be contained in?
Also it goes everywhere on the stage just not what is defined as the width in the begining of the code,
-Case
Random Fall Items Within A Certain Area...
I am trying to make a game where there are random fall items ( cheese, mouse traps and things like that) but i want them to just fall inside a certain area. I created a movie clip the size of the area I want them to fall inside, but i have no idea where to start on the AS to get the to fall inside it...pls help
Thanx in advance
Random Movement In Defined Area
I want to have about 15 verticle lines moving randomly along the X axis
Now I have modified the Kirupa random movement tutorial to this code:
ActionScript Code:
onClipEvent (load){//data you may want to change width = 300;speed = Math.round(Math.random()*4)+1; //initial positions x = this._x=Math.random()*width;x_new = Math.random()*width;} onClipEvent (enterFrame) { //x movement if (x_new>this._x) { sign_x = 1; } else { sign_x = -1;} dx = Math.abs(x_new-this._x); if ((dx>speed) || (dx<-speed)) { this._x += sign_x*speed; } else { x_new = Math.random()*width;} }
But I noticed the starting point of the verticle line is always in the same spot and is not confined to where I want it positioned....How would I define an exact stage for it be contained in?
Also it goes everywhere on the stage just not what is defined as the width in the begining of the code,
-Case
Controlling Area Of Random Movement In Flash MX
Me again. I managed to get most of the issues I had before resolved, but I have another. First, my in progress site (yes, I know there are many stupid parts. Please don't comment on them.)
http://www.freewebs.com/hlgladiator/index.html
Alright. So, the problem I'm working on at the moment is those little red blood-cell like things that float around the screen. Thing is, they go ALL OVER the entire movie. I actually created them as an entirely seperate movie and imported them, but for some reason they didn't come in properly, and I ended up copy and pasting them, then adding the actionscript myself. That, however, is slightly beside the point. The problem is, I just want them to float around in a 100x200 (px) area, specifically the white area below the buttons. Again, as you can see, they're all over the place.
Actionscript used (which I yanked from a tutorial site):
// special thanks to Suprabeener for the 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) {
return (Math.sqrt(a*a+b*b));
}
MovieClip.prototype.reset = function() {
// specify the width and height of the movie
width = 100;
height = 200;
// -------------------
var dist, norm;
this.x = this._x;
this.y = this._y;
this.speed = Math.random()*6+2;
this.targx = Math.random()*width;
this.targy = Math.random()*height;
dist = _root.getdistance(this.x, this.y, this.targx, this.targy);
norm = this.speed/dist;
this.diffx = (this.targx-this.x)*norm;
this.diffy = (this.targy-this.y)*norm;
};
MovieClip.prototype.move = function() {
if (_root.getdistance(this.x, this.y, this.targx, this.targy)>this.speed) {
this.x += this.diffx;
this.y += this.diffy;
} else {
this.x = this.targx;
this.y = this.targy;
if (!this.t) {
this.t = getTimer();
}
if (getTimer()-this.t>2000) {
this.reset();
this.t = 0;
}
}
this._x = this.x;
this._y = this.y;
};
That's in the layer but on nothing in specific. This actionscripting is on the actual red things:
onClipEvent (enterFrame) {
move();
}
Help, anyone?
Thanks in advance.
-Glad
Finding A Random Position Outside Of An Defined Area?
Hey guys, I could use a little help with some math.
Basically I am trying to find a random position to place a movieclip outside of my stage, but within a certain bounds.
I want it to be so the position is completely random and can have either a positive or negative value, and of course it must be a position with either the x or y out side of the stage, so that the movieclip is completely off stage, but inside the outter bounds.
I've tried to hack around, but could not think of a very clean solution that retained complete randomness within the defined area.
I also do not want to have to run a loop until I randomly come up with a set of points where atleast one of the dimension is outside the stage.
any help is much appreciated.
Extract Bounding Area Of MC With Random Content
I have a main movieclip with a bunch of 'flies'-MCs flying around randomly in it. If the main mc is placed in main timeline, is there a way to retrieve the actually covered area of the main mc at a certain moment... imagine a snapshot bounding box of all flies at that specific moment.
tia
P.
How To Move Random
Hi every one
i created flying bird movie, this need to be move randomly
on stage like bird moving here and there what action i need to give as fream loaded.
thanks for your replays
naushad
A Mc With Random _x Move..
i want to know how a MC can move in random left .or right.....
just like this game http://www.7scolor.com/games.swf
the boy on the roof .... move in random ....and drop the water...
i want to know how the boy move .???
i think its difficult for me to write the hole AS in the boy
can someone help me // ???????
thanks........
Random X Move
Hi
I am working on a banner where I am moving some transparent shapes horizontally-nothing new
Here I have script that just move one clip.
ActionScript Code:
mmcXmove = 300
speed = 5
mmcXmove2 = 0
_root.mc1._x = 0
var moveIN:Boolean =true;
//
this.onEnterFrame = function(){
if((_root.mc1._x<mmcXmove)&&(moveIN==true)){
mc1._x += (mmcXmove-mc1._x)/speed}
else if (moveIN!=true){mc1._x -= (mmcXmove-mc1._x)/speed}
//
if(Math.round(mc1._x) >=mmcXmove){moveIN=false}
if(Math.round(mc1._x) <=0){moveIN=true}
}
How can I duplicate it and movie multiple clip hrizontally and randomly.
Thanks
Random Placement Of Objects On A Specified / Unique Shaped Area
Hi , Wondering if anyone can help. Basically I saw a humerous game where randomly placed pimples grew on a face, and the player had to squeeze them against a timer.
I'm trying to simulate a similar idea, but I can't work out how to make the objects appear only in the area of the face. sure, I can do it on a rectangle or square. In my mind I am thinking that I must use some kind of hit test function to check if it lands on the face shaped area.. But yeah my syntax is from another planet. Any ideas. Thanks. Probably stupendously easy.
HOW? Move In Random Direction....
First, check this out:
http://www.rightsys.com/temp/dots.htm
These are just one movie clip, duplicated a lot of times, with random scale, color, _alpha, and rotation.
I would like to know how to make these MCs start moving in the direction that they are pointing, until they fade away...
Anyone know how to do this?
the rotation for each MC is in a variable, but I'm not sure how to find the direction each MC is pointing, and how to change the X and Y values to accomplish this correctly.
THANKS!!
How To Random Move With Easing?
ok. here is what im trying to do.
i want to make a bunch of objects move to random positions on the screen with easing when i click a button. im pretty stumped on this. if been foolin around for awile. and i don't think it should be to hard. but im new to this stuff so im not having much sucess. this is what i have...
on (release){
speed = 5;
endX = 300;
endY = 500;
t = 1
if ( t > 0) {
move_mc._x += (endX-_x)/speed;
move_mc._y += (endY-_y)/speed;
}
}
now i might be waaay off base.. probally am for sure. i figure for the random locations i can just use a random * a constant. but then the problem of getting more than one object to move without a move for each object. this moves the object to the location but it does it instantly. i think its something with the loop... i dunno im a total noob to this so that piece of code iwll probally make someone who knows how to do this laugh alot. but nonetheless help please.
How Can An Object Move "inside A Constraint Area" Relative To The Mouse Movement?
hi,
I'm so glad that this site exists!
I know you have posted a tutorial to teach us how to make an object move relatively to the mouse movement in Flash 5.
However, I tried the code with Flash MX 2004. It did not move so smoothly as the example demonstrated. I am wondering if the code should be slightly changed in the latest version of actionscript?
so, here's my real question: could you please teach me how to write the ActionScript in order to make an object move "inside a constraint area" relative to the mouse movement? For example, how to make an eyeball move inside the eye orbit following the mouse movement?
Thank you for answering my question~!!!
Sincerely,
Hedi
Move To A Random Target Location
hi!! i'm using flash five and i need some help with making the following happen.
a movie clips actions:
loop
pick a random number with math.random for x
pick a random number with math.random for y
loop:
head towards x and y one pixel at a time
until -> has reached x and y, then
loop
please excuse my crappy psuedo code, hope someone can help!
Random Move An Object In The Movie
Hey guys!
One more newbie came here for a question...
I have a movie where I want a box to be displayed randomly anywhere at the movie. My movie is 720x284 wide and if it's possible I want it to move at the center or the right side of the movie. I also used some actionscript from here, to achieve auto alpha blending and works like a charm.
Here's the test .fla:
Random Move...orient To Path?
How do I make my MC point in the direction its moving?
This is the code
code:
acceleration = 10;
newpos = function () { ranx = Math.round((Math.random()*250));rany = Math.round((Math.random()*250));};
newpos();
this.onEnterFrame = function() {
this._x += ((ranx-this._x)/acceleration);
this._y += ((rany-this._y)/acceleration);
if (Math.round(this._x) == ranx || Math.round(this._y) == rany) {
newpos();
}
};
EDIT: I added [ as ] tags to your code for readability. See the forum guidelines. - jbum
[f8] Random Mc's To Move To Somewhere Else On Button Rollover
Hi. I used the code from kirupa to make my movieclips move randomly.
Code:
//special thanks to Suprabeener for the 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) {
return (Math.sqrt(a*a+b*b));
}
MovieClip.prototype.reset = function() {
//specify the width and height of the movie
width = 1000;
height = 700;
//-------------------
var dist, norm;
this.x = this._x;
this.y = this._y;
this.speed = Math.random()*1;
this.targx = Math.random()*width;
this.targy = Math.random()*height;
dist = _root.getdistance(this.x, this.y, this.targx, this.targy);
norm = this.speed/dist;
this.diffx = (this.targx-this.x)*norm;
this.diffy = (this.targy-this.y)*norm;
};
MovieClip.prototype.move = function() {
if (_root.getdistance(this.x, this.y, this.targx, this.targy)>this.speed) {
this.x += this.diffx;
this.y += this.diffy;
} else {
this.x = this.targx;
this.y = this.targy;
if (!this.t) {
this.t = getTimer();
}
if (getTimer()-this.t>1000) {
this.reset();
this.t = 0;
}
}
this._x = this.x;
this._y = this.y;
};
I want the random moving movieclips to gather around a button when it's onRollOver. Can someone advise me on this? Thanks..
[F8] Making Random Blocks Move Up
Hi there, (first time posting hoping to have a nice time from now on here )
Basicly my problem is that I want to make a game, at the moment graphics are not important I can make them later but I need help in coding for it.
1) How would I have 1x1blocks randomly of 6 diffent colors moving up the playing feild,
They all come in at the same time in lines of around 10
2) When three or more colors match they dissapear and the ones above the dissappearing blocks move down
3) The aim is to keep the block from reaching the top. If they do you die
Thanks for any help
Array To Move Random Objects
I've searched the forum and didn't find this particular situation addressed. And I'm an idiot when it comes to Arrays.
In a movie I have six foreground objects hidden off-stage. I want to randomly choose one object to pan across the screen each time a function - fgpan(); -is called. Each object has its own pan speed, so I have set up two arrays, and use a single variable to call up the same number item from both arrays. But somehow I can't get the function to work. I'm sure it's a simple syntax error.
Note that the fgMove(); function works correctly if literal names and values are inserted. But when I try to insert the Array values, it doesn't work.
Please, someone teach me!
ActionScript Code:
var fgThing:Array = new Array("tree", "bush", "fence", "hay", "mist1", "mist2");
var panSpeed:Array = new Array(1, 2.5, 3, 2.5, 2, 2);
function fgMove(daKine, daSpeed):Void {
daKine._x = -290;
daKine._visible = true;
daKine.onEnterFrame = function() {
if (this._x>=900) {
this._visible = false;
delete this.onEnterFrame;
} else {
this._x += daSpeed;
}
};
}
function fgPan():Void {
var fgItem:Number = Math.floor(Math.random()*6);
trace(fgThing[fgItem]+" "+" "+panSpeed[fgItem]); //THIS WORKS CORRECTLY
fgMove(fgThing[fgItem], panSpeed[fgItem]); //THIS DOESN'T WORK!
}
fgPan();
Move A Object In Random Directions
Hi guys.
This is kind of hard to explain, so i'll paint you a picure here:
I have a shoppingbag. Out of that bag, i want to have multiple stars flying out.
The stars have to move upwards, but in a random angel and speed.
And fade out in the end. Either after a duration of time, or when they have moved more then 300 pixel.
Please, anyone who can help me in the right direction here?
Move Movieclip To Random Locations
hey guys,
i'm trying to make a movie clip travel between different points in random order. if it's at "A" it can go to "B" or "C". if it's at "B", it can go to "A" or "C" etc... Locations are in an array.
i can't figure out to let the movie know when to go to the next array!
PHP Code:
onClipEvent (load) {
var targets1 = Array(10, 20);
var targets2 = Array(30, 40);
var targets3 = Array(50, 60);
var targets4 = Array(70, 80);
arrays = [targets1, targets2, targets3, targets4];
_root.myObject._x = arrays[3][0]; //set start location x
_root.myObject._y = arrays[3][1]; //set start location y
i = 0;
}
onClipEvent (enterFrame) {
x = Math.abs(arrays[0][0]-arrays[i+1][0]);
y = Math.abs(arrays[0][1]-arrays[i+1][1]);
if (x>y) {
xspeed = 5;
yspeed = 5*(y/x);
} else {
yspeed = 5;
xspeed = 5*(x/y);
}
with (_root.myObject) {
if (_x>(xtarget+2.5) || _x<(xtarget-2.5) || _y>(ytarget+2.5) || _y<(ytarget-2.5)) {
if (_x>xtarget) {
_x = _x-xspeed;
} else {
_x = _x+xspeed;
}
if (_y>ytarget) {
_y = _y-yspeed;
} else {
_y = _y+yspeed;
}
}
}
}
i took the bottom part of the code from one of the tutorials
can anyone give me some hints on where to go from here?
thanks a bunch,
monkeybrainz
Pixel Random Move Question
Hello guys, i am trying to make a so called pixel effect in witch I want to make a shape only from pixels that are positioned in some random place on the stage. And all these pixels move to a certain point and create that shape.
I now this is a long shot for a newbe like me but i'm willing to learn.
So could somebody give me some clue on how to begin this. I've been looking into BitmapData Class but i don't now if that is the best way to do it.
Making A Array Of Lines -move At Random
Hello Flash Kit!
This is my frist time visiting this site. What a great ideal.
I am trying to build a interface or intro design for a flash presentation. I would like to use mulit-line moving across page at random speed and transparency.
Can someone tell me where I can find codes to do this?
Thank you
Random Eyeball Move - Not Follow Mouse
Hey all,
I have an eyeball in a project and want it to move randomly in a natural manner in it's "socket"...independent of any mouse movement.
But the area is too small to have it follow the cursor/mouse movements.
I, more or less, want it constrained to a natural look, but want the looking to be slow, and appear random and haphazard.
I have found many "cursor following" examples, but don't know how to "give it a life of it's own" if that makes sense.
Any ideas? Thanks!
cb
Making A Clip Move On A Random Path, But End In The Same Place
Maybe someone can help -- still a little new at actionscript:
I have a movie clip that needs to zip along some sort of a path, but end up in the same place by frame X every time. Right now, I've drawn a random-looking path, and have it motion tweened along it, which looks fine the first time, but gets old (and the tweening is slowing stuff down).
Is there any way in actionscript to make something move randomly, but end up in the same place and the end frame?
Any help is appreciated... thanks.
Move Screen To Movie Clip On Random Path
I have made a flash file with dim of 200*100, behind it there is a background of 1000*500! on this background there are 4 movie clips (which ofcourse I may change) I have made it so that by pressing a button on the screen the screen moves to the movie clip (which is also 200 * 100) and then from that clip to another clip and so on ...
The thing I need is to create a random path to move from one location to the next! ... is that possibe? and if so! how?? The following is the script I have written to make the selected button (which is appointed to a movie clip) do its thing: (sorry for the weak codes, this is actually my first actionscript code) if anyone can give optimize my code it will be excellent!
PHP Code:
function moveTo(clip, speed) {
xtarget = clip._x-clip._width/2;
ytarget = clip._y-clip._height/2;
var speedX = Math.abs(xtarget+_x)/speed;
var speedY = Math.abs(ytarget+_y)/speed;
//--------------------------- x ---------------------------//
//left
if (xtarget<0 && _x>0 && (-xtarget-_x>0)) {
var i = 1;
}
//right
if (xtarget<0 && _x>0 && (-xtarget-_x<0)) {
var i = 2;
}
//left
if (xtarget<0 && _x<0) {
var i = 3;
}
if (xtarget<0 && _x == 0) {
var i = 4;
}
//right
if (xtarget>0 && _x<0 && (xtarget+_x>0)) {
var i = 5;
}
//left
if (xtarget>0 && _x<0 && (xtarget+_x<0)) {
var i = 6;
}
//right
if (xtarget>0 && _x>0) {
var i = 7;
}
if (xtarget>0 && _x == 0) {
var i = 8;
}
//--------------------------- y ---------------------------//
//up
if (ytarget<0 && _y>0 && (-ytarget-_y>0)) {
var j = 1;
}
//down
if (ytarget<0 && _y>0 && (-ytarget-_y<0)) {
var j = 2;
}
//up
if (ytarget<0 && _y<0) {
var j = 3;
}
if (ytarget<0 && _y == 0) {
var j = 4;
}
//down
if (ytarget>0 && _y<0 && (ytarget+_y>0)) {
var j = 5;
}
//up
if (ytarget>0 && _y<0 && (ytarget+_y<0)) {
var j = 6;
}
//down
if (ytarget>0 && _y>0) {
var j = 7;
}
if (ytarget>0 && _y == 0) {
var j = 8;
}
//--------------------------- ---------------------------//
clip.onEnterFrame = function() {
trace(buttons._y);
if (i == 1 || i == 3 || i == 4 || i == 6) {
_x += speedX;
buttons._x -= speedX;
}
if (i == 2 || i == 5 || i == 7 || i == 8) {
_x -= speedX;
buttons._x += speedX;
}
if (j == 1 || j == 3 || j == 4 || j == 6) {
_y += speedY;
buttons._y -= speedY;
}
if (j == 2 || j == 5 || j == 7 || j == 8) {
_y -= speedY;
buttons._y += speedY;
}
if (i == 1) {
if (-xtarget-_x<0) {
buttons._y = buttons._y+(this.height/2);
delete this.onEnterFrame;
}
}
if (i == 2) {
if (-xtarget-_x>0) {
buttons._y = buttons._y+(this.height/2);
delete this.onEnterFrame;
}
}
if (i == 3 || i == 4) {
if (xtarget+_x>0) {
buttons._y = buttons._y+(this.height/2);
delete this.onEnterFrame;
}
}
if (i == 5) {
if (xtarget+_x<0) {
buttons._y = buttons._y+(this.height/2);
delete this.onEnterFrame;
}
}
if (i == 6) {
if (xtarget+_x>0) {
buttons._y = buttons._y+(this.height/2);
delete this.onEnterFrame;
}
}
if (i == 7 || i == 8) {
if (xtarget+_x<0) {
buttons._y = buttons._y+(this.height/2);
delete this.onEnterFrame;
}
}
};
}
|