AS2 - Giving A Movieclip A Specific Depth
Feb 15, 2011I want to give a movieclip a specific depth number, but i cant found a method for this.
View 2 RepliesI want to give a movieclip a specific depth number, but i cant found a method for this.
View 2 RepliesI've got this new problem where I'm trying to remove a container movieclip i've attached the first time the function is run, but I try to remove it and replace it again, but the second time around it gets a negative depth and all goes to hell.
Code:
function populateBasket(){
trace("B4 REMOVE:" + basketRows.loader.container.getDepth());
basketRows.loader.container.removeMovieClip();
[Code].....
I have managed to load external swf's fine and also unload them when a new one is loaded, but now I need the swf's that are loaded to appear below (meaning on a lower layer effectively) than my navigation, which is in the main swf. I hope that makes sense.I can get that to happen by creating a movieClip on the stage on a layer beneath the one my navigation is on and loading the swf into that mc, but then I don't know how to clear the swf from that mc so another one can load there in it's place.Here is the code I have so far:
Code: Select all//Universal Button Function
function buttonClick(event:MouseEvent):void
{
/*removeChild(target_mc);
[code]....
putting a movieclip into highest depth without knowing which clip is in the highest depth
View 2 RepliesIf n=1,b1.gotoAndStop(2); is to happen.n=2,b2.gotoAndStop(2); is to happen.But i don't want to put conditions like this.I want to putting something like this:b[n].gotoAndStop(2); or something.Is it possible.Is there any other alternate logic.
View 2 RepliesI have a Android Air application, where I import a png image to the stage on frame two and converted it to a symbol as a movieclip. I am performing a hovering animation using this image as a movieclip and it works great but when I go from frame 2, where the animation is, and I move to frame 3, 4, 5, or 6, and then I move back to frame 2, my application throws a errors when referencing the movieclip again. The error is 1009 cannot access null object reference. So to me it seems that once the timeline moves away from frame 2 it wipes away the reference to the imported image converted to a movieclip....is this correct? Is there a way I can keep the timeline referencing the this image as a movieclip so I can always come back to this frame?
View 1 RepliesI have this movieclip that i made in flash. How would I go about duplicating it and giving its parts instance names using AS3?
View 3 RepliesI am making a game where I reference "Player_mc" quite a lot. I have a bunch of full characters (movieclips) in the library that work as the player when put on the stage and referenced as "Player_mc". I need a code that can reference those characters (movieclips) in the library, and move them onto the stage and name them "Player_mc". Also I need a way of removing an existing "Player_mc" so that another character can be referenced and brought onto the stage as "Player_mc". Here is what I have: if (this.P1Character==(Whatever that character's number is)){
View 3 RepliesI'm trying to place an instance of a movieclip (instance name: tehMovieClip) from the library within another movieclip (instance name: parentMovieClip) on the stage. tehMovieClip, the movieclip going inside another movieclip, belongs to a class called CollisonDetection (linkage properties, class:CollisonDetection, Base Class: flash.display.MovieClip). When I put tehMovieClip inside parentMovieClip, I get this runtime error:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
If I just place tehMovieClip on the stage by itself, it works fine but I need it to be inside parentMovieClip.
ERROR 1046: Type was not found or was not compile-time constant:textline.
I have nested my animation into a movie clip and have tried to use a pre-loader on it. The nested movie clip opening screen as a button on and the second screen as back and forward buttons. The movie clip works fine no problem until adding it to the pre-loader. The code for the pre-loader is (below) on frame 1 frame 2 to is tells it to stop and also were my nested movie clip is
function loadProgress(my_content:ProgressEvent):void {
var percent:Number = Math.floor( (my_content.bytesLoaded*100)/my_content.bytesTotal);
myLoadText.text = percent + "%";
} function loadComplete(e:Event):void {
currentFrame + 1;
} loaderInfo.addEventListener(ProgressEvent.PROGRESS, loadProgress);
loaderInfo.addEventListener(Event.COMPLETE, loadComplete);
I'm trying to get the following movieclip smallbutton to link to frame 5 on movieclip cont.The way the timeline is built is as so:content_mc > cont > (more mcs) > smallbuttonThis seems to be an issue from every answer I've tried so far since the movieclip "cont" is not being called in the main timeline; first there's content_mc and then comes cont.How would I go about getting the movieclip "smallbutton" to link to the 5th frame of movieclip "cont"?This is for AS 2.0So far I'm at:on (release) { _root.gotoAndPlay("cont"); _root.smallbutton.gotoAndPlay(5);
View 7 RepliesI m looking for method similat to MovieClip.swapDepths(depth).what is the method in as3, i have movieclips i wanne update those deths
View 4 RepliesHow can I set the depth for a movieclip.Actually I want my popup to always come on the top and there is some problem using swapdepth.Would it help setting the depth of movieclip to be something like 10000??
View 1 RepliesIm trying to change the depth or index of a movieclip when its click. And bring it to the top of everything. The problem is that the movie clip is not added by addChild, but nested in a frame.
so if i try and use any of these:
anyMC.parent.setChildIndex(anyMC, anyMC.parent.numChildren-1);
or public function bringMCToFront($mc:MovieClip){ $mc.parent.setChildIndex($mc, $mc.parent.numChildren-1);}
by it gives me this error: Error #1065: Variable setChildIndex is not defined.
Im trying to keep all my movieclips onto 1 layer/mother mc to speed up the flash display engine
I have these takable items(movieclips) that respawn after a while.
Initially i build the level starting with all the takable items before adding all the players/npc's. This way the player and npc's walk over the objects if they are not taken.
After an items respawns though, i have to re add them to the main mc and then they appear to be over the npc's and they seem to be moving under a carpet of stuff.
Its a nice 3d effect but totally unwanted in this scenario.
Is there a way to make sure that items are added as child before a certain clip (like the player). I tried using addchildat but this gives me a index error now and then. I dont really understand how the depths are worked out by flash.
I was thinking of storing the original depth of an item movieclip and then on restore, addchild at at its old depth. Or is there a more sensible way?
Also: can two movieclips occupy the same index/depth level? or are the incemented or something?
I have 4 movieclips on my "layer1". Everytime my mouse is onRollOver of a movieclip, I just want THIS movieclip coming to the FRONT, that's to say the Highest Depth.
(in Visual Basic, "ZOrder(0)" is simple.. but harder in ActionScript.. lol )
I've found some many examples "around" this, but did'nt success to adapt the code to my simple needs !
Is it possible to keep a movieClip at the lowest depth and stack other movieClips on top. I have a container movieClip that I add a movieClip called floorTile. I want floorTile to always be at level 0 no matter what. Then when I click on another movieClip, I want this to be added on top of the floorTile.
ActionScript Code:
//create a container to hold the floor tile and textures
var myContainer:MovieClip = new MovieClip()
myContainer.x=425;
[Code]....
the question is a bit more involed. I have a dynamic text box, which I've put inside a movieclip. I hae a number of movieclips that I bring in using attachMovie, but my movieclip which contains my text box is underneath all the other movieclips.
I would like to know how I can tell my movie to display above all the other?
I have a slide show of images for my banner that is loaded through the use of a component in my library. The component merely swaps images with a fade out/in as a transition. Now, that is working fine, the thing that I am having a problem with is that I cannot place an graphic/text on top of the component. I what the banner to be in the background. What do I have to add to the component to insure that it will always load in the back, not infront of the text, graphic, etc...
View 1 RepliesI started with some AS2 pageflip code that I've been modifying because I needed the code in AS3, and I wanted to make some changes to it. At anyrate, I'm having a problem with the depth of two movieclips created. The code first creates a page using the makePage function, and then creates a shade for that page (makeShade function).When running the code, the page appears on top of the shade. When using getChildIndex, the page's index = 11, and the shade's index = 14.
The complete code is super long so I've attached the code that has the shade and page below:
//create left-aligned page-sized solid fill
function makePage(targ, xQuadrant) {
//trace ("in make page");
[code]...
If i wanted to change the depth of a movieclip using AS3
View 2 RepliesI have some code in ActionScript 2 similar to the below snippet (Item being a MovieClip):[code]I'm unable to remove Temp after swapping the depth (works fine otherwise).[code]how to get rid of Temp?
View 2 RepliesI'm trying to get a movieclip to appear at the highest depth from the library.
View 1 RepliesThat you can't remove a movieclip if it's at a minus depth? Is this on purpose, or is it a glitch?
View 2 RepliesDoes anyone know where I can find a tutorial on movieclip depth?
View 3 RepliesIs there a way to change the depth (index number) of a movieClip when I click on it to drag. Example:Say I have three circles. Each circle has a MOUSE_UP and MOUSE_DOWN eventListener. When one is clicked It will bring it to the front so when I drag it will be above the two other circles.
View 7 RepliesI have Macromedia Flash 8 Pro with AS2 and I was wondering if there was a function that would change the depth of a movieclip on rollover of a button.
View 1 RepliesCode:
moviclip.swapDepths(movieclip._y);
and it worked perfectly.
but I decided that I wanted to continue the development of the game in AS3 (so that it will be more up to date and I could learn the new syntax), and I found the equivalent to swapDepths is setChildIndex. so I followed the new rules and came up with this code:Code: setChildIndex(character_mc, character_mc.y);but, sadly it does not work the same. the game becomes extremely laggy and almost unresponsive, but becomes normal again if I remove the code. So, my question is how can I add a similar code for this to work properly.
I have about 85 movie clips on stage and they all have startDrag with MOUSE_DOWN.here is the thing I need the active one to come forward to the top of all others.I tried using:
setChildIndex(e.currentTarget, 85)
on the mouse over function but its not working its giving me an error 1118: Implicit coercion of a value with static type Object to a possibly unrelated type flash.displayisplayObject.
I would like to be able to draw a simple box as a background/placeholder, dress it up with buttons and movie clips at design time, and at runtime call a function to replace the simple box with a new design. How would I go about doing this? I have a graphic design that is too complicated to make with flash. So i made a piece of actionscript that can restyle any existing movieclip. This piece of code works. It basically gets the coordinates of the specified mc, creates a new one in it's place and deletes the original. Unfortunately this also removes any nested movieclips and buttons and breaks animation tweens of this mc. So if the original mc would have a button on it and animates from left to right, the new one doesn't.
mc.clear(); looked very promising, but it only clears stuff you put on it at runtime while I need to clear the stuff from design-time. (= the simple box drawing object)Creating a movieclip with the same name, at the same depth doesn't seem to work. oldbox.parent.createEmptyMovieClip(oldbox._name, oldbox.getDepth()); The old movieclip keeps existing and neither of them animates.So I'm searching for a way to replace a movieclip or clear it's content at runtime.