ActionScript 3.0 :: Parent Width From Children
Oct 20, 2009
Having some strange problem getting a width from objects placed on stage using addChild. I am under the assumption that when I add some children to a specific parent, the parents width will increase and I can use that number to immediately act on the parent. The width is 100 when traced no matter when or where I add the children. I can change it statically but the is a desktop app which depends on screen size.[code]
View 1 Replies
Similar Posts:
Jul 19, 2011
I have placed 3 movieclips named mcParent, mcChild1, mcChild2 and 1 textbox in flash. child are childrens of parent movie clip. child1 and child2 both are of sizes 300 whereas parent movieclip is 600px, textbox is placed inside child2 movie clip .
I have made the flash to auto resize according to the screen area. Everything works well, but after resize it resizes parent and all childrens and textbox which is correct. The problem is with the correct placement of textbox on mcChild2. I have seen that after resize, mcParent width and scalex both changes but the child clips doesn't changed its sizes even they are stretched but there sizes are not updated due to which I am unable to get the exact location of where to place the textbox.
View 1 Replies
Nov 23, 2010
I have created a custom component - MyImage - that has two children including a Bitmap as well as a Sprite.My display object hierarchy is as follows -
mx:Canvas
view:MyImage
mx:Bitmap
[code].....
View 1 Replies
Jun 6, 2011
i am slightly confused about the parent and child relationship. lets assume we have several different instances, what would be difference of adding them all as children of the stage and creating a parent-child hierarchy between them(other than the access path).
View 5 Replies
Jul 29, 2011
I got a Parent Sprite, let's name it SpriteP, which holds inside it two other Sprites. Sprite1 and Sprite2.[code]Sprite2 is a rectangle. When I rotate it, of course, the height of its parent, SpriteP, GROWS. But I would expect that height to go back to what it should be when I'm removing Sprite2!And it does! If I remove Sprite2 while NOT being rotated, the height of the parent drops back to normal, 200.
View 10 Replies
Jul 29, 2011
I got a Parent Sprite, let's name it SpriteP, which holds inside it two other Sprites. Sprite1 and Sprite2.
When Sprite2 is NOT rotated:
Code:
trace(SpriteP.width + ' ' + SpriteP.height); //100 250.
SpriteP.removeChild(Sprite2)
trace(SpriteP.width + ' ' + SpriteP.height); //100 200. -> works, 200 is good.
When Sprite2 is rotated at 90:
[Code].....
And it does! If I remove Sprite2 while NOT being rotated, the height of the parent drops back to normal, 200. But if I rotate Sprite2, the Parent won't update its bounds.
View 1 Replies
Jul 27, 2010
I have multiple children movieclips containing png images inside of a parent movieclip. The parent movieclip has a slow looping animation. The children don't stay in sync with one another during the animation. It becomes obvious to see because there is a background child clip with other child clips on top of it. It appears to only happen with movieclips containing a bitmap image. Does anyone have an easy fix or work around for this?
View 5 Replies
Mar 2, 2009
I have 2 movieClips loading images using XML files.
I need to set the position on this movieclips from the parent depending on their width.
The problem is that the parent have to wait that both children have loaded the images before to proceed.
View 2 Replies
Feb 8, 2010
how can i get an objects "main" width, the width whe object whould have widthout all the added children?
View 2 Replies
Apr 29, 2010
I have a set of movieclips that are added as children to a parent mc. I want to scale the parent mc up but keep one of the mc's in the same place on the stage. I think the easiest way to do that is to scale the mc up, calculate how far the child mc moves and move the parent an equal amount in th opposite direction. Everything works but I can't for the life of me wrap my head around the math required to calculate the distance to move the parent mc. Has anyone else tried this? Is there an easier way that I don't know about?
View 2 Replies
Sep 17, 2010
I'm making a rather large flash project and so I'm concerned about memory usage. At the end of each section of the application I remove the overarching parent element that holds the content. Although this remove the parent, does this also free up the memory for each of the children contained within this, or should I run an iteration to remove those prior to removing the parent?
I'll give a little more explanation in-case I'm not expressing what I want:
addChild(movie1);
movie1.addChild(movie2);
movie1.addChild(movie3);
By using this code:
removeChild(movie1);
Does it remove movie2 and movie3 from memory or are they still stored, just unlinked?
View 3 Replies
Oct 26, 2010
I have setup a "LayoutPage" custom class (based on MovieClip) and I am attemptimg to create a "selected" behaviour.When I assign my "addEventListener(MouseEvent.CLICK,toggleSelection)" from within my custom class, everything works as expected, clicking any object of that class does display the correct behaviour.
Now, I would like to extend the functionality by adding keyboard modifyer to either extend the selection or replace it.For this, I thought of moving the "addEventListener" out of the class and put it inside the parent instead (my "PageLayout" class where all the "LayoutPage" live). But by doing so, the click event no longer register on the "LayoutPage" class but rather on its individual children (Page icon, Page number text field, Page Highlight shape, etc.)
View 1 Replies
Feb 1, 2011
How do I get a list of all the children (Sprites) on the stage of my Document Class OR how can I get a list (length) of all the children (Sprites) of a parent (Sprite)?
View 1 Replies
May 17, 2011
How to avoid children inheriting parent's colortransform in flash?
View 2 Replies
Jun 15, 2007
is it possible to retrieve all children of a certain type from a parent in actionscript 3?i only see getChildAt,getChildByName, is there a getchild of a certain type like get all childs of object type:Food?!!!
View 3 Replies
Nov 14, 2010
What's the best way of resizing parent movieclip without affecting the children? I have a container movieclip that resizes depending on the stage, and when I add another movieclips to it they also resize, but I want them to keep the original size,
View 3 Replies
Apr 16, 2011
I'm doing an AS2 project with a parent.swf that loads many child_##.swf's. they each use identical buttons and other library assets.tried using Shared Library concept two different ways:
1 - created library.swf and used assets from it for child swf's ... no problem when child is played by itself, but when parent loads the child's, shared assets do not work,
2- established parent.swf as the 'library', and followed the common steps of Shared Library setup, but shared assets did not work. of course, using class files works, but still I need a central place for the graphics ( I'm avoiding having my classes create graphics via draw methods ).
View 1 Replies
Jan 27, 2011
I have a parent node and I'm trying to get each child node under that parent and store it into an arraycollection? How could I go by doing this?
View 1 Replies
Jul 5, 2011
is it possible to retrieve all children of a certain type from a parent in actionscript 3? i only see getChildAt,getChildByName, is there a getchild of a certain type like get all childs of object type:Food?
View 2 Replies
Dec 23, 2009
I have a rectangular movieClip named 'container'. In this movieclip, a function generates some number of squares.My problem is that; for example, if I generate 12x12 squares with each width/height of 40; it resizes the container to width/height of 480. If I set the width and the height of the container movieClip to a lower value; then the squares become smaller.I have been struggling for some time on this problem. I tried setting the ScaleMode of container and squares to various values but it did not work.How can I overcome this illogical (for me at least) problem? How can I prevent children from resizing their parent OR how can i prevent parent downsizing the children?
View 2 Replies
Nov 14, 2010
What's the best way of resizing parent movieclip without affecting the children?I have a container movieclip that resizes depending on the stage, and when I add another movieclips to it they also resize, but I want them to keep the original size
View 1 Replies
Jun 1, 2011
I have a game set up like so:
DOCUMENT CLASS -->
MASTER LEVEL -->
LEVEL OBJECTS
The MASTER LEVEL is a child of the DOCUMENT CLASS and the LEVEL OBJECTS are a child of the MASTER LEVEL
The MASTER LEVEL is just a border which also shows the time that has passed. The LEVEL OBJECT are stuff like the player and the finish.
The problem is that I can make the player and finish swap depths using setChildIndex but I don't know how to bring the master level in front of its children? Is this even possible or will I have to make a level container that is the parent of the LEVEL OBJECTS and also the MASTER LEVEL. So that the MASTER LEVEL, the finish and the player are all siblings (sort of).
So I am trying to bring a movieClip in front of its movieClip children.
View 5 Replies
Jun 25, 2010
I'm facing a problem with drag & drag actions on children mc. The parent sometimes moves too.How can I disable any reaction of the parent, without affecting children?
View 1 Replies
Feb 27, 2011
Changing the width and height of the parent MovieClip does not bring change in the width and height of the inner MovieClip. The parent MovieClip is placed at Stage and is resized manually. When I assign the dimension of the parent MovieClip to the inner MovieClip through code, the parent MovieClip dimension is changed. I want both MovieClip to be of same width and height at runtime. However, parent MovieClip dimension is changed at design time by me.
Example:There are two MovieClip, one inside another. Now parent MovieClip is placed at Stage at design time and its dimension is (50,50) and the child MovieClip which is inside the parent MovieClip has also same dimensions (50,50). Now, I manually change the parent MovieClip dimension by pressing Q and stretching it with mouse, the dimension of the parent MovieClip is now (100,150) or whatever I like. Now double-click on parent MovieClip and check that inner MovieClip dimension remains same i.e. (50,50)Now in AS3 code, I change the width and height of inner MovieClip like this:
saveheight = parentmc.height;
savewidth = parentmc.width;
now I change the child MovieClip according to the dimensions of the parent MovieClip like this:
parentmc.inner_mc.width = parentmc.width;
parentmc.inner_mc.height = parentmc.height;
but this brings change in parentmc also so I reassign value to parentmc like this:
parentmc.height = saveheight;
parentmc.width = savewidth;
In above case, parentmc and inne_rmc dimension should be same i.e (100 ,150). With swapping the values as above, I get parentmc and inner_mc to be of same dimension, but object size is never (100, 150), I have checked it with pixel-perfect air app.
View 3 Replies
Sep 30, 2011
I have a ViewStack which is dataProvider for a TabBar. There are two VBoxs as children for this ViewStack. It works fine with absolute values for width and height for these VBoxs, but when specified in percentages, the VBox uses all the available space (100%) for any percentage value. find the code and screen shots below.
how can children of a ViewStack be aligned to center? There is no horizontalAlign property for ViewStack and it is not working with horizontalCenter= "0".
Code:
<mx:ViewStack id="viewStack" width="100%" height="100%" selectedIndex="0" horizontalCenter="0" textAlign="center">
<mx:VBox label="Tab 1" width="25%" height="10%" borderThickness="2" borderColor="red"
[Code]....
View 2 Replies
Feb 15, 2009
I have a container object that i add children to. I want to change the height & width of the container without the children scaling. In this case I draw a rectangle in flash which I'll use as the container object then export for AS.
[Code]...
View 5 Replies
Sep 3, 2008
I have a Document class called Main.
As a child of Main, I have an instance of a class called NavMenu.
As children of NavMenu, I have multiple instances of a NavLink class: navLink01, navLink02, navLink03, etc.
Back up in the Main class, there is a function called navigateTo, which accepts sectionID variable as an argument.
My question is, what is the best practice to get the navLinks to call the navigateTo function on Main? I've been told that in the spirit of encapsulation, it is not best to pass a reference to Main down to the navLinks, and call the function from there.
But rather, it is desirable to use the event listener/dispatcher method, where the navLinks are dispatchers, while the Main class listens for the navLinks to broadcast their sectionIDs.
While this makes sense, however, don't you still have to pass a reference of the listener on the Main class down through the hierarchy, so that the navLinks are registered as dispatchers? Doesn't that defeat the purpose of encapsulation?
View 4 Replies
Feb 11, 2010
Is there an easy way to make a parent container (eg Group) resize when it's children resize?
Below is a little example app. When I put the 200x200 'food' in the 'stomach' the stomach & it's containing 100x100 'body' should resize to contain the food.
[URL]
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
[Code]....
View 2 Replies
Dec 10, 2010
I'm trying to simulate some fade in/out effects in Action Script 3 programmatically, using Timer class and controlling alpha property of the specified DisplayObject in time. In general it works and looks great. As I was expecting. But after I add some more child DisplayObjects to the parent Sprite it starts to behave weirdly. Children seem to not fade at the same rate as parent object and it visually noticeable, and ugly. There seems to be a short lag after parent already started to fade out and before children actually follow. Are there any additional measures I should take to avoid that? I do alpha manipulation only on parent object. I thought that'd be logical...
View 2 Replies
May 13, 2011
I have code like the following:
<s:VGroup gap="10" id="group" height="100%">
<s:Label text="This is page 2" />
<s:Button content="Resize Canvas" click="resize(event);"/>
<mx:Canvas id="photoCanvas" color="#567898" backgroundColor="#125567">
</mx:Canvas>
</s:VGroup>
I don't understand why the following does not work:
Pushing the Button resizes the photoCanvas's height (gets taller or smaller). Since the photoCanvas control is a child element of the VGroup shouldn't the container update itself to the new height? The Vgroup has ALWAYS the same height, no matter what the (total) height of the children is! I would like the VGroup to adjust itself and get a height value equal to the sum of its children heights. Is this not possible??
View 1 Replies