ActionScript 3.0 :: SetChildIndex Seems To Have No Effect?
Jan 21, 2010
I am trying to set a Sprite's z-index to topmost on mouseOver. In my mouseOver event I am calling:this.parent.setChildIndex(this, this.parent.numChildren - 1);If I trace the index of this before and after the call, the index has changed but my sprite still appears to be behind it's siblings.I am changing the scale of the object on mouseOver as well
I'm trying to use the setChildIndex(); property to move a mc to the top of the stage when that particular mc is clicked on. I'm still not sure what is meant to go in the parentheses? Sorry, still new to AS3.0. The mc has it's own class called Ball and this is where I'm calling the setChildIndex property, in the dragIt function. Here's the code for the Ball class....
know how to set the Child Index for a video inAS3 ? I have a class that extends the video class and I call it from my main class file. In my main class file I have other Movie Clips that I wan to put on top of the video instance
For the life of me, I cannot understand this method. The help files are confusing to me, and I can't locate anything else on the web that explains how it works.
What I have is an array of 5 objects closely in a row, that tween and expand on a MOUSE_OVER. Trouble is, I want the object to be in front of the others on the MOUSE_OVER, but part of it is always beneath the object to its right or left. Here's the code I have:
function setupVars(e:Event):void { trace("Entering setupVars"); //The following removes the Event.ENTER_FRAME listener so that it does not activate 30 times a second. removeEventListener(Event.ENTER_FRAME,setupVars); var myArray:Array = [box1_mc, box2_mc, box3_mc, box4_mc, box5_mc]; for(var i:Number = 0; i < myArray.length; i++) { myArray[i].addEventListener(MouseEvent.MOUSE_OVER, boxOver); myArray[i].addEventListener(MouseEvent.MOUSE_OUT, boxOut); myArray[i].buttonMode = true; } } var box:Tween; var box2: Tween; function boxOver(ev:Event):void { box = new Tween(ev.target, "width", Elastic.easeIn, 100, 130, .5, true); box = new Tween(ev.target, "height", Elastic.easeIn, 100, 130, .5, true); trace("yay, it works") }
function boxOut(ev:Event):void { box2 = new Tween(ev.target, "width", Elastic.easeOut, 130, 100, 1, true); box2 = new Tween(ev.target, "height", Elastic.easeOut, 130, 100, 1, true); trace("yay, this one works, too") } Could someone be so kind as to help me with the setChildIndex method? I want any particular box to be in front of the others on the OVER.
What I have is an array of 3 pictures in a column, that expand on a MOUSE_OVER. I want the picture to be in front of the others on the MOUSE_OVER, but part of it is always beneath.
Code: var thumbnails:Array = ["IMG_1258.JPG","IMG_1417.JPG","IMG_1428.JPG"]; var studioGallery:MovieClip = new MovieClip(); addChild(studioGallery);
[Code]....
I tried to add the following line of code on OnOver as I saw it in another thread, but it gives me an error message:
I am creating multiple sprites on the stage using structured classes as shown below, I would like every time I click on one of these sprites to make it go on top of all previously created sprites. I would also like to know if this can be implemented from within the last class "class c" onMouseDown function.
I'm making an android air application for school, a sketch app.But I'm facing an annoying problem, when I'm drawing I can draw over my bar and my menu, here's some code:
[code]....
--> so this is the function for drawing a shape on stage the shape is declared as
Actionscript Code: public static var brushDraw:Shape = new Shape();
now the problem is that I can draw over my menu and everything. Putting the setChildIndex of brushDraw to 1 doesn't work, it gives some error...
In Flash, some of the objects I put on the stage directly (e.g. mc_), and some of the objects are using "add child" function to be put on the stage.For some reason, I need to use setchildIndex function in frame 15 to bring the object (mc_A on the top my stage.But this causes a problem that is, object A is always there from frame 1-15.Actually I don't need mc_A on frame 1. So in order to remove object I use removeChild or set mc_A.visible=false, but it doesn't work because I got the typeError said "TypeError: Error #1009: Cannot access a property or method of a null object reference." I know it makes sense because mc_A is not in frame 1. Of course, it couldn't access to the object.I attach an example file, hope it could describe my problem more clearly.Attachments:setChildIndex.fla.zip (7.2 K)
I have an XML file with a path to a number of images which I load to the stage.
Code: public function popStage():void{for(var i=0; i<xml.projectInfo.length(); i++){var picLoader:Loader = new Loader(); var picHolder:Sprite = new Sprite(); picLoader.load(new URLRequest(String(xml.projectInfo[i].image)));
[code]....
What I want to do is bring the infoBox to the top Index than bring the image to the top index after that so that the logo is over the infoBox. The infoBox is no problem but I can't seem to get the code right for the target to have the top index. I have tried a number of variations and done some research but no luck. [URL]
I am trying to do is dynamically place movie clips into a container called container. when I roll over the movie clip I need it to show on top.. right now its either not showing up on top or I get an Error #2006.. out of bounds... Below is my AS3 code that I created to do what I want.. so far everything is working except the rollover effect..
PHP Code: import caurina.transitions.*; var imgHolder:MovieClip; for (var i:int = 0; i < 6; i++){ imgHolder = new imageHolder(); imgHolder.x = (imgHolder.width + 3) * i; [Code] .....
I'm having reel trouble trying to bring a movieclip to the front using setChildIndex. I have 3 movieclips that are being loaded into a movieclip that sits on the stage. I'm using:
the code which works over stage, is not working properly over a movieclip..sample, i have many objects to stay at different indexes at flash..with that code block below. I add 300 mc's to stage,
Code: for (var j:Number = 0; j<300; j++) { var mc2:MovieClip = new MovieClip(); stage.addChildAt(mc2, j); }
TO be able to change indexes with different items.. i have random movieclips which have to be placed indexes between 5 and 300.. And everything goes great when i do this directly at stage..But when i do this with a movieclip.. example;
Code: for (var i:Number = 0; i<300; i++) { var mc3:MovieClip = new MovieClip(); my_mc.addChildAt(mc3, i); }
i can't see the movieclips inside.. but i know they are at their right indexes..but somehow they are getting behind those fake movieclips..
I've got a movie with some buttons in the middle of the screen. I've got a tween on the buttons to make them grow/shrink on rollOver/rollOut, when a button is clicked, I've got a frame animation that moves the buttons to the top of the screen and shrinks them. This all works fine.
When the buttons grow, they need to appear on top of all the other buttons. Since there's no more swapDepths, I'm using setChildIndex to move the rolled over button to the top. Now, when I click one of the buttons (after rolling over it), any of the buttons I've rolled over aren't affected by the frame animation.[code]...
I have a bunch of movie clips set up to the same instance names as the ones mentioned in the follwoing code using this. however I am trying to make it so that when clicked, the mouse click event will cause the selected item to be set to the front of the stage and not to be overlapped by anything in front of it. I have been doing research and know its done using setChildIndex but evertime I try and implement it I get errors I muse be doing something wrong could one show me in this code where the 2 or 3 lines of code would go?
I have this script I am writing where when someone hovers over a button it displays a popup box until they roll off. I have that function working alright, but I need the movie clips to swap depths, I realize I can do this with setChildIndex but I'm running into a small problem with my children/parent situation. My items are added as such: root > color_mc (blue or red or whatever) > button (this is the hover) I have the event listener added to the button for each color, but I need it so that when the button is rolled over, it takes the color_mc and moves it to the -1 spot. I've tried writing the code a number of ways but can't seem to get it.
Code: function manageMouseOver(event:MouseEvent):void{ var parentClip = event.target.parent.name; parentClip.setChildIndex(parentClip, parentClip.numChildren - 1); event.target.parent.gotoAndPlay(2); }
That code gives me the following error: Error #1069: Property numChildren not found on String and there is no default value.
i tried all 3 of these, and i get errorReferenceError: Error #1065: Variable TLFTextField is not defined.orTypeError: Error #1034: Type Coercion failed: cannot convert "instance207" to flash.display.DisplayObject.
at menucaller/self_overHandler() Code: Select all private function self_overHandler(event:MouseEvent):void {
I am adding movieClips to the stage. I then am able to change the index of each movieClip, by moving some mc's behind or in front of one another. Prior to uploading these mc's to my database, I get their index locations. Let's just pretend we are working with 3 mc's (even though it could be unlimited). I grab the index of these mc's, and I get (35, 2, 38). I then send this information to the database. Looking at those numbers, we can tell there are a ton of objects on the stage. Information is sent to DB, and now I open up a new FLA, ready to get the information.
Now I want to get this information, and add the mc's to a container, in the same exact order they were in before. Because I am adding them to a fresh container, and there are no other objects within the container, these will obviously be out of bounds (except for the one mc at index "2"). I understand they are out of bounds because unlike when I sent them to the DB, there were tons of objects on the stage. This time, there is only the container, and the 3 mc's, so their old index of (35, 2, 38) won't work.
I'm working a project where images expand 50px on roll_over and then retract on roll_out. On roll_over the images overlap and I use the setChildIndex to keep the target on top. This works fine. What I'm having issues with is the border that is displayed on roll_over. The first time I cycle through the images, everything works fine, after that only the image stays on top, the border slides underneath the other images. I looked up the Adobe 'setChildIndex' I'm afraid I don't understand the numChildren-1 thing.
I have a movie clip with 5 frames. When I'm on frame 3 (main game play) and I use the setChildIndex command on an on-screen element that exists on the frame itself, the element in question will now be permenantly added to the stage, and will persist across the remaining frames (end level and end game). This behavior was not present in the project until I converted it to CS5. If I remove the setChildIndex command, the on-screen elements stop sorting their depth (as your would expect) and they no longer bleed into the next frame which is for level ending.
I am also having trouble with a dynamic text field. It's currently set to not be selectable, but when you mouse over the field it shows the cursor symbol for your mouse pointer, and when you click over it, a small block highlight appears on the left or right side of the field. You can't change the field contents, or even select them, but when you try a small selection black mark appears on the end of the field. I've destroyed and recreated this field, and the bahavior seems to be staying the same.
Inside of movieclip on keyframe i want a script that tells to swap depths between 2 mc's that are on main timeline. When i use setChildIndex inside of mc flash hits me with Error #2025.
I am trying to use setChildIndex() to bring the current movieClip to the front. I have the following code on the first frame of the TimeLine. setChildIndex(currentMovieClip,numChildren - 1); And am getting the following errors. Scene 1, Layer 'Layer 2', Frame 1, Line 20 1093: Syntax error. Scene 1, Layer 'Layer 2', Frame 1, Line 20 1084: Syntax error: expecting rightparen before 1. Should I be using stage or something else is wrong?
I get this error: TypeError: Error #1034: Type Coercion failed: cannot convert mcBlad$ to flash.display.DisplayObject.at Notitieblok_fla::MainTimeline/backCard()
trying to on mouse over set the parent of the moused over text field to the highest depth child of its parent i tried both of these: [code] private function
check out: [URL] The typewriter effect here is very fast, much faster than when I use onenterframe to produce the effect. Does anyone know how this is done?
I really like the text effect Pom used in the footer contest, and would like to use the same grid-type method of creating mc letters but with a different effect. i understand how to change the parameters and shapes of the letters, but can't seem to figure out which piece of code is purely for the explosion effect. basically, i want the letters but with the 'Repel' effect from[URL] here is Pom's AS:
[AS] cellSize=3; radius=10; damp=.85;
[code]....
and here is the .fla using the repel effect using pre-made mc:
It's a bit of decoration to go behind a logo. When the dMove var is commented out I get the appropriate line of squares fading in and out at random spots along the x = 78 axis, but when introduced nothing appears at all...