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
Similar Posts:
Feb 2, 2009
Is it possible to set the height of the sprite depending on the height of an textfield inside that sprite? I'm creating a box with a textfield inside it, but I want the box to be sized depending of how much text it is in the textfield..
View 9 Replies
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
Aug 31, 2009
What is the maximum height and width of a sprite.
View 7 Replies
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
Jul 28, 2009
In a previous thread I asked a question about setting the width and height of a sprite subclass in its constructor method. One of the responses has puzzled me since I read it:
"Setting width and height only makes sense if you're adjusting the width and height of existing content, and the Chart (Sprite) has none at that point."
I don't understand that; what if you're adding children to the sprite that depend on those dimensions?
Here's a simple app which draws a red circle inside of a blue box which demonstrates my confusion as well as one other issue. The full questions are at the bottom.
Main.fla:
import Box;
var myBox:Box = new Box(200, 200);addChild(myBox);myBox.drawCircle();
[Code].....
Question 2: In this example, the dimensions of Circle are based on the width of its parent Box sprite. Is there a more elegant way to pass the dimensions to the circle? I ask because in my actual project (a chart) the plot area contains a lot of screen locations that must be passed around when I add new objects such as grid lines and markers and passing around the coordinates as parameters seems awfully messy. I'm just not sure how else to do it.
View 1 Replies
Oct 28, 2010
I got a screen to display objects in a sprite that covers the stage. ok I got a screen to display objects in a sprite
q1) do I need to specify the sprite height/width to match the stage or is this implied with canvas1=new Sprite();addChild(canvas1);
[Code]....
View 5 Replies
Oct 23, 2009
Given this code:
[Code]...
Why does changing the width and height of uiComp not affect the Sprite? Wouldn't UIComponent provide Sprite with a Graphics object, which limits that area where Sprite can draw?
View 1 Replies
Feb 25, 2011
I'm working with a Sprite in AS3. Initially, width,height are 0,0 as expected.
After this:
var tf : TextFormat = new TextFormat();
tf.font = "Arial";
tf.size = 48;
[code]....
View 2 Replies
Feb 27, 2011
I know this might seem like such an easy issue and I can't understand why I cant figure it out but none the less I can't and I've just about given up. Here's the issue:
I have a sprite container which is supposed to hold a bunch of thumbnails to videos. I am able to populate the container with all the videos and the whole works but obviously if I add a bunch of videos its going to exceed the size of the flash document so I need to add a UIScrollBar (which I did) now the scrollbars target is set to the container but isnt allowing me to scroll and if im correct this is because the container doesnt have a set height. So Im trying to set the height of this container but the second I try setting the height or even width all my thumbnails I used to be able to see are gone! It's as if the size is being set to 0 when its not I've even tried to set it to a specified size just to test and nothing.
[Code]...
View 1 Replies
Feb 5, 2009
[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
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
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
Mar 29, 2012
What more can be done if I extend MainClass with MovieClip rather than Sprite. I know that MovieClip extends Sprite and it has Timeline defined under it. But still how it will be usable to me by MovieClip ?
package {
import flash.display.Sprite;
import flash.text.TextField;
import flash.text.TextFormat;
import flash.display.MovieClip;
import flash.text.TextFieldType;
[Code] .....
How to use Timeline if I replace Sprite by MovieClip ?
View 1 Replies
Jan 10, 2011
I am following this page to create a custom preloader extending Sprite to load an animation SWF, but it is not working (the animation SWF is not displaying): [URL]. I know the Animation.swf file is okay, because if I load it into the main app it displays and runs. The preloader works if an image is loaded by the preloader instead of the animation SWF.
test.mxml (main app)
BTW, I typically have many more lines of ComboBox in the app to force the preloader to display, but limiting number of lines here.
CustomPreloaders.SparkAnimationProgressBar.as
package customPreloaders {
import flash.display.;
import flash.events.;
import flash.net.;
import flash.utils.;
[Code] .....
View 1 Replies
Sep 18, 2009
since I cant create a custom property on a sprite if extend a sprite, should be able to make a custom property then or do I need to use a movieClip?
View 14 Replies
Apr 4, 2011
I've got a sprite which I want to temporarily hide... But changing the .visible property doesn't do what I expect. The code looks roughly like this:
[Code]...
View 1 Replies
Mar 2, 2009
I created a new AS3 document (550px by 400px) and added the following code to the first frame.
However, when I run this, I see nothing painted on the screen at all, the screen remains completely white.[code]...
View 3 Replies
Jul 6, 2011
I'm doing a simple rotation on a sprite but there's a weird behavior where the sprite does not rotate around it's top left. I think I'm rotating along the top left of the test class instead of the sprite child. I would like to rotate the rectangle around it's top left corner (kinda like a clock hand). The code is pretty short so I'll let the code + pictures explain my problem:
package
{
import flash.display.Sprite;
[Code]....
I've read a lot of stuff about rotating around a fixed point, I've tried doing it with movieclips instead of sprites, I even copy pasted a tutorial on rotation and nothing works.
View 3 Replies
May 27, 2008
[Code]...
Then the numericStepper is drawn as if it is squished to 20% its normal height. If I pre-set mySprite width and height before adding the numericstepper, the trace output is 0,0 after adding it and it is not displayed at all. Is there some way I can make the sprite only adjust to correctly fit the numericStepper OR resize it afterwards without distorting the numericStepper component?
View 2 Replies
Dec 23, 2009
I have a sprite in which I have added other sprites. Something like:
var sp_main:Sprite = new Sprite();
var sp_group:Sprite = new Sprite();
for(i:int = 0; i < 10; i++)
[Code]....
View 1 Replies
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
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
Feb 10, 2010
I'm trying to make a textfield inside a sprite zoom upon mousing over the sprite. I'm instantiating tweens on the x, y, scaleX, and scaleY properties of the sprite. The x and y tweens are needed due to the top left registration. Also, the tweens are added to an array to ensure they finish. Sometimes it works as I intended, but when I mouse over from the bottom right corner, the sprite jumps haphazardly towards the top left and back until I mouse out, instantiating another set of tweens to return the sprite to it's original state. I'm not sure what to do other than using a custom tweening engine such as Tweener. I'm using the built in tweening classes and I'm hoping to find a solution within these parameters.
View 5 Replies
Aug 15, 2010
first i have 2 sprite.. it`s mcproduct sprite and mcproductpane sprite . mcproductpane is a parent of mcproduct sprite.. so inside mcproductpane there a several mcproduct sprite.this is a script of mc prodcut
PHP Code:
[Code]...
The problem is i want to set a button in here(mcproductpane sprite), this button will unload / make dissappear an image that i load using loader class in mcproduct sprite..how can i make this happen?when i want to make a button in mcproductpane sprite which the function of the button it`s to unload/make an image that i load using loader class in mcproduct sprite disappear.
View 1 Replies
Mar 21, 2011
I try draw one pixel width rectangle in a sprite. And add some tween on it to make some effect. But I find use the code below can't create exactly one pixel white rect. I created I want to create
[Code]....
View 1 Replies
Aug 9, 2011
I've a slider class (SliderUI) and I'm passing slider and track images to that class as sprites.
What I'm trying to do is, passing one more image as sprite and changing its width for doing masking in slider. (It will expand or collapse as you move volume slider)
When I try to change width of sprite, it doesn't show up and I guess sprite is just container and resizing it makes it disappeared.
So how can I resize sprite with its child image (it's loaded by a Loader object by the way)?
View 1 Replies
Jun 3, 2009
why I can't get the width of a Sprite when it has components in it.
For example
Code:
var foo:Sprite = new Sprite();
addChild(foo);
var comboBox:ComboBox = new ComboBox();
[Code]....
I'm assuming the component possibly isn't set before I'm trying to get the width?
View 5 Replies
Oct 11, 2010
Ok every time I think I understand the DisplayObject model i find something else that seems like it should work but fails. Am I correct that if I create a sprite then create another sprite and add it as a child the original parent sprite will show a height of 0... In my case i have three classes that all extend Sprite and each one is creating the next with the "youngest child" being a class that adds an image to its "stage". I can see the image height fine but its holder does not nor does its holders parent... im having a real moment here as I debate if im just stupid and missing the obvious way to do this or if I really have to add a bunch of getters and setters to see the height that includes children.Maybe I am thinking of this too much like a CSS block element but it just seems like it should work this way...for example
parent "holder" <- child "slide" <- child "image"
holder.height == 0
slide.height == 0
[code].....
View 2 Replies
Jan 5, 2011
I'm attempting to draw a text box on the screen. If I assign width and height to any value, as in the code below, I don't see anything drawn. Why is this? What is the use of width and height? Adobe's docs say it's the width/height of the sprite in pixels. Why would that occlude or prevent the drawing of a textbox or another box? I assumed the width/height would set the area that this sprite could be drawn upon, but based on this, I'm probably wrong.
package
{
import flash.display.Sprite;
[code].....
View 1 Replies