Setting Depth With Snow
So I'm trying to adapt this snow script and its awesome, but how would I put it on the main timeline and swap the depth so that the snow was on a layer beneath another layer?
Here's the script on the clip: onClipEvent (load) { //specifies the size of the movie stage movieWidth = 300; movieHeight = 200;
//variables that will modify the falling snow i = 1+Math.random()*2; k = -Math.PI+Math.random()*Math.PI;
//giving each snowflake unique characteristics this._xscale = this._yscale=50+Math.random()*100; this._alpha = 75+Math.random()*100; this._x = -10+Math.random()*movieWidth; this._y = -10+Math.random()*movieHeight; } onClipEvent (enterFrame) { //putting it all together rad += (k/180)*Math.PI; this._x -= Math.cos(rad); this._y += i; if (this._y>=movieHeight) { this._y = -5; } if ((this._x>=movieWidth) || (this._x<=0)) { this._x = -10+Math.random()*movieWidth; this._y = -5; } }
And here's the script on the main timeline:
for (k=0; k<100; k++) { duplicateMovieClip(_root.snow, "snow"+k, k); }
Any help would be super appreciated.
KirupaForum > Flash > ActionScript 1.0/2.0
Posted on: 08-13-2008, 10:31 PM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Snow Behind MC (using Snow 3.0)- Depth Issues
Hey folks! I am hoping someone can help me out with this one. Thanks to Sammo I was able to put an end to my snowfall headache using snow 3.0 http://www.kirupa.com/developer/flash8/snow.htm -- But now another problem has risen.
I need it to "snow" behind a movieclip and I can seem to figure out the right way of doing this . Anyone? Not sure if this involves using movieclip.getNextHighestDepth(); for the object? Just one of my unsuccessful attempts.
Help.....
Setting Mc Depth?
I know that I can set the depth on either the duplicate or attatch movie commands but how do I set the initial depth of a movie clip that was not created with either of the two commands?
Thanks
Carter
Setting Depth?
Is there a way to set a movie clip's depth without using the swapDepth function? I wanted to set a clip's depth as another clip has a very large depth. I can't swapdepth in just one instance as the frames are regenerated rendering that useless. All I have right now is a swapdepth function, which obviously makes my one clip show up only half the time. I'm not aware of a depth property, is there one?
thanks
shawn
Setting Depth
Is it possible to change the depth of an object without duplicating it and specifying a new depth? (using duplicateMovieClip)
Setting Depth
i would like to know how (if possible) to set the depth of an MC so when i have a bunch of drag and drop MC's i don't end up clicking and 2 fly together because their so close together on the same 'depth'.... any help would be really great
thnx
[MX] Setting Depth
I have an interface layer above the main layer but the depth of the duplicated movieclips are making them appear above the interface, how do I set the depth of the interface movieclip?
Depth Setting
Hi
I've set a series of movie clips buttons to automatically assume the highest position on on mouse press - however, I'd like the movie clips to remain under (a lower depth) a movie clip (a 'picture frame') on another higher layer.
The depth change for the movie clip buttons was achieved using:
on (press) {
//Start Dragging Movieclip Behavior
startDrag(this, false, 168, 224, 564, 476);
this.swapDepths(this._parent.getNextHighestDepth() );
//End Behavior
Any ideas on assigning a higher depth to the 'picture frame' on the highest layer - so effectively the movie clip buttons remian underneath it.
I tried masking but not working.
Thanx
Dirk
Depth Setting
i have a movie clip on the stage, and i need its depth to always be higher than everything, but other movieclips are being duplicated constantly. How do i do this?
Depth Setting
Hey everyone. I know when you assign an empty movieclip or a movieclip to the stage via actionscirpt you have to set a z depth on the layer.
Is it possible to change the depth of the movie clip? If so how?
cheers lovely people.
Setting Depth
hmm, I have some windows opening up within my flash site that you can click, drag and minimise like normal windows. However I cannot seem to get them to move to the top when you click one.
I can't change the depth upon a click, or upon anything actually.
Does anyone know what the function would be to change the depth of a movieclip.
In fact while I'm at it. Does anyone know how to make my movieclip stop being click-throughable by the mouse. I have a window open and I can still click menus behind it?
Thanks again,
Gaz
Setting Depth Of Movieclips
I have some movieclips on the main timeline that sit to the side of the stage. When a button is pressed, a function is called and these movieclips
float randomly across the stage. They are random also in there speed and therefor overlap each other. I have another movieclip that sits on the main timeline that sits on the stage at all times. I want this movieclip to overlap all of the moving movieclips as they float across the stage. How would I do this? Is there a way of setting the depth of a movieclip at the beginning of the flash movie instead of swapping the depth? If so, can more than one movie be at the same depth? But this may be a problem since the moving movieclips overlap eachother randomly.
Manually Setting Depth
Hey everyone,
Don't know if this question belongs here, but anyways here it comes :
Is it possible to manually set the depth of a movie clip (at creation time or at runtime) without having to duplicate it?
Thanx in advance
Setting MC Depth With Actionscript...
Hi,
I have 4 MCs (little airplanes) that fly around my stage (viewed from the god's eye view). Depending on the position on the stage, certain airplanes need to be higher than others. I am trying to find a way to dynamically change the depth of each MC depending on its position on the screen.
I've tried using the swapdepths() function but it doesn't seem to work for me. I may not understand it. Basically there are three "altitude levels" and so to put an MC/airplane at the lowest altitude I .swapdepths(0) it...and to put it at the highest I .swapdepths(2) it and to put one in the middle I .swapdepths(1) it. But this doesn't seem to work for me. The airplanes still fly under or over each other without me being able to affect it.
I've searched the forums and the only thing I've come up with is that depth seems to be a pain in the rear. Can anyone skool me? Thanks in advance.
Setting And Changing Depth
Hi. Have been having issues with setting and changing depth.
I have an interface with 7 MCs. When you click on one, it scales via tween to fill the stage.
How do you make this the highest depth, and then send it back again?????
Have been using:
_root.MC.swapDepths(getNextHighestDepth());
Is there another way???
Thanks!
WN
Components And Setting Depth
I have an easing scrollbar component in my Flash document that always appears in the foreground, regardless of what layer its on (screenshot attached).
Looking around the Web, I figure that I have to somehow manage the depth of the component, but I can't figure out how.
What's the easiest way to script the depth of a component so that it doesn't cover the topmost layer of my presentation?
Thanks.
Setting The Depth Of A Movie Clip?
Hello,
I need to set the depth of MovieClip: BackBox
The reason is so it will be on top of everything else in the time line, even Duplicated MovieClips.
Please help me with code.
THanks
Setting Depth For Movie Clips..?
Not sure exactly what I need to accomplish otherwise I'd probably have figured it out, but I have lots of text fields being created dynamically in an animation during runtime. I have a pre-made movie clip (just a graphic but had to make it a movieclip so I could give it an instance name to change properties on it) that needs to be on top of everything else, including the dynamic text fields (and a movie clip with a curveto drawing in it, also made at runtime).
How can I get the pre-made to be over everything else? Even if I could retain it in the library then generate it into the animation during run time, thus making it on top perhaps, that would work. Not sure exactly how it would be done either way.
Setting Depth For An Instance On The Stage
Hi gang,
This is an easy question that for some reason is escaping me. I have a MC instance on the stage that becomes the mouse cursor when the swf is loaded, and a linked mc that is dynamically generated to travel across the stage. All of that is working just fine, but I wanted the cursor to be set to the highest depth so that it's on top of everything else. I think I know how to set depth to a dynamically loaded mc, but I forgot how to set depth for something already on the stage. Moving the layers around does nothing.
MX04 and AS2.0
Any help is most appreciated!
-Sandy
Setting Depth To An External File
hey FK!
as usual, i am on the path of the learning as3.
here is my question for today? can you set the depth of an externally loaded file?
ex.
I have an image gallery (which is external) loaded into my main app. when you click an image it opens a "pop up" where the image is displayed. in my main app, there are some other elements that i would like to show on top of my image "pop up". so i am trying to figure out how to set the image to go back a step... any ideas?
Setting A Movieclip To The Highest Available Depth
Hi,
I am making a website where I have some thumbnails of images on the first page itself.
These thumbnails are all individual movieclips, acting as buttons....
When a user clicks over a particular thumbnail, the playhead goes to the fourth frame(of that movieclip) and loads a new movieclip (the full version of that thumbnail) already placed at that frame. And as soons he clicks on it again, the playhead comes back to the 1st frame....
Now the problem I am having is that I am not able to place the currently clicked thumbnail's movieclip to the highest depth....such that when the third thumbnail is clicked and the its bigger version is loaded at 4th frame, the previous two thumbnails are overlaying it due to the depth problem....
I am new to depths, and pls help me out to solve this problem...
Thanks.
Setting Depth Of Multiple Draggable Clips - MX
I have a flash movie with several draggable movieclips. I would like to add a 'bring to front' button to each of them. I am having trouble using swapdepth as they do not share the same parent movieclip. Any ideas?
I an using MX
[F8] Problems Dynamicly Setting Depth Of A Line
Hey, I am having problems dynamicly setting depth of a line that I drew from actionscript. I use this in an onclipevent(load) to make a clip to draw a line.
Code:
_root.createEmptyMovieClip("wallpiece"+instance, instance);
after that I would draw a line. The line draws fine but it is in front of all the other instances. In other instances I use this code. In the script I calculate the depth and "try" to set it with this
Code:
_root["wallpiece"+instance].swapDepths(this.newdepth);
Is it even possible to dynamicly set the depth of a dynamicly drawn line?
Setting Display Objects To The Highest Depth
Say I have a number of buttons placed on my stage. On roll over - I want this button to expand along both x and y axis. So I want my button to be on top of all the other buttons - otherwise there is high risk that the other buttons will lie on top of my expanded button.
I have found a quick and dirty solution:
ActionScript Code:
private function onMyButtonOver(e:MouseEvent)
{
removeChild(DisplayObject(e.target));
addChild(DisplayObject(e.target));
}
In the old days you would use getNextHighestDepth to be sure to put something on top. The solution above works but I find it kinda ugly. Any thoughts?
Snow Effect Without The Mouse Effects Required [asdvanced Snow From Free Source]
Hi all.
Managed to find this really cool snow effect but trying to remove the mouse interaction, but in doing so the snow seems to stop or fade after five or ten seconds due to removing the mouse elements, however if they are in place without any hit with the mouse the snow still continues to fall regardless so in effect I need the snow to keep running without any effect from the mouse, here is the actionscript as below. Any help would be great.
cheers
ActionScript Code:
//var total = 0;//function setQuality(thisSpeed) { if (thisSpeed == 1) { total = 100; } else if (thisSpeed == 2) { total = 300; } else { total = 400; }}setQuality(_global.speed);/////////////////////////////////////function createParticles() { for (var i = 0; i<total; i++) { this.ele.attachMovie("bit", "bit"+i, i++); var clip = this.ele["bit"+i]; clip.force = 0; clip.mn = 1+Math.random()*1.5; clip.x = Math.random()*2-0.75; clip.y = Math.random()*2; clip._x = (Math.random()*this.frame_mc._width)+left; clip._y = Math.random()*200-220; clip._xscale = 70+Math.random()*290; clip._yscale = 70+Math.random()*290; clip.ct = Math.floor(Math.random()*60); clip.c = 0; clip.onEnterFrame = function() { this.c++; if (this._x<_x/*mouse*/) { this.x -= this.force; } else { this.x += this.force; } if (this.force>0) { this.c = 0; this.force *= 0.6; if (this.force<0.05) { this.force = 0; } } if (this.c>this.ct) { this.x = Math.random()*5-1.5; this.c = 0; this.ct = Math.floor(Math.random()*60); } this._y += (this.y+this.mn)-(this.force*9); this._x += this.x; if (this._x<left-5) { this.x = Math.random()*5-1.5; this.force = 0; this._x = right+2; } if (this._x>right+5) { this.x = Math.random()*5-1.5; this.force = 0; this._x = left-2; } if (this._y>_y/*mouse*/-25 && this._y<_y/*mouse*/+25 && this._x>_x/*mouse*/-35 && this._x<_x/*mouse*/+35) { this.force += Math.random()*5; } else if (this._y>=bottom+5) { this.force = 0; this.x = Math.random()*5-1.5; } }; }}///*function clearAll() { for (var i = 1; i<=total; i++) { removeMovieClip(this.ele["bit"+i]); }}*///createParticles();//stop();
Setting The "depth" Of An Object
okie... heres the problem... i have an object sorta like an IE window ... basically the same layout... the DOM of the FLA is as such...
scene 1
portfoliowindow
square_mc
inside square mc are abunch of buttons that affect either portfoliowindow or square_mc. portfoliowindow is just a MC that has multiple frames of the taskbar button (to simulate the effect of opening and closing windows) squaremc is all the actual buttons and such that make up the browser window...
so the problem... square_mc is a dragable object ... im trying to create the effect of window focus... swapdepths works great... problem is... it stops all the butons set INSIDE square_mc from receiving mouse events... so the startdrag and other options i have working dont do anything...
any ideas?
Falling Snow - Showing/Hiding The Snow
Hey everyone,
A question someone asked me earlier was how to make the snow disappear or reappear at a certain point. For example, you may want the snow to fall in Frames 1-30, but beyond that, you would not want any snow to fall. The code I had provided in v2.0 of the tutorial did not address that, so until I write a modified tutorial, I have provided the FLAs (for MX) that help you to control when you want or don't want the snow to fall
I have provided two variations of the Falling Snow file. One method stops or starts the falling snow by having you press a button (the white/pink circle on the bottom left of the animation). The second method displays the falling snow for about 30 frames, and then it stops displaying the falling snow.
The primary thing you will need to consider in this new version of the falling snow is your placement of:
ActionScript Code:
_root.run = 1 // displays snow
- and -
ActionScript Code:
_root.run = 0 // hides snow
Also, I made some minor modifications to the actual Falling Snow code found on the snow movie clip, and that can be found here:
ActionScript Code:
onClipEvent (load) {//variableswidth = 300;height = 200;//random x,y, and alpha this._xscale = this._yscale=50+Math.random()*100;this._alpha = 20+Math.random()*50;//random x and y for flakesthis._x = -width+Math.random()*(3*width);this._y = -10+Math.random()*height;//speed and trigonometric valuei = 1+Math.random()*2;k = -Math.PI+Math.random()*Math.PI;rad = 0;this._visible = false;}onClipEvent (enterFrame) {//////////////////////////////////////if (_root.run == 1) {//////////////////////////////////////this._visible = true;// horizontal movementrad += (k/180)*Math.PI;xmovement = _root._xmouse;this._x -= Math.cos(rad)+(xmovement-(width/2))/50;// vertical movementthis._y += i;// remove clips when they misbehave (overstep boundaries)if (this._x>(width+50)) {this._x = -45;this._y = Math.random()*height*2;}if (this._x<-50) {this._x = width+45;this._y = Math.random()*height*2;}if (this._y>=height) {this._y = -50;this._x = -width+Math.random()*(3*width);}//////////////////////////////////////} else {this._visible = false;}//////////////////////////////////////}
The source files should contain everything I have explained here.
Cheers!
Kirupa
Problem About Depth Of Objects..(swap Depth) Plse.help
umph..hello i'm nameg sir
i'm trying to do dragging project. drag isomatric object in small room(isomatric view too) for test installation..(so i necessary have foreground objects,background objects ..u know)
now i can drag many objs. in same movie when i press it , by i use swap depth command (for see it above other)and drag it around sometime it works...but sometime it don't!...
1..... some obj. automatic swap its depth! when i release other one....i don't know why
2. some time i dup. new obj. to drag and it del some old obj. that call before
ps. i use swap code from this site tutorial ...s.a.Drag & Drop / Swap DepthsAuthor by : estudioworks
thank u so muchhhhhhhhhhhhh
Snow, Blummin Snow
Hey Guys,
What a nightmare! I love the Snow tutorial our god of Flash, Kirupa, did but I can't seem to take the code etc and bung it into something I'm working on.
It's bloody strange, everything is exactly the same. The names, the vars, the timelines, the sizes, the Flash version, even the bloody colours, but it still just grinds my system to a hault and prompts me to stop the script. This all happens when I export/preview obviously.
Anyway, it's here www.tigeralex.co.uk/MYTEST_SOL.fla
Would love some help?
A dearly grateful, Alex.
Snow Glorious Snow
Hello all,
Hate to cross post this, but I'm not getting any takers over in the Flash 8 forum.
I am using the snow method wonderfully created here on Kirupa and have a quick question.
Currently, the movie just starts with a screen full of snow. I'd like to get it to start off screen and fall in. Basically setting an initial state for the ._y of 0. I also can't seem to get a delay working for the function. Ideas?
Thanks!
ActionScript Code:
var movieWidth = 470;var movieHeight = 230;createEmptyMovieClip("snowholder",this.getNextHighestDepth());function makesnow() { for (var i = 0; i<500; i++) { var clip = snowholder.attachMovie("snow", "s"+i, i); clip.i = 1+Math.random()*2; clip.k = -Math.PI+Math.random()*Math.PI; clip._xscale = clip._yscale=20+Math.random()*100; clip._alpha = 75+Math.random()*100; clip._x = -10+Math.random()*movieWidth; clip._y = -10+Math.random()*movieHeight; clip.finished = false clip.onEnterFrame = move; }}function move() { this.rad += (this.k/180)*Math.PI; this._x -= Math.cos(this.rad); this._y += this.i; if (this._y>=movieHeight) { if(!this.finished){ this._y = -5; }else{ this.removeMovieClip() } } if ((this._x>=movieWidth) || (this._x<=0)) { this._x = -10+Math.random()*movieWidth; this._y = -5; }}function removesnow() { for (var obj in snowholder) { if (typeof snowholder[obj] == "movieclip") { snowholder[obj].finished = true } }}makesnow();setInterval(removesnow,5000);
Snow 3.0 Help - End Snow Function
Hey !!
Im using the Snow 3.0 effect but i need a bit of AS that will end the snow effect once the playhead has left the frame
or a bit of AS that will end the function once a button is clicked or something like that
cos the snow still falls after i leave the frame !!
Question About Depth And Highest Depth
Hello hello
I am learning AS and am now at the depth story.
I have questions about it : when I create an empty mc, where different swfs will load in ( loaded on main stage by several movie clips) is it interesting to use the getNextHighestDepth command ??
Thank you action scripters !!!
Quality Setting - Changing The Default Setting?
Whenever people go to my site www.findraf.com I find that the quality is set to Medium by default and most people don't know computers enough to realize how easy it is to change it. Any idea's how to change this?
Dynamically Setting Labels Or Dynamically Setting Frames To Print
1. Does anyone know if there is a way to dynamically set a frame label. The reason for this is that I want a particular frame to Print with other frames (requiring a frame label of #p) if you answer a question a certian way and not to print with the other frames (needing a different label or no label at all) if the question is answered differently.
2. Option #2 would be to be able to dynamically set which pages print when you call the "PRINT" command (probulary through an expression). Any ideas would be appreciated.
thanks
Snow On Tv
Hello all,
Everybody has seen it on tv. The channels where there is nothing but snow. I would like to do the same in Flash but I have no idea how I would do this. Could somebody give me some help.
Thanks
Snow In MX?
Hi all!
Is it possible to have falling snow that settles and builds up in certain areas on the stage?
Thanks in advance
Andy
Snow
I am making a Christmas card with flash mx and I am using actionscript to make it snow. Could somebody check my code and tell me what is wrong with the part I mared red.
// general
Blow = function () { if (!(random(75))) {windTarget = (random(21)-10)/3;}wind += (windTarget-wind)/20;};
// snowfall
MovieClip.prototype.addFlake = function() {
this.attachMovie("snow", "s"+++this.depth, this.depth);
var me = this.flakes[this.flakes.length]=this["s"+this.depth];
me.x = random(500)-100;
me._xscale = me._yscale=random(75)+26;
me.scale = me._xscale/100;
};
MovieClip.prototype.killFlake = function(i) {
this.flakes[i].removeMovieClip();
this.flakes.splice(i, 1);
};
MovieClip.prototype.LandFlake = function(i) {
var clip = _root.landscape.snow;
clip.attachMovie("snow", "s"+++this.depth, this.depth);
var me = clip["s"+clip.depth];
me._x = this.flakes[i]._x;
me._y = this.flakes[i]._y;
me._xscale = me._yscale=this.flakes[i]._xscale;
this.killFlake(i);
};
// flakes
MovieClip.prototype.fall = function() {
this._x = Math.cos(this.t += .1)*10+(this.x += _root.wind*this.scale);
this._y += 3*this.scale;
};
MovieClip.prototype.isInBounds = function() {
return (this._x>-100 && this._x<400 && this._y<300);
};
MovieClip.prototype.isTouchingLand = function() {
return _root.landscape.hitTest(this._x, this._y, true);
};
Thanks
Snow Tv
hi i saw somewhere on this site a tv with snow on it does any1 has a link to that b/c i can't ifn it anymore ore got something thats simulair
Snow
Do anyone know how to make the snow. (many white object fall down endlessly)
I have thought of a method by inserting layer and creating motion guide.
But it is complicate and cant make it endlessly.
Can someone know how to make it by actionscript or have any ideas of making snow?
Thanks
Snow
Hey, before i start visit this site: www.synphia.com It isnt any spyware,xxx or such site, its a finnish company that make homepages. I now assume that u have visited the site and hopefully can tell me how i make those snowflakes but the "site itself, and text" still being visible. Now i'm not really a newbie but in this case i dont see it going since the flash movie wants it own space, am i right ?
Snow
I'm using a snow scene in one of my xmas cards (see code below). I'm not an expert at action script, so can anyone give me the code to stop it snowing without coming out of the scene?
thanks.
Mike
(i = 0;
while (Number(i)<>250) {
duplicateMovieClip("/snow", "snow" add i, i);
i = Number(i)+1;
}.
Help With Snow Tut. AS
Could someone PLEASE help me script the snow to my dimensions:
Stage 600 wide x 400 High
I only want the snow in an area 432 Wide x 296 High at the X=80 y=52 position
I've tried scripting it and totally messed it up...again & again & again. I'll never learn this stuff :<(
Here's the original script:
onClipEvent (load) {
onClipEvent (load) {
//specifies the size of the movie stage
movieWidth = 300;
movieHeight = 200;
//variables that will modify the falling snow
i = 1+Math.random()*2;
k = -Math.PI+Math.random()*Math.PI;
//giving each snowflake unique characteristics
this._xscale = this._yscale=50+Math.random()*100;
this._alpha = 75+Math.random()*100;
this._x = -10+Math.random()*movieWidth;
this._y = -10+Math.random()*movieHeight;
}
onClipEvent (enterFrame) {
//putting it all together
rad += (k/180)*Math.PI;
this._x -= Math.cos(rad);
this._y += i;
if (this._y>=movieHeight) {
this._y = -5;
}
if ((this._x>=movieWidth) || (this._x<=0)) {
this._x = -10+Math.random()*movieWidth;
this._y = -5;
}
}
|