ActionScript 2.0 :: SwapDepths Random But GetNextHighestDepth Obscures Objects?
Sep 24, 2010
I'm currently trying to create something akin to a simple 'page flip' effect for a site.The effect that I'm going for is basically a changing background, appearing by playing an MC (tweened movement of large rectangle that moves from off-screen to on-screen) that is, ideally, supposed to be executed by a button.
I currently have on the stage, four coloured buttons, with a corresponding MC off-stage that gets triggered by a button and slides on to take the place of the previous MC (background colours that slide in depending on which button you press). I also have a text box embedded in an MC which was basically just a test object that is supposed to stay on top of everything. The stack order should be [top]->[bottom], [text]->[buttons]->[background MCs]
The problem lies in the order of playing the MCs. A background colour rectangle MC should technically cover up whatever background MC is already there. However, when a new MC slides on, the one below it briefly changes to a seemingly random one. The MCs are currently not created dynamically, but I did ponder whether the problem could be solved by dynamically creating them using loadMovie and then removing it when the next one loads or something... I've made it work using swapDepths, but therein lies the problem I think, because swapDepths works by trading depths of MCs and, when giving the MC that you want to appear on top a certain depth, it takes that depth from an MC that already has it, thus causing THAT MC to adopt a new depth and the order seems to change completely... I considered using getNextHighestDepth(), but that obscures the text and, as I take it, getNextHighestDepth() gets THE highest possible depth (I think...), there doesn't seem to be any meaning in assigning a depth, no matter how high, to the text.
// MCs containing coloured buttons
// Plays each coloured button's associated coloured page MC and swaps the MCs'
// depth bringing it to the top of the stack
basically I want my engine to display one out of three objects at random. I thought I had figured it out but apparently not. A familiar error message appears, "A term is undefined and has no properties". I'm sure it refers to the object I'm trying to spawn, however it rejects every object I refer to. Is my approach reasonable or should I scarp what I've got?
Code: var spawnObject:Array = new Array("Object1", "Object2", "Object3"); var randomNumber:Number = Math.round(Math.random() * (spawnObject.length - 1)); if(spawnObject[randomNumber] == "Object1")
I also have code that stops it dragging. What I need answering though is how to make the window get the highest depth (so that it is on top of the other windows after pressing the dragbar. I tried using getNextHighestDepth() but it doesn't seem to be working.
it is possible to have a foreground when using getNextHighestDepth? The problem i have is that unless the foreground is the highest depth then anything else attached after that will appear over it rather than under.
I have a flash movie with some buttons that load swf's into the movie. Here is the code I have attached to the buttons:
on(press){ var container:MovieClip = this.createEmptyMovieClip("weddingClip", this.getNextHighestDepth()); weddingClip.loadMovie("wedding.swf"); }
This actually works fine the first time. The problem is that if I press button 1 and it loads the appropriate swf, then I press button 2 and it loads it's appropriate swf, if I decide to go back to 1, it won't come up because it is already loaded below #2. I would think it would come up in depth.
Here is the link to the site for demonstration purposes: [URL]
i have 3 movie clips,all loaded external into the scene with action script
clip 1 is the background.
clip 2 is thumbnails of photos that pass through the screen from top to bottom.and the clip 3 is a png file that i want to put in front of all other movie clips.My problem is that i cant put the clip 2 between the background and the png file cause the clip 2 uses the "getNextHighestDepth" method because everytime the user clicks on a thumbnail a larger image appears in top of all other layers.
I have an mc (mcBreakOut1) that contains some links (simple buttons) that sits on the root. The mc gets next highest depth on release and plays to reveal the links. The problem is that none of the button actions in mcBreakOut1 seem to work. I don't know if this has something to do with the getNextHighestDepth() or because mcBreakOut1 has an onRelease=function():Void {} function associated to it that is not allowing any onRelease functions within the mc to work.
i have attached the flash file and also xml file. Here i duplicate the movieclip, first for loop is working perfectly but inside of second for loop is not working properly.
I'm creating a game with movie clips that are generated using getnexthighestdepth, and have a pause menu too. However, as the movie clips are generated after the pause menu, they appear above it, partially obscuring it. Is there a way to make the pause menu permanently on top?
i have attached the flash file and also xml file. Here i duplicate the movieclip, first for loop is working perfectly but inside of second for loop is not working properly.
I have a problem with a preloader on a slideshow. The preloader works perfectly the first time the slideshow is loaded but if you move to another frame and then return the loader bar loads in the top left hand corner of the stage and does not function, it just duplicates every time you navigate back to the page.
I have a code here that drops a first row then drops a second row down right after. First row drops right away and second row is on a timer.
// Bring in first row var blueY:Tween = new Tween(blue, "y", Bounce.easeOut, -295, -49, 2, true); var pinkertonY:Tween = new Tween(pinkerton, "y", Bounce.easeOut, -295, -49, 2, true);
[Code]....
How would I drop each cover individually at random between two set numbers? I assume I would have to apply a separate timer for each one then somehow make the time at which it drops random between two numbers?
Flash in general so this is probably above my skill level. Basically I have 3 movieclips, called random1, random2 and random3 for the sake of this.I want, at the start of the frame to pick one of the three objects at random, keep that object visible, and hide the other 2
I'm trying to develop a SWF Api that consists of a game that makes random objects fall from the top, each of them has different points, and then the points the player gets should be stored into a dinamic text called score, when the player doesn't take the ball, loses a life. Then, if the player catches it, the ball disappears and gives the points to the player.
I have 3 separate movieclips, called random1, random2 and random3 for the sake of this.I want, at the start of the frame to pick one of the three objects at random, keep that object visible, and hide the other 2.
I have 4 objects in the library. I use a switch case statement to randomly generate them to the stage;[code]When the user clicks "taskMC", I want to assign behaviors according to which object. If I trace "taskMC" I get the name (object A_Graphic, object B_Graphic etc.)but I can't assign actions to them that way. How do I get object A_Graphic to do one thing, object B_Graphic another thing...?
I have an interavtive module where user drags objects using droptarget. Once items are filled in the timeline moves to a frame where there is only one object. What I dont understand is that random objects continue to show up at the end frame where there is only one object! How do these objects show up?
I am attempting to create a game that will simulate groceries coming down a conveyor belt. The player acts as a bagger and must click and drag the groceries into designated bags (one for cold food and one for non-cold food). When the correct choice is made the food will disappear and the score will increase +1.
I have become overwhelmed by thinking about how to do this and have not found helpful answers that actually work when I try to compile them so I decided to ask. how I can have random grocery items fall down the screen? I assumed I could create an array of movieclips and have them be called to fall down randomly, but I am not sure how this would work.
I'm making a game similar to Kaboom for my actionscript class
[URL]
I realize I'm not even close to done and its probably shitty but this is my code so far:
var bucket:Bucket=new Bucket var sun:Sun=new Sun var fireBalls:Array=new Array()
[Code].....
I know I want to use a timer event or something to get the sun to switch directions randomly but I can't quite figure it out
this is an idea of what the swf looks like (its not loading everything in this simulation, the bucket is on the stage and moves left and right onKeyDown in reality):
I'm trying to create a flash demo for my prof and we want green dots to move randomly across the screen without ever overlapping each other.I saw the kirupa tutorial on random motion which is really good. I'm wondering if I can add something to the code so that the dots won't overlap, (as soon as one touch another they move away) as they move.
With some excellent help from ilike2 I was able to import random objects from a library that can then be dragged to their respective targets (on repeat). However, I forgot to mention that I need to drag more than one of these objects onto the same target and I don't know how to change the actionscript to accommodate this. Would anyone be able to help me with this? In the example below I would also like Blue2 to target targetBlue_mc Here is the code:
I am using the random motion code found here at Kirupa. [URL]I have the code working fine but I have a question about fixing it to my needs. The way it is now, you change the height and width variables so that the objects don't move off the screen. This works fine, if you are using the whole screen area at:
we have this game where you control an avatar in the middle of the stage that defends itself from incoming projectiles. If it hits them with its arms or legs you get a +1, but if they hit the head or torso you get a -1. But cant figure out how to spawn them randomly along a given path. See picture below. Want them to come in from the sides but have the same "destination-area" - which would be the head & torso.
I am trying to make a game where you have random objects falling vertically and must land in a bucket. The bucket is controlled by the mouse(it follows the mouse).
One of my main interests is playing games so I thought why not make a game? I see lots on the Internet games based in Flash so I thought that would be my best starting point to make actual graphic based games... (not to mention I actually got taught at university how to use flash to a certain extent). The game I decided upon was tetris. I'm sure you're all familiar with the block based puzzle game and might be able to shed some light upon what I am doing right and what I am doing wrong. So, I've firstly made my game screen with a window for all the blocks to come down in.
I've also put some dynamic text place holders ready for when I come to keeping track of how many 'lines' the player has scored, the time and so on in the right hand side of the screen. I have made graphics for the different colour 'building blocks' (just one block of 24x24 in different colours for each shape) and then used the 'building blocks' multiple times to create my shapes (I, J, L, O, S, T, Z). These blocks are called tetrominoes. Now I've come to a point where I need to import these tetrominoes randomly from the library and get them to appear in the middle just off the top of my block screen.
How do I import random objects from a particular folder in my library to the stage in Flash CS5 AS3? After realising a quick solution to my problem was not to be found quickly I then thought about what will happen to this block once it has been imported... Well, in Tetris the block moves slowly down until it hits another block or the bottom of the block screen. I know that I can do something with a detectHit() function. How do I get my block to move down the screen by a set amount of pixels every second or so?