ActionScript 3.0 :: Width Of DisplayObjectContainer - Make The Size Of Sprite Is Not Affected By Its Children?

Jan 30, 2010

look at the following codes first
 
var sp:Sprite = new Sprite();
trace( sp.width );                    // the result will be 0
var mc:DefinedMC = new DefinedMC();          // assume that DefinedMC is derived from movie clip, and the width of mc is 100
sp.addChild(mc);
trace( ap.width );                    // the result will be 100
 [code].....
 
so the size of an instance of Sprite is affected by its children.is there any class derived from DisplayObjectContainer whose size is not affected by its children, or is there any method that could make the size of Sprite is not affected by its children.

View 7 Replies


Similar Posts:


ActionScript 3.0 :: DisplayObjectContainer Handling Children With Same Name

Jan 27, 2009

Code:
import flash.display.Sprite;
var sp1:Sprite = new Sprite( );
var sp2_1:Sprite = new Sprite( );

[Code]....

I'd assume from this that there is no correcting done for children with the same name being added to the same parent. I ask this question because I'm creating a structure that needs to mimic the display list and I'd like to keep behavior consistent.

Another question: I'd assume internally the children are saved in something similar to a Dictionary object, does anyone know if this is true? And then getChildByName simply does a foreach loop and returns the first match on a name?

View 2 Replies

ActionScript 3.0 :: Clip Children That Are Part Of A DisplayObjectContainer?

Dec 9, 2009

is it possible to clip children that are part of a DisplayObjectContainer? If I have a parent object with size x 100, y 100, width 100, height 100 and a child that has the coordinates x -50, y -50, width 100, height 100, I can still see the full child staying at x 50, y 50, but I want the child to be cut off by the parent.

View 3 Replies

Actionscript :: Flash - Function To Adjust Font Size To Make Text Field Width Smaller Than A Given Width?

Aug 31, 2011

Is there a function or property or better way to do what the following code do?

var width:int = 20
while (textField.defaultTextFormat.size > 1 && textField.width > width) {
textField.defaultTextFormat.size--
}

View 1 Replies

Flash :: Make Size (width And Height) Full Size In The Browser?

Sep 15, 2011

I would like to know how to make flash size (width and height) full size in the browser? the real size of flash is w:955px h:600px I tried to make w:100% and h:100%, it makes pictures pixelate.

View 6 Replies

ActionScript 3.0 :: Size - Make A Stage With 100% Width And Height

Jan 15, 2011

when i create stage and make its width and height in pixels Web Browsers show it with pixels too. so i want to make a stage which width and height would be 100% in web browsers. i just want to place buttons and some stuffs on the top and right of the web browser.

View 2 Replies

Actionscript 3 :: Class Extending Sprite - Set The Sprite's Width And Height Properties?

Mar 5, 2010

I created a class, extended the sprite class, and now in the constructor I am trying to set the Sprite's width and height properties which are inherited from the DisplayObject. However, after I set this.width and this.height, and print the values, I get 0 for both.

What the heck is going on? When I view the livedocs I see that DisplayObject has width and height listed as public properties. I have been able to instantiate a Sprite directly, and set the width and height after it's been instantiated, so I don't get it.

package {
import flash.display.*;
public class ScrollBar extends Sprite {[code].....

View 1 Replies

Actionscript 3 :: Difference Between Sprite.width VS Sprite.scaleX?

Sep 23, 2011

Both of sprite.width and sprite.scaleX can be used for scale a sprite. Is possible sprite.scaleX depends on screen size?

View 2 Replies

ActionScript 3.0 :: Sprite.graphics And Setting Sprite.width?

Jun 19, 2009

It has been a great resource of the years. No my problem. I am trying to dynamically resize a sprite that has a line drawn into it. Here is my code:

[Code]...

View 4 Replies

Flash :: Flex 4.5: Tree - Make A Flex Tree Component Display The Children Of A Sprite In A Hierarchical Way

Nov 19, 2011

I'm trying to make a Flex Tree Component display the children of a sprite in a hierarchical way. Moreover, dragging the items on the FlexTree would resort and reparent the items. I have special Elements set as Folders. This would allow other elements to be added there as a children by dragging an element on the tree and dropping it there. I have a failed attempt which works, but breaks when I try to add folders. Basically, it fails at reparenting the items by dragging and resorting folders and that Does anyone know of a component or something which can do this, has anyone have created any of this or could anyone give me a clue?

View 1 Replies

ActionScript 3.0 :: Redimensioning Sprite But Not Its Children?

Jul 30, 2009

Is it possible to alter the width or height of a sprite dynamically without altering the width and height of its children ?

Even when I add children to a Sprite that had its dimensions altered dynamically, these children have their dimensions changed.

[Code]...

View 3 Replies

ActionScript 3.0 :: Sprite Is Larger Than Its Children?

Feb 2, 2011

I have sprites with dynamically created children: combo-boxes, buttons, and textfields. The number of children is variable and they're positioned vertically one under the other. If a sprite contains textfields only, its height corresponds to the joint height of all children + the spaces between them. In the case of sprites containing combo-boxes and buttons however, the sprite height is larger.

I may be on the wrong track here, but it seems that what is responsible is the object bounds. E.g. if my button height is 25 and getBounds returns 100, the sprite's height is larger by 75 pixels.The sprites are loaded into a scroll-pane, and depending on their size, the vertical bar is visible (or not). Obviously the above results in situations where a scroll-bar appears even though the entire contents of the sprite is visible, or one scrolls down to an empty space...Is there a way around this problem? Can object bounds be re-sized as well or can I overwrite this '100' value somewhere in Flash itself?

View 1 Replies

ActionScript 3.0 :: Checking If A Sprite/Movieclip Has Any Children

Oct 16, 2009

how do you check whether a certain mc or sprite has any children inside it... does the following do the trick?

[as]
if (mc.length > 0)
{
trace ("mc has children");

[Code]....

View 4 Replies

ActionScript 3.0 :: Duplicate A Sprite With All Its Children And Events?

May 10, 2011

I am trying to duplicate a sprite that I loaded a bunch of images in from an xml.

I even tried senocular's way of duplicating display objects and it just returned an empty sprite.

View 2 Replies

Actionscript 3 :: Force A Sprite To Position Children In Reference To 0,0?

Sep 26, 2010

I'm trying to add some scroll bars to a Sprite using ScrollRect. The Sprite starts empty and when I add something at 500, 500, it should scroll, as it is outside the viewport. Unfortunately, adding a 10x10 Sprite at 500, 500, doesn't make my Sprite change its size to 510, 510, but to 10, 10 ::- (.

We all know that DisplayObjectContainers resize according to what's put in them. But I didn't know up until today that if you put something at 500, 500, the Sprite / DObjContainer will NOT resize from 0, 0 to 500, 500, but simply jump directly at 500, 500. Annoying, as I cannot put Scrollbars on something whose content fluctuates so. I need 0, 0 to remain 0, 0 and if something is placed at 500, 500, the sprite's height should increase with 500 + that something's height.

View 3 Replies

ActionScript 3.0 :: Resizing A Sprite Without Scaling/streching Its Children?

Nov 29, 2009

I have a Bitmap. Let's say it's 100x100 in size. I would like to display that bitmap on a Sprite that for the sake of this example is 100x50. Since the height of the bitmap is double than the height of the sprite - I would have liked the bitmap to be cropped (and to later implement a "scroll-down" mechanism) - HOWEVER, apparently:

1. The size of an "empty" sprite is defined by the size of its first children(s) - once I addChild the bitmap into the sprite - the sprite becomes 100x100 (If I try to define the size of the sprite to 100x50 before adding the child, and then adding it - then nothing is displayed).

2. If I then try to resize the sprite by modifying its Height property - the bitmap get's "scaled-down", or rather "squashed-in" to fit the new size.I'd like the bitmap to retain its original size (and be cropped at the bottom).Can it be done (without copyPixeling to a different bitmap etc.), and if so how?

btw:(3) If after all that I try to scale the bitmap back up (by changing scaleY) - then the sprite itself is again gets scaled and resized with it...

View 1 Replies

ActionScript 3.0 :: Force A Sprite To Position Children In Reference To 0,0?

Sep 26, 2010

I'm trying to add some scroll bars to a Sprite using ScrollRect. The Sprite starts empty and when I add something at 500, 500, it should scroll, as it is outside the viewport. Unfortunately, adding a 10x10 Sprite at 500, 500, doesn't make my Sprite change its size to 510, 510, but to 10, 10 ::- (.

We all know that DisplayObjectContainers resize according to what's put in them. But I didn't know up until today that if you put something at 500, 500, the Sprite / DObjContainer will NOT resize from 0, 0 to 500, 500, but simply jump directly at 500, 500. Annoying, as I cannot put Scrollbars on something whose content fluctuates so. I need 0, 0 to remain 0, 0 and if something is placed at 500, 500, the sprite's height should increase with 500 + that something's height.

View 9 Replies

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

Actionscript 3 :: Parent Sprite And It's Children DisplayObjects Do Not Fade In/out Simultaneously

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

ActionScript 3.0 :: Get Width Of Object But Exclude Children?

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

Actionscript 3 :: Setting Alpha On Parent Sprite Without Affecting Sprites Children

Mar 12, 2010

If I change some value for a parent sprite, the same value will affect all of its children. So if I set alpha or width on the parent, the child will automaticly get the same value.

View 4 Replies

Actionscript 2.0 :: Stage.width - Make A Minimum Width And Stop Resize?

May 27, 2009

is there a way to make a minimum width and stop resize? I have a menu I am building that is locked to the bottom of the browser and 3 buttons on the left and a movieClip on the right. When you resize the browser window - currently - you can make the button on the right sink under the three on the left.

[Code]..

View 6 Replies

Actionscript 3 :: MovieClip Resizes But Its Children's Height And Width Are Not Changed?

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

Flex :: Width And Height Specified In Percentage Not Working For Children Of A Viewstack

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

ActionScript 3.0 :: Change The Height & Width Of The Container Without The Children Scaling?

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

ActionScript 3 :: How To Scale Width Of Sprite To Resize

Oct 24, 2011

I have a sprite in as3 code, I want to enter its height to resize it, how can I scale the width accordingly?
sprite.height = 200;
sprite.width = ??

View 2 Replies

ActionScript 3.0 :: Sprite Width Not Working For Image?

Jun 21, 2009

I create a simple .As file with following score code:
Code:
package{
import flash.display.Loader;
import flash.display.Sprite;
import flash.events.MouseEvent;
import flash.net.URLRequest;
public class AS3_Project1 extends Sprite{
private var sprite:Sprite;
[Code] .....
And the image wont appear but if i remove the sprite.width = 500; line and I can view the image? what going on?

View 3 Replies

ActionScript 3.0 :: Height/Width For Sprite Subclass?

Jul 26, 2009

For example, if I say:

ActionScript Code:
public class Chart extends Sprite {
public function Chart(myHeight:Number, myWidth:Number) {

[code]......

View 4 Replies

ActionScript 3.0 :: Maximum Width And Height Of A Sprite?

Aug 31, 2009

What is the maximum height and width of a sprite.

View 7 Replies

ActionScript 3.0 :: Changing Width Of Sprite Seems To Change Height Too?

Feb 5, 2009

Here is some code I have.

[code]
_buttonUnderline = new Sprite();
with(_buttonUnderline.graphics) {
[/code].....

When the Tween takes place though it not only changes the width, it changes the height as if it were scaling it up in both directions. Why does this behavior take place? And how can I get it so that only the width changes? I have also tried using scaleX as the property but it does the same thing.

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved