ActionScript 3.0 :: Flash Adding Childs Into A Continer, Depth?
Feb 12, 2012
adding children to the stage, Im trying to add two movieclips into a container, then add the container to the stage. The problem is my coins were not displaying (Guessing they were behind my 'map') so after doing a bit of research i discovered the 'getChildAt' function, so i followed the advice and set the numbers to the index i presumed they would be in.
I now get the following error :
Code:
[SWF] Game.swf - 779350 bytes after decompression
RangeError: Error #2006: The supplied index is out of bounds.
at flash.display::DisplayObjectContainer/addChildAt()
I am playing with papervision and is creating a carousel. For that I have used a tutorial on [url].., and hey - It works just fine.
But, i want to add the carousel within a holder(movieclip), so i have created a movieclip, placed it on the stage, and given it an instance name. Also, i have exported it for actionscript.
So, now instead of doing scene.addChild(plane); i tried to do planeHolder.addChild(plane); and that did not work out too well.
I'm working on a game that lets objects of the same name spawn everytime the timer triggers (Which is every 5 seconds). The objects that spawn on the stage get pushed into an array, so I can let them each fall down by using the ENTER_FRAME function. Here's a piece of the code:
Code: timer = new Timer(5000, 6); timer.start(); timer.addEventListener(TimerEvent.TIMER, onTime);
now MovieClip_1 contains one child _child_1. now by pressing button i want to add that _child_1 of MovieClip_1 to MovieClip_2 without removing from MovieClip_1.
i tried following code in button press event but it removes _child_1 from its past container.
var mc:MovieClip = MovieClip(MovieClip_1.getChildAt(0)); MovieClip_2.addChild(mc);
I have been busy working on a small mini game, in which has several other mini games such as Memory. The script itself is working fine and the game works as it should but the problem with it is, whenever I decide to go to a new frame (and end the game before someone has really found all the answers) the cards stay, so they are visible on the other frames aswell.
Now I have been trying to remove all the childs whenever its on a new frame but I just can't get it to work, I hope someone on the Flashkit forums is able to help me out with this.
I have 6 movieClips on stage. When I roll over any one of them, I want to:A) removeChild the remaining 5 movieClips and then B) bring a new movieClip onto stage that would hold a description and possible button links
Upon rollOut, I want to fire a 3 second delay, removeChild the description movieClip and then addChild the original 5 (removed) movieClips.
add childs to canvas. I want to add childs to canvas in top-down direction and left-right direction? I'm using the addChild function but I don't want to calculate the X and the Y for each Item. is there a way to do that?
I have a portfolio gallery that I can browse. I click on a thumb and it opens an image. Then, if I want, I can "zoom it", by loading a larger image, that is not necessary equal.At the first time I "zoom" an image it all looks fine. I create a black rectangle, a loader and add them to stage covering everything.When I'm done seeing the image, I click on any off them and supposelly they are removed. They even desappear from stage.
But when I try again with a diferent image the same code, it actually loads the previous image and square, plus the nem desired items.This errors increments everytime I click and zoom. All of the previous appear and I have to close them again.
ActionScript Code: portfolio_mc.aberto.botaoZoom.addEventListener(MouseEvent.CLICK, ZoomFuncImg) function ZoomFuncImg(event:MouseEvent) {
I have this problem: I am making a game with flash cs5, and i am coding in as3 i have written some code, that spawns an child (a fireball) from the character position. i made a movieclip symbol on my main scene, that mc is the "parent" for all the enemies that i am adding but now i need to detect the collision between an enemy child and a fireball child, does anybody know how to do that? if asked i can post some parts of my code
Whenever I create a MovieClip in the IDE and draw on it with the IDE then use ActionScript to add more to it (add a Sprite, draw graphics etc..) the thing I added is always behind the graphics of the MovieClip that was drawn in the IDE. How do I bring the Sprite/Graphics that I draw/add to the MovieClip in front of the graphics that were drawn with the IDE?I have tried doing this:
Code: var myMC:mcDemo = new mcDemo(); //mcDemo being a MovieClip created in the IDE. var sp:Sprite = new Sprite();[code]...
The final product of this is the myMC movieclip on the screen with my sprite behind whatever I drew in the IDE for myMC. How do I make it so the sprite is in front of everything? I have tried setting it to numChildren-1 which should set it in front of all objects.
I have an ArrayCollection which has several employees and departments.Each employee belongs to one department. How can I find out how many employees are belonging to the same department from the said ArrayCollection.In database we use join query to do this, but how can I do this by using an ArrayCollection in Flex?
For Example
[code]...
How can i fetch these values from arraycollection in flex? is there in inbuild function or property provided by adobe.
Creating an application for a client and figured now is a better time than any to make the jump from as2 to as3. I've read many articles and books to keep up to speed but I get constant errors everytime I add or change something. Its becoming beyond ridiculous and rather than searching another unrelated google result, I thought I'd post something here.
after it is done i would have access only to the last imageLoader instance. How to get access to the rest of images, which were added to the Display List with the same name "imageLoader".I tried to call it with the imageLoader.name property,but surely i do something wrong, as only errors appear in the output panel.
Recently noticed this, if i add an event listener somePerent.target.addEvent() and then move that target to someOtherParent.addChild(somePerent.target) the listener is lost, is there a way to avoid it?
I've got a MovieClip which has bitmaps pasted onto it via AS3. These bitmaps are transformed and are sometimes over each others with transparency.So I would like to the grab the whole MovieClip as it is and make it a completely new bitmap. Problem is:
ActionScript Code: bitmapData.draw(mc) //does NOT work in this case (nothing shows) bitmapData.draw(mc.getChildAt(0)) // works, but it doesn't save the childs properties such as x,y coordinates and transparency
What I need is basicly a function such as "Image -> Apply Image" in photoshop.Except that it only copies a movieclip and not whole stage.
how can i make all mcs (a bunch of them) inside another mc, to gotoAndPlay in a random frame without having to adress each one of them by theyr instance names?
I have problem with clearing memory in my game because of eventListeners, garbage collector not clear my objects with events, because events points them when objects are removed from scene. Is there any way to clear events connected to object and his childs? (game create a lot of objects and put diferent listeners if necessary, but because there are also libraries which are created by other programmers I cant just make list of events to clear) Even clar whole scene will be sutable for me if it will destroy all events, because its big problem and game close to beta -.- the only thing I cant do is close flash window
I have a script that randomly pops out circles all over the stage. However, I want them to disappear once I roll my mouse over them (and only the ones I roll over, not all the instances).So if I have code like this in a function:[code]And then I have a mouse_over function in the same class, how do I tell it to removeChild? Since the stars are instances of the object, they are giving instance names like instance67, which makes them hard to remove.
I have a question that is a bit tricky. Why I want to do this is becouse I need such a dynamic solution as posible with fast downloadtime.
- I have a host file that schould preload child files (this is to display what I can load visual).
- In the child files library i have a clip ready to be exportet (it's exported in first frame)
- when my host noticed that the childs second frame is loaded I want to grab the clip from the childs library and attach it in the host. (after this it will load nextone e.g.)
Is it not posible to get childrens exportet library clips? (have tried to load whole child clip before trying to grab the clip).
Im loading some HTML text into a flash dynamic text box and have some list items but i want the bullet to be flush to the left along with the other text and without such a big gap,see below.is there some code i can insert in my plain text document with out using css?<li>Present you with the best market opportunities within your search criteria.</li>
I've recently created a game in which the logic and programming all runs perfectly, however the graphics are lackluster. I'm currently having a hard time managing the depth of movieclips on the screen.Basically the game is tile based and each frame of the movieclip holds a different type of tile. All the tiles are 50x50 with the exception of one type of tile which is 60x60 and therein needs to overlap the tiles around it which are 50x50.In AS2 I could of set the depth manually, however I'm told (as is this is my first time dealing with depth in AS3) that I cannot do this anymore. Is there any suggestions on how I can make sure that a tile of one type is automatically set beneath tiles of another type - I've thought about simply coding a function to check this but it somehow seems inefficient (considering larger maps will have a lot of tiles, meaning hundreds of movieclips attached to the stage, each movieclip with multiple frames).
Essentially, i have loaded an external SWF (area-home.swf) w/in a MC (mc_loader) of the main SWF (base.swf). This is simple, not a problem, works like a charm. What I want to do from here is have the main SWF (base.swf) tell the external SWF (area-home.swf) to gotoAndStop at a certain frame (42). Below is the code that I have, and can't quite figure out why it won't work:
PHP Code:
var loader1:Loader=new Loader(); loader1.contentLoaderInfo.addEventListener(Event.COMPLETE, myFunction); loader1.load(new URLRequest("area-home.swf"));
[code]...
When i trace the total frames, it does bring back the actual frame count from area-home.swf, so I know that it is communicating. It simply does not stop on the 42nd frame (even have a stop(); command on that frame in area-home.swf's timeline)
Do I need to create all objects which i will possible use with itemRenderer in createChildren function, even if the current item must not show some of them ?