kearnguy
asked on
Attaching movie clip, duplicating it, and placing them in random coordinates, then unloading them...
Ya so I am trying to create a background effect. I want to dynamically load a movieClip into a flash doc multiple times and in different locations (x y coordinates). I also want the clips to unload themselves after one loop of itself. Then start all over again. There would probably be around 10 clips at any given moment loaded on screen.
I have tried a couple different approches, but really when it comes down to it, I have no clue where to start since I have only a basic working knowledge of ActionSript.
Mix-fx software actually has an effect that produces a similar result but only around text (since it is a flash text effect program). However, it would give you a good visual about what I want. Look at the background and ignore the text.
http://www.mix-fx.com/blowsmoke.htm
Thanks in advanced. Oh, this is rather time sensitive.
I have tried a couple different approches, but really when it comes down to it, I have no clue where to start since I have only a basic working knowledge of ActionSript.
Mix-fx software actually has an effect that produces a similar result but only around text (since it is a flash text effect program). However, it would give you a good visual about what I want. Look at the background and ignore the text.
http://www.mix-fx.com/blowsmoke.htm
Thanks in advanced. Oh, this is rather time sensitive.
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
aneeshchopra, this is great. However, I will need to taylor it for several different projects so please break it down for me.
For exmple, could you comment out explanations of what the lines of code are doing so that I can change settings of them.
Here's what I understand so far so please explain better for me (I want to learn this stuff so I can one day give back to this awesome community):
FRAME 1
//setting value for variable
i = "0";
//is this the number of movieClips?
amount = "10";
//setting the movieClip initial value to invisible
circle._visible=false;
FRAME 2
//not too sure what the numbers are doing here and what they effect
valuetest = random("160") + 40;
//duplicating the circle moviClip, naming the instance, then something I don't get with the numbers again
duplicateMovieClip("circle ", "test" add i, 16384 + (1000 - i));
//doing something with the coordinates
this["test" add i]._x= random("100") - 50;
this["test" add i]._y=random("30") - 15;
//doing something with the size of the movieClip
this["test" add i]._yscale=valuetest;
this["test" add i]._xscale= valuetest;
//somehow changing the alpha property
this["test" add i]._alpha= random("40") + 10;
i = i + 1;
FRAME 11
//looping the whole effect
if (i<amount+1)
{
gotoAndPlay(2);
} else
{
i = "1";
amount = "10";
gotoAndPlay(2);
}
For exmple, could you comment out explanations of what the lines of code are doing so that I can change settings of them.
Here's what I understand so far so please explain better for me (I want to learn this stuff so I can one day give back to this awesome community):
FRAME 1
//setting value for variable
i = "0";
//is this the number of movieClips?
amount = "10";
//setting the movieClip initial value to invisible
circle._visible=false;
FRAME 2
//not too sure what the numbers are doing here and what they effect
valuetest = random("160") + 40;
//duplicating the circle moviClip, naming the instance, then something I don't get with the numbers again
duplicateMovieClip("circle
//doing something with the coordinates
this["test" add i]._x= random("100") - 50;
this["test" add i]._y=random("30") - 15;
//doing something with the size of the movieClip
this["test" add i]._yscale=valuetest;
this["test" add i]._xscale= valuetest;
//somehow changing the alpha property
this["test" add i]._alpha= random("40") + 10;
i = i + 1;
FRAME 11
//looping the whole effect
if (i<amount+1)
{
gotoAndPlay(2);
} else
{
i = "1";
amount = "10";
gotoAndPlay(2);
}
ASKER
...also, what is making the circles a red tint? I can't find anything that is causing this. I changed the background color to black and the circles are still a red/orange color.
Here I have updated the comments for frame 2 code, I hope rest all is clear to you.
-------------
//generating a random number inbetween 160 to 200 to assign the scale (size) of movieclip
valuetest = random("160") + 40;
//duplicating the circle moviClip, naming the instance, last parameter is to assign the depth with a unique number.
duplicateMovieClip("circle ", "test" add i, 16384 + (1000 - i));
//setting x-coordinate with random number inbetween -50 to 50;
this["test" add i]._x= random("100") - 50;
//setting y-coordinate with random number inbetween -15 to 15;
this["test" add i]._y=random("30") - 15;
//setting scale (size)..
this["test" add i]._yscale=valuetest;
this["test" add i]._xscale= valuetest;
//changing the alpha property with a random value inbetween 10 to 50
this["test" add i]._alpha= random("40") + 10;
i = i + 1;
--------------
red tint is coming because....
root instance of "circle_mc" has it defined using tint...
to remove it do the following:
1.
select "circle_mc" at root
2.
click color dropdown and select a tine once,and then remove it again..
Rgds
Aneesh
-------------
//generating a random number inbetween 160 to 200 to assign the scale (size) of movieclip
valuetest = random("160") + 40;
//duplicating the circle moviClip, naming the instance, last parameter is to assign the depth with a unique number.
duplicateMovieClip("circle
//setting x-coordinate with random number inbetween -50 to 50;
this["test" add i]._x= random("100") - 50;
//setting y-coordinate with random number inbetween -15 to 15;
this["test" add i]._y=random("30") - 15;
//setting scale (size)..
this["test" add i]._yscale=valuetest;
this["test" add i]._xscale= valuetest;
//changing the alpha property with a random value inbetween 10 to 50
this["test" add i]._alpha= random("40") + 10;
i = i + 1;
--------------
red tint is coming because....
root instance of "circle_mc" has it defined using tint...
to remove it do the following:
1.
select "circle_mc" at root
2.
click color dropdown and select a tine once,and then remove it again..
Rgds
Aneesh
ASKER
Yes, that clears it up great. I have one more question concerning this code.
When the circles are generated, they show up in a random _x _y coordinate. However, they keep loading into that same coordinate while the movie is playing. They only change coordinates if the movie is refreshed. I need the circle_mc clip to unload and reload so that it is in a constant state of random placement.
Once that is figured out, then I will have my solution.
When the circles are generated, they show up in a random _x _y coordinate. However, they keep loading into that same coordinate while the movie is playing. They only change coordinates if the movie is refreshed. I need the circle_mc clip to unload and reload so that it is in a constant state of random placement.
Once that is figured out, then I will have my solution.
Now it will do as you required...
here is the updated codem for frame 1 and 11:
frame 1
--------
//setting value for variable
i = 0;
//is this the number of movieClips?
amount = 10;
//setting the movieClip initial value to invisible
circle._visible = false;
---------
frame 11
--------
//looping the whole effect
if (i<amount+1)
{
gotoAndPlay(2);
} else
{
i = 0;
amount = 10;
gotoAndPlay(2);
}
--------
actually variable "i" and "amount" had been defined as "String".. now they are as number...
Rgds
Aneesh
here is the updated codem for frame 1 and 11:
frame 1
--------
//setting value for variable
i = 0;
//is this the number of movieClips?
amount = 10;
//setting the movieClip initial value to invisible
circle._visible = false;
---------
frame 11
--------
//looping the whole effect
if (i<amount+1)
{
gotoAndPlay(2);
} else
{
i = 0;
amount = 10;
gotoAndPlay(2);
}
--------
actually variable "i" and "amount" had been defined as "String".. now they are as number...
Rgds
Aneesh
ASKER
Thanks. This is great. You have been a great help.
And if u want more effects with images in flash you can try with some thirdparty tools like "siwsh", "swishmax", "flex", "swift3d".
Best Regards
Dushan