Moving A Movie Clrip Randomly
Hi
ive just written this script for miving a movie clip randomly within any set parameters but i cant rub it. it keeps saying that it needs to abandon the script or my computer might seize up or something.
ive never had this error before and i was wondering if anyone could give me some advise as to where ive gone wrong here.
thnx in advance and heres the code g
WIDTH = 200; HEIGHT = 200; startX = 145; startY = 145; STEP = 5;
container._x = startX; container._y = startY;
leftWall = startX - (WIDTH/2); rightWall = startX + (WIDTH/2); topWall = startY - (HEIGHT/2); bottomWall = startY + (HEIGHT/2);
Directions = ["l","r","d","u","lu","ld","ru","ld"]; dirLength = Directions.length; Direction = Directions[0]; i == True; while (i == False){ switch (Direction){ case "l": container._x = container._x - STEP; if (container.x <= leftWall){ Direction = Directions[Math.random(1,2,3,4,5,6,7)]; break; } break; case "r": container._x = container._x + STEP; if (container.x >= rightWall){ Direction = Directions[Math.random(0,2,3,4,5,6,7)]; break; } break; case "d": container._y = container._y - STEP; if (container.y <= bottomWall){ Direction = Directions[Math.random(0,1,3,4,5,6,7)]; break; } break; case "u": container._y = container._y + STEP; if (container.y >= topWall){ Direction = Directions[Math.random(0,1,2,4,5,6,7)]; break; } break; case "lu": container._x = container._x - STEP; container._y = container._y + STEP; if (container.y >= topWall or container.x <= leftWall){ Direction = Directions[Math.random(0,1,2,3,5,6,7)]; break; } break; case "ld": container._x = container._x - STEP; container._y = container._y - STEP; if (container.y <= bottomWall or container.x <= leftWall){ Direction = Directions[Math.random(0,1,2,3,4,6,7)]; break; } break; case "ru": container._x = container._x + STEP; container._y = container._y + STEP; if (container.y >= topWall or container.x >= rightWall){ Direction = Directions[Math.random(0,1,2,3,4,5,7)]; break; } break; case "rd": container._x = container._x + STEP; container._y = container._y - STEP; if (container.y <= bottomWall or container.x >= rightWall){ Direction = Directions[Math.random(0,1,2,3,4,5,6)]; break; } break; default: i = False; break; } }
FlashKit > Flash Help > Flash ActionScript
Posted on: 04-15-2005, 08:06 AM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Moving A Movie Clip Randomly
Hi all,
my stage size is 550x400 and movie clip is about 20x20 now
i want this clip movie randomly about 5 pxiles from its position how can i do this.
what i did so for is
setProperty ("one", _x, random (5));
when i played that time this clip gose left side og the stage and playing randomly 5, but i need this to play exactly where iam placed in main stage.
Thanks for replay :-)
Naushad.Bangalore
Moving Movie Smoothly But Randomly
I have problem. I can place the movie randomly. But i want to move it smoothly. I.e its should follow some random path without jerks.
Please send a mail urgently to ndbhatt@hotmail.com
Randomly Moving MCs In A Box.
i have about 4 MCs that i want to randomly move inside a box on my page. on mouseover, i want the MC's to Slowly fad out... how could i achive this ?
Moving MCs Randomly Inside Box
O.K I have 20 different MCs on the main timeline, I want them to float (move) RANDOMLY around INSIDE a boundrybox, the boundrybox co-ordinates are
x 0 - 600
y 0 - 300
The MCs are 20 x 20 pixels
Can anyone possibly help me with the appropriate code, and where it goes ie; what frame etc.
If anyone can help it would be VERY VERY greatly appreciated!!!!!! Thanks heaps in advance!!!!!
LauraG
Randomly Moving Buttons
can anyone tell me how to make objects move slowly and randomly around the screen. I want to use them as menu buttons.
thanks
Moving Object Randomly
hi
I want to move my "red circle(or other..)"10..20..30 pixel if randomly selected number=10..20..30 respectedly when click a buton to produce random numbers between 1 and 50..
thank you..
Randomly Moving Objects
I need assistance with this, since I can't find it in the forums. I want to have at most 10 circular-objects moving randomly around the page. Also if it's possible to have some of them appear and disappear after time. Can this be done?
thanks!
Randomly Moving Objects
Does anyone know a script that can randomly move objects on a rollover then revert back after rolled out? I plan to use this as a menu, so when someone rolls over text, the letters will move seperately, but different every single time. I will post my FLA if needed to show what I want.
Thanks in advance,
James
Moving MCs Across Stage Randomly..
I have a Media clip of a bird that I want to often fly across the screen but not just simply fly, I want action script to choose a random scale so it appears as if one is further than the other. How would I do thi? Anyone know?
I thought of what I meant...Just like a star field kind of effect except Im just going to replace the star with a bird.
Randomly Moving Menu
Hi guys
can anyone explain how is the randomly rotating menu in the shoes section of the following link done:
http://www.kangaroos.com/uk/
the menu with the shoes rotating ....
I know how they have connected the shoes with the lines but how r they rotating?
Any help appreciated. thanks a lot for your help.
require it urgently as i need to incorporate the idea in a project.
thanks again
Ritika
Randomly Moving A Movieclip
hi you all, hope you can help me with this one, i want to move a movieclip around on stage. the most important thing is, it's movements should be randomly. You could compare it with an annoying fly buzzing above your head. if you want a more concrete example ... try www.thedesignersrepublic.com and get their screensaver. they use that very thing i want to accomplish.
Moving Buttons Randomly/ I.e. Fish
I need to make a flash movie where I have randomly moving/floating buttons (fish), which upon clicking, will animate (i.e. blowfish will puff up and make a sound). I figured out the bubble element in the background, but the fish element is giving me trouble.
I've found different sample movies (even aquarium samples) to help serve as examples, but am having trouble tweaking and combining them into my specific needs. They either have -just- randomly moving objects (no mouse events), or if they do have mouse events, they have other additional stuff (i.e. a start button and toggles between different shapes) that I don't need.
What would be the easiest way to move a button on random paths across the screen, and still integrate a mouse-event? Is there a good sample somebody could show me, or point me to a good tutorial?
thanks so much!
Randomly Moving Movieclip On Stage
Hello everybody.
I am new to flash and I am here to get some help for my typing game. I have 5 movieclips and I want them to enter the stage from different directions. If they go out of the stage they should come in again from some other direction. Please help if anybody know how to do it.
Best Regards,
7 Different Objects Moving Randomly Smooth
Howdy ... I have 7 different objects on my stage, and they should move randomly and smoothly ... I have tried the Kirupa Tuts here, but i had no luck to build my own random movement smoothly (coz they all use only one MC to make the effect)
anyone can help me with that ???
cheers
ChromeD
Drag And Drop Randomly Moving Obj...
hi all ,
i am trying to do a drag and drop game .
i want to have some multiple objects flying randomly around the scene and i want the user to drag and drop them into a box ...
when the user drags the same color object for three times into the box
he wins a prize related to that color .
i have solved the drag and drop part like this (thanks to kirupa!!);
on (press) {
startDrag("_root.green" ;
}
on (release) {
stopDrag();
if (_root.green._droptarget == "/computer" {
_root.computer.gotoandStop("green" ;
_root.pieceCount += 1;
if (_root.pieceCount == 3) {
_root.prize.gotoAndStop("you won the prize nr 5" ;
}
}
}
so if the user drags the same object for 3 times onto the box he wins a prize related to that object .
and to do the game more challanging i want to make the object to move randomly around the stage ;
so i added this code on the objects ;
onClipEvent (load) {
width = 800;
height = 600;
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;
}
}
the problem,
both codes work ok when they are seperated ...
but together the drag and drop doesnt work ... after you click the object remains attaced to the mouse in a strange way ...
any ideas please...
Randomly Generating Moving Numbers/symobls
What I'm trying to do is create 1s and 0s that move down behind a graphic that i'm using as a background trying to give it more depth. I want the 1s and 0s to be random and not look like a loop but at the same time i want them moving towards the bottom of the screen so they look like they're scrolling. I have a limited knowledge of action script so if you know a tutorial or something that would help too.
Randomly Moving Monkey Tail Script
Hello Flash Folks,
I have a question regarding actionscript for a moving line (MX04). I have looked in the archives with no success.
I have a monkey tail annimation that moves with tweens, but is not nearly random enough. I would like to use code to move the tail's end around.
Does anyone have code to keep one end of a line stationary while the other curls and waves? The monkey will be so grateful!
Seriously...Thanks for your help.
Rob
Combining Randomly Moving Body With Springy Leg
Hi I've been reading previous threads which have provided separate answers to the two theories of random movement and elasticity. But now I can't figure out how to combine them.
What I want is a movieclip (lets say 'body.mc'), moving randomly around the stage with a second movieclip ('foot_mc') that springs to the coordinates of the constantly moving 'body_mc'.
I found the code on bit-101.com, for the springy foot (part of making a creature):
bit-101.com
The problem with this is that I don't want the body to be draggable, I want it to move randomly of it's own accord.
Code:
foot_mc.onEnterFrame = spring;
function spring() {
if (!this.dragging) {
var dx = body_mc._x-this._x;
var dy = body_mc._y-this._y;
this.vx += dx*k;
this.vy += dy*k;
this.vx *= damp;
this.vy *= damp;
this._x += this.vx;
this._y += this.vy;
} else {
this.vx = this._x-this.oldx;
this.vy = this._y-this.oldy;
this.oldx = this._x;
this.oldy = this._y;
}
}
How do i remove the 'if' statement, with the dragging clause, and make the foot always spring to the body?
The random movement code, I found here:
kirupa.com
I hope someone out there has the expertise to help, or just shed some light.
grateful in advance
[FMX] Stop Objects From Overlapping When Moving Randomly
Hi I'm trying to create a flash demo for my prof and I need to make dots move randomly across the screen without overlapping each other as they move. Then one of the dots need to turn to a different colour for 2 seconds and then return to its original colour.
I can make the dots move randomly but need help
1) to prevent them from overlapping
2) make the dot turn a different colour momentarily
If you can direct me to a starting place or a resource where I can find out how to do these things (or better yet, tell me how) your help will be greatly appreciated!
Randomly Moving Horizontal Bars/ Lines
Hi all,
Could anyone please tell me how do I do the effects on this page (the moving bars effects at the bottom of the page)?
http://a4desk.com/lib/show.php?id=A4DP026
Thanks.
Jeremy
Randomly Moving Horizontal Bars/ Lines
Hi all,
Could anyone please tell me how do I do the effects on this page (the moving bars effects at the bottom of the page)?
http://a4desk.com/lib/show.php?id=A4DP026
Thanks.
Jeremy
Moving MovieClip On Stage Randomly With Easin..help
Hello everyone,
I am trying to move a movie clip with easing.
Stage size: width(300) height(100);
I am trying to write function which would simple move the mc_clip on to the stage back and forth with easing. This is what I have so far:
PHP Code:
function player(mc:MovieClip)
{
speed = 20; // the higher the slower
this._x = this._x + (100 - this._x)
I don't know how to assign the stage width which I tried:
(Stage.width - this._x)
I would use setInterval to invoke the function every two seconds which I think got it:
PHP Code:
myInterval = setInterval(player, 5000);
Any help would highly be appreciate it.
Thanks a lot.
Trouble Keeping Randomly Moving Objects Contained
hey out there hows it going
i've got a problem that has been bugging me for a while now i've tried a couple of scripts but no solution. hopefully some flash guru can help me out here. here goes
i have linked 8 instances of an object on stage with the attachMovie script, these 8 objects are then told to randomly pick
1 of 8 directions to move in for a certain number of frames, when the movie hits the last frame the script repeats and they choose a new direction. the problem is that the objects eventually escape the screen past the size of the movie. to counter this i created another object that i named 'border', used the getBounds script and tried to keep the other eight ojects to stay within the xMin xMax yMin and Ymax of the 'border'. - it doesn't want to work
if anyone out there has the patience to figure out what i've done wrong then you are my hero.
heres the scrip:
// this part puts all eight objects on screen and creates the motion--it works fine
for (n=1; n<9; n++) {
_root.attachMovie("blackdotcase", "dotcase"+n, n+1);
_root["dotcase"+n]._x = 206;
_root["dotcase"+n]._y = 198;
// heres the function ( "chooser" is another expression that chooses 1 of eight directions)
function motion (speed) {
if (_root["chooser"+n] == 1) {
_root["dotcase"+n]._x += speed;
}
if (_root["chooser"+n] == 2) {
_root["dotcase"+n]._x -= speed;
}
if (_root["chooser"+n] == 3) {
_root["dotcase"+n]._y -= speed;
}
if (_root["chooser"+n] == 4) {
_root["dotcase"+n]._y += speed;
}
if (_root["chooser"+n] == 5) {
_root["dotcase"+n]._x -= speed;
_root["dotcase"+n]._y -= speed;
}
if (_root["chooser"+n] == 6) {
_root["dotcase"+n]._x += speed;
_root["dotcase"+n]._y += speed;
}
if (_root["chooser"+n] == 7) {
_root["dotcase"+n]._x += speed;
_root["dotcase"+n]._y -= speed;
}
if (_root["chooser"+n] == 8) {
_root["dotcase"+n]._x -= speed;
_root["dotcase"+n]._y += speed;
}
}
}
// all is well until here. to keep the motion contained to a certain area i added a new object got its bounds and created a new function
_root.bigbox = _root.border.getBounds();
_root.top = _root.border.yMax;
_root.bottom = _root.border.yMin;
_root.left = _root.border.xMin;
_root.right = _root.border.xMax;
for (n=1; n<9; n++) {
function check () {
if (_root["dotcase"+n]._x<=_root.right) {
_root["chooser"+n] == 2;
}
if (_root["dotcase"+n]._x>=_root.left) {
_root["chooser"+n] == 1;
}
if (_root["dotcase"+n]._y<=_root.top) {
_root["chooser"+n] == 3;
}
if (_root["dotcase"+n]._y>=_root.bottom) {
_root["chooser"+n] == 4;
}
}
// with this code i hoped to predetermine what number "chooser" would be in the case of the objects escaping the border and making them move back inwords. i put this function above the original werever the original was used but it didn't work.
if anyone has any ideas i'm all ears cuz i'm fresh out
thanks in advance
Flash Question - Cool Lil Tile Map And An Mc Moving Thru It Randomly
g=this
g.s=4
function draw(m, c){
with(m){
lineStyle(1, c, 0); beginFill(c, 40); moveTo(0, 0)
lineTo(g.s, 0); lineTo(g.s, g.s); lineTo(0, g.s); lineTo(0, 0); endFill()
}
}
function tile(x, y, t){
c=(t==0) ? '0x000000':'0x999999'
r=(t==0) ? 0: 1
d=createEmptyMovieClip(x+'t'+y, g.k)
d.r=r
with(d){ _x=x*g.s; _y=y*g.s }
draw(d, c)
g.k++
}
g.lib=new Array()
g.map=new Array()
g.lib[0]=[[0, 1, 0],
[1, 1, 1],
[0, 1, 0]]
g.lib[1]=[[0, 0, 0],
[0, 1, 1],
[0, 1, 0]]
g.lib[2]=[[0, 0, 0],
[1, 1, 0],
[0, 1, 0]]
g.lib[3]=[[0, 1, 0],
[0, 1, 1],
[0, 0, 0]]
lib[4]=[[0, 1, 0],
[1, 1, 0],
[0, 0, 0]]
g.lib[5]=[[0, 0, 0],
[1, 1, 1],
[0, 0, 0]]
g.lib[6]=[[0, 1, 0],
[0, 1, 0],
[0, 1, 0]]
g.lib[7]=[[0, 1, 0],
[1, 1, 1],
[0, 0, 0]]
g.lib[8]=[[0, 0, 0],
[1, 1, 1],
[0, 1, 0]]
g.lib[9]=[[0, 1, 0],
[0, 1, 1],
[0, 1, 0]]
g.lib[10]=[[0, 1, 0],
[1, 1, 0],
[0, 1, 0]]
g.map[0]=[[1, 5, 5, 5, 5, 8, 5, 5, 5, 2],
[6, 1, 5, 5, 5, 7, 5, 5, 2, 6],
[9, 10, 1, 5, 5, 5, 5, 5, 7, 10],
[6, 6, 3, 5, 5, 5, 5, 2, 1, 10],
[3, 7, 5, 5, 5, 5, 2, 6, 6, 6],
[1, 5, 5, 5, 8, 5, 4, 3, 4, 6],
[9, 5, 5, 5, 0, 5, 5, 5, 5, 10],
[3, 2, 1, 5, 4, 5, 5, 5, 5, 10],
[1, 5, 5, 5, 5, 5, 5, 5, 5, 10],
[3, 5, 5, 5, 5, 5, 5, 5, 5, 4]]
g.map[1]=[[1, 8, 8, 8, 8, 8, 8, 8, 8, 2],
[9, 0, 0, 0, 0, 0, 0, 0, 0, 10],
[9, 0, 0, 0, 0, 0, 0, 0, 0, 10],
[9, 0, 0, 0, 0, 0, 0, 0, 0, 10],
[9, 0, 0, 0, 0, 0, 0, 0, 0, 10],
[9, 0, 0, 0, 0, 0, 0, 0, 0, 10],
[9, 0, 0, 0, 0, 0, 0, 0, 0, 10],
[9, 0, 0, 0, 0, 0, 0, 0, 0, 10],
[9, 0, 0, 0, 0, 0, 0, 0, 0, 10],
[3, 7, 7, 7, 7, 7, 7, 7, 7, 4]]
function create(w){
g.m=w
for(i=0; i<g.map[w].length; i++){
for(j=0; j<g.map[w][i].length; j++){
for(y=0; y<g.lib[g.map[w][i][j]].length; y++){
for(x=0; x<g.lib[g.map[w][i][j]][y].length; x++){
tile(x+j*3, y+i*3, g.lib[g.map[w][i][j]][y][x])
}
}
}
}
}
create(1)
function checker(m){
g.p=new Array()
if(_root[m.x+1+'t'+m.y].r==1){ g.p.push([m.x+1, m.y]) }
if(_root[m.x-1+'t'+m.y].r==1){ g.p.push([m.x-1, m.y]) }
if(_root[m.x+'t'+m.y-1].r==1){ g.p.push([m.x, m.y-1]) }
if(_root[m.x+'t'+m.y+1].r==1){ g.p.push([m.x, m.y+1]) }
choose=random(g.p.length)
m.x=g.p[choose][0]
m.y=g.p[choose][1]
}
function organ(){
c=createEmptyMovieClip('organ', g.k)
c.x=1; c.y=1
c.onEnterFrame=function(){
this._x=this.x*g.s
this._y=this.y*g.s
checker(this)
}
draw(c, 0xcc3300)
g.k++
}
organ()
ok, there r types of tile pieces like corner pieces which r explained in the lib thing (the movinf thing can go on 1s and not 0s) so then i make a map of these pieces and its parsed. whenever a 1 or 0 is added, it has the name x+t+y, its x, a t to seperate it and its y. also, its given a variable r to tell what kind it is to something later. ok
now the moving thing. it checks the x and y of the tiles around it in the cardinal directions, and if they r 1's its inputed into an array. it chooses a random index in the array, takes that x and y and goes there. c/p the code into u re flash. it works for like seconds then immediately goes intot he upper rite corner, 0, 0. whats wrong?
Trying To Create Randomly Moving/color-changing Shape
I am pretty new to Flash, so I'm really just trying to figure things out. Anyway, I have a MC that is a red circle. I have an instance of it on the stage, and the AS for the instance is as follows
Code:
onClipEvent(enterFrame)
{
_alpha=random(100);
_x=_x=random(800);
_y=_y=random(600);
}
This accomplishes the task of the shape moving to a random location and changing transparency every frame. The last thing that I would like to do is get it to change to a random color every frame as well. How can I do this? Thanks for the help!
How To Get A Movie Clip To Randomly Scroll Through My Movie.
Hmm... I've got a small movie that I'd like to have a movie clip I've made randomly move from the top of the movie to the bottom and then restart the effect. I'm sure this is relatively simple... I just don't know how to do it
P.S. I'd like multiple instances of the clip to do this if it makes a difference.
Thanks,
Loading A Movie Randomly?
Is it possible to have a selection of 4 movies, individual .fla files, where by one is selected at random and shown in one single .fla?
Basically Im trying to set up a screensaver that will select one of four movies at random.
Any ideas?
Movie Plays Randomly
Hey guys.
How can I make a movie play randomly...example...something flashes randomly, or grows and shrinks randomly, without anyone rolling over anything, and without it being constant like every second. ! second it flashes; next time it flashes maybe 10 seconds passes, then maybe 3, and so on... TOTAL RANDOMNESS.
Thanks. By the way, Im new at this so please be gentle.
Movie That Plays Randomly
Is it possible for a movie to play itself randomly. For example, an icon blinks, then maybe 3 seconds pass and it blinks, then 10, then 2...etc... Is this possible? How can I do it?
Thanks.
Can A Movie Be Set Tp Play Randomly?
Is it possible for a movie to play itself randomly. For example, an icon blinks, then maybe 3 seconds pass and it blinks, then 10, then 2...etc... Is this possible? How can I do it?
Thanks.
Randomly Selecting A Movie
I have been trying to get a certain animation to randomly choose a movie from a certain set of movies. Thusfar, I haven't really gotten very far, to be honest. I'm horrible at coding .
The only thing I've figured out is that I can generate a random number between 0 and 8 using the actionscript command:
code: f = random (8);
When it comes to actually using that to randomly choose a certain movie out of 8 different movies, I can't seem to get any further.
I'm hoping someone knows how to do this , if you've got the knowhow this should be a piece of cake.
If you need any more information about the movie, just ask.
Randomly Load Movie
is there a way to make a movie randomly load a movie to a target on startup so that a different movie loads everytime the root movie is accessed?
Play Movie Randomly
I have a movie that has a gleaming effect on it. I want to play this randomly. Here's what I have so far...
onClipEvent (load){
timer = Math.round(random(10)*1);
if (timer = 1){
logo_anim.gotoandPlay(1);
}
}
I know the first problem is that it only executes on load. How do I fix this? Also, the instance name of the movie is 'logo_anim'. Will the rest of the code work?
How To Play Movie Randomly
I have three movies named " mov_0, mov_1, mov_2"
I inserted them in one fla.
I want to play them randomly..
Uff I couldnt do
Need help !!
Playing Movie Clips Randomly
i'm wondering if anyone can help with what i'm sure is a relatively simple task:
i'm building a flash file with a number of small movie clips in it. i would like these clips to play randomly (so that there are little animations playing here and there)
i'm afraid i'm no expert with actionscript but i appreciate it'll require a bit of maths
alternatively if you can direct me in the direction of any tutorials that cover the subject i'd appreciate that
cheers
jonsi
Randomly Generating Movie Clips?
Hello!
I want to have a button, that when clicked, prompts 5 movie clips to randomly display a movie clip within them. The names of the clips are:
grey
red
purple
green
blue
the interior clips for the movies are grey_1, grey_2 , grey_3, grey_4 and grey_5. This format is followed for each of the following clips. Do I use arrays to do this or is there a much simpler way? Or should I attach Math.random to the button?
not really sure of what to do...
THANKS in advance!!!
Randomly Playing Movie Clip
i have a little movie clip...i want it to play randomly . its just an animation w/ a "stop" action on the last frame (within the movie clip), so it doesnt loop out of control. how do i make it play randomly , i tried to do it myself , dont know were i'm messing up.
i took off all the actions and uploaded it to
http://www.geocities.com/hitdabongo_*****/
starMC.fla
some plz help me.....its like the 3rd time i posted asken the same question, no1 relpied to any
Movie Clip Plays Randomly....
hello guys
i want a script to play the movie clip randomly... it means stop for a period of time then play and so on randomly
thanks
How To Randomly Display Stars On A Movie Seen
Hi to who ever answers this qusetion
I have this idea that I would like to have stars appear and dissapear ramdomly when the projector is first starting. Can anyone show me how it is done? also after the music is finished I would like for the projector to advance to a place on the time line. Can this be done?
Thanks inadvance for any help in this.
Randomly Attaching Movie Clips
Hi,
I want to randomly import movie clips from a 'library.swf';
(all the mc's within this .swf are linked to be exported as
"01", "02", etc.)
The code at the moment looks like this;
1st frame;
placeHolder.loadMovie("library.swf");
2nd frame;
stop ();
// mc 01
placeHolder.attachMovie("01", "my1", 2);
placeHolder.my1._x = 8;
placeHolder.my1._y = 18;
placeHolder.my1._xscale = 100;
placeHolder.my1._yscale = 100;
What I want to do is to, instead of using "01", "02", etc.
placeHolder.attachMovie("01", "my1", 2);
and use an action to randomly import movies from "01" to "50".
Any help or comments will be greatly appreciated,
Thanks,
Lenny.
Randomly Generating Movie Clips, Etc.
Anyone here know how to randomly generate instances of a movie clip?
To elaborate further, in case that helps, here's what I'm doing:
1. I am trying to make a game where you shoot at targets (a 'target' movie clip with Linkage 'targetlink').
2. The targets randomly appear.
I am trying to use attachMovieClip to do this, and so far, absolutely nothing happens when I test the movie. Any clues?
Here's my script, if that helps anything:
PHP Code:
createTarget = function(factor, x, y) {
var shootMe = this.attachMovie("targetlink", "Target", 0);
// variables for expedited code execution
var mr = Math.random, mf = Math.floor
// put target at specific x and y on stage
shootMe._x = x;
if (shootMe._x>40 || shootMe._x<510) {
shootMe._y = mf(mr()*400);
} else {
shootMe._y = y;
}
// set target's rotation
target._rotation = mf(mr()*360)-180;
};
createTarget();
Now, I can get it to generate the movie clip at this point, at the correct random coordinates and stuff, BUT.......
it appears to be on a "layer" way above everything else in the movie. So my custom cursor can't target it, for one thing, and it is not clickable, meaning that the game is very boring (as there is nothing to do but look at a target).
How on earth do I get this thing on a more interactive level? Any ideas what I'm doing wrong?
Additionally, the cursor is supposed to turn red, etc. when over the movie clip, and I've got code for it that works, but how do I make sure this code is still applied once the instance is randomly generated?
Whew... anyone who can help me on this gets mucho thanks :)
Thanks a ton,
-wobbly
Play Randomly Movie Clips
i used this code...
Code:
random = Number(random(9))+1;
tellTarget ("/mc" add random)
gotoAndPlay(1);
}
then this one...
Code:
r=int(Math.random()*9)+1;
_root["mc"+r].gotoAndPlay(1);
}
im using 79 movieclips...they are tiny sqares but they all are different...
i need to play the animation that each square has (change color) without pressing any button...the first code worked pasting it into a button...but second one dindnt worked....
ah!...and with the first code...i can only play randomly the first 9 MC...and then comes and error of level_0
Playing Movie Clips Randomly
hi!
I have 8 movie clips on the main timeline (all clips just have some text that fades in and out). Is there a way of playing these clips in a random order? ie: clip1 plays, then clip5, then clip8, then clip3 and so on...
if anyone can help that would be grand!
thanx in advance
Movie Clips Randomly Selecting
Hello,
I wonder if someone can help me with this dilemma I have. Ok, I have 3 MC's in the Library which I already placed Links to it, in order to use the AttachMovie Method to call them, now, how can I placed them via Randomly on the screen using the AttachMovie Method? I've read that one can 'Load' random Movies(ex:swf's, jpeg's, sounds, ect..) via the LOADMOVIE command, however, I would like to load these MC's using the AttachMovie method randomly, is there a way to do this without using the LOADMOVIE? Also, I would like it to be a continuous loop....These 3 MC's would be placed on the background of the stage....I would appreciate ur help on this matter..........Thanks and God Bless....
www.ymisitio.com
Load Movie Banners Randomly
I'm trying to sqeak out a site (even though I'm a print guy) and I've run into a question.
You can view the site-in-progress at: www.taylor-homes.com
You'll notice at the bottom of the main page (lev.1) that I've got a little animated ad (which is currently a movie symbol on the same timeline).
What this client wants to do is sell tons of these ads and so I've got to figure out the best way to have approx. 20 ads up at any one time that will load and run randomly as people come to the site. I've seen it done before in HTML but I wouldn't know where to start here.
Any ideas would be greatly appreciated.
—m
Randomly Loading Movie Clips
Ok, Im going to try and attempt to explain this....
I want to make an MC (lets say we call it MC_main), that contain or loads other MC's (from a list of MC's in the library, lets say MC_A, MC_B, MC_C, MC_D......to M or something)...in a random sequence. How can I do this?
Thanks
Duplicate Movie Clip Randomly
Hello flash people:
I need some help, How do i duplicate a movie clip randomly posisiton, alpha and scale?
And how do i do that in a ranged space in the scene?
Play Duplicate Movie Randomly?
This is probably very, very simple...but I have looked and am frustrated trying to figure it out being new to this...
but here goes.
I have a movie clip (a square that rotates and fades) that i have duplicated on the stage 50 times to cover the whole stage.I want them to play randomly-dissolving at different times to reveal the background.
do I need to name each one? even if it is the same movie? or is there a actionscript to play it at random times?
Since I am a newbie, any help would be greatly appreciated and where I put the code.
thanks!!
|