ActionScript 2.0 :: New Resize() On Sprite Object?
Feb 28, 2007
I'm making a resize function that has to resize a Project object that extends Sprite.
But I keep ketting a type coercion error:
TypeError: Error #1034: Type Coercion failed: cannot convert AS:: Project@318ff89 to mx.core.IUIComponent.
I've tried casting the Project object to an UIComponent or DisplayObject, but this also throws a TypeError.
[AS]var resizeTarget:UIComponent = new UIComponent();
resizeTarget = UIComponent(target.getChildAt(0));
var myResize:Resize = new Resize(resizeTarget);[/AS]
So basically should I try avoiding the use of Sprites in Flex?
I have a brick class where I have created a rectangle using flash.display.graphics.I am using this brick class to create a grid of 10 X 10 in another class called grid using new brick() in a for loop.I have another class called ball where I have created a circle with flash.display.graphics.The problem is that I want to remove / destroy individual bricks when the ball hits the bricks on Event.ENTER_FRAME which is not happening.the error I get is shown only for the last brick that is created in a for loop.ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
at flash.display:isplayObjectContainer/removeChild() at grid/ball_movement()// my function in enter frame event The code I wrote in ENTER_FRAME is
I have a brick class where I have created a rectangle using flash.display.graphics.I am using this brick class to create a grid of 10 X 10 in another class called grid using new brick() in a for loop.I have another class called ball where I have created a circle with flash.display.graphics.The problem is that I want to remove / destroy individual bricks when the ball hits the bricks on Event.ENTER_FRAME which is not happening.the error I get is shown only for the last brick that is created in a for loop.[code]
How do you resize a sprite without resizing the contents? For example the script below create a sprite, attaches it to the root, creates a button, attaches the button to the new sprite then resizes the sprite. but it scales the button when I try to resize?[code]...
I'm currently working on a center stage component and I was wondering if there's a good way to detect when a stage component has been changed if any of the elements inside it have been enlarged?
This seems like it should be available but I can't find one that doesn't fire before the redraw. Or at all for that matter.
I want to dynamically resize and align a Sprite with a DropShadowFilter so it fits all Stage but in a way that the Shadow keeps visible.
The problem is that when I resize the Sprite it fits the Stage but it doesn't take the filter in consideration and the shadow is drawn outside the stage.
For example:
imageSprite.filters = createFilters(); // this method creates the DropShadowFilter var s : Sprite = new Sprite();
[Code]....
Resizing Sprite 's' has the same effect as resizing 'imageSprite' and I couldn't find a way to get the size of the image+shadow.
Im trying to get the sprite overlay to stick to the edges of the stage when I resize the swf window. It works when you resize the width, but not the height.
I want to load two picture and add every picture to every sprite object,such as picture a to sprite1 and picture b to spriteb,I know I can load a pictue by following code:
loadImage('a');loadImage('b');private function loadImage(imagePath:String):void { var loader:Loader = new Loader(); loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onImageLoaded); loader.load(new URLRequest(imagePath));}private function
What I'm about to ask might be completely nonsense/basic or something else. Because my AS knowledge is too little. Hope I can explain correctly. I am tring to create a sliding banner animation dynamically. The reason that I create dynamic is that I want to load banner images and headlines from XML file.
What I'm about to ask might be completely nonsense/basic or something else. Because my AS knowledge is too little. Hope I can explain correctly
I am tring to create a sliding banner animation dynamically. The reason that I create dynamic is that I want to load banner images and headlines from XML file.
So I found a sample project with .as and .xml file. It does what I want but it has no animation. You can see the demo here: [URL] As you can see, there's a transparent info panel below. Here's the code how it is being created:
private var infoPanel:Sprite = new Sprite(); private var titleField:TextField = new TextField(); private var description:TextField = new TextField();
I want to load two picture and add every picture to every sprite object,such as picture a to sprite1 and picture b to spriteb,I know I can load a pictue by following [code]...
I have created instance of textField Object and set property scaleX and Y in large and then I my textfield set into Sprite Object. I saw my text in ugly font . How can I have my text in smooth .
I have two sprite object and they direct to same event like follows: sprite1.addEventListener(MouseEvent.CLICK, mouseEventHandler); sprite2.addEventListener(MouseEvent.CLICK, mouseEventHandler); private function mouseEventHandler(event:MouseEvent):void { //how to do it here? } When click spirt1 or sprite2,it will call mouseEventHandler function,my question is how to determine which sprite is click in mouseEventHandler function,sprite1 or sprite?
I'm trying to debug AS3 code on production. I have no access to trace(), can't write to disk or open a socket. What I want is to display something on screen.
With AS2 I could just access _root and create a text field with my trace data.
how I can pull this off with AS3? My class extends Object, it is not a sprite and is never added to a parent display object.
I'm rendering a xps file using flash (no MX or Spark), and I'm running into a sort of 'contradiction' that I'm unable to solve. [Note, that I'm trying to work only in core flash (e.g. Sprite, Shape, etc.), I've already solved (sort of) this issue using Spark.]
The pages of the xps file specify an explicit size. However, the content described (especially paths) in the xps file can sometimes extend outside of this area.
The problem is, I want the parent Sprite to have the size specified by the xps file, for example so scroll bars match the page size (not the sprite size), but in some cases the Sprite is much larger than this.
I've tried recursively going down and scaling everything UP, and then at the end scaling the parent container DOWN. Unfortunately, this causes translation problems with paths, and I assume it can also cause problems with bitmaps, etc.
Without using MX or Spark, is there anything I can do to control the size of the parent Sprite, other than scaling all the children independently?
I load a picture file by Loader and add Bitmap into sprite,like follows:sprite1.addChild(myBitmap);Now I want to get the myBitmap from sprite1,how can I get myBitmap from sprite1,what code can I use?
I have a Sprite object on the stage. What I should do in order to change the dimensions (viz.,size,colour, or both ,etc) of this Sprite object, when it gets clicked?My sample code looks like this:
Code: var circle:Sprite = new Sprite(); stage.addEventListener(MouseEvent.CLICK,onStage); function onStage(e:MouseEvent):void {
I am trying to get an image object from one sprite container and adding it to another sprite container. But when I use GetChildAt for this, it will remove the object from the parent sprite and place it inside the other.
I've got a few spites on stage that are created dynamically and live in an array. I'm rotating images through these sprites and now need to know which image is in a sprite when clicked. My code: loading the images:
I am really confused with this tutorial as there is shown how to assign z dimension to the Sprite object. It is never declared, so I assume the z property should be implemented to the Sprite class. But obviously I get an error when I try to build the application does not matter if it is flash or flex app. From my point of knowledge I can not find z property for Sprite in the actionscript, so I do not know how Lee implemented his code to work. Below I put all the code from the tutorial, so you can quickly glimpse at it. How is it possible to assign z dimension to work it, or suggest what kind of class to import or whatever I should do, or know anything about the z dimension in flash player 10.I do not really think z could be in 10-beta and is not in 10 official.
Here, my loader instance name is: myLoader. When I click on the dynamically loaded image, I need to place a small red rectangle at that particular pixel position on the image.For creating a small rectangle, I am using following code:
I'm making a game where I have must have some objects like weapons and characters, which I in the end would like to get visual as a sprite or movieclip
Should I write the logic for the objects in several classes and then make a reference to the object in a sprite class like the following :
[Code]...
And then when I need to do damage just call the WeaponSprite's method weaponModel() when I need to acces the methods or should I just merge the two together into one class.?