Flash :: BitmapData.rect Creates A New Rectangle?

Jul 15, 2011

I was working on some blitting code today and after profiling it found that I was creating 1000s of new rectangles. I was shocked because I only had 1 or 2 different new Rectangle() calls or I was using the .rect property of BitmapData.

I started commenting out huge swathes of code until I was left with this code in my sprite class:

canvas.bitmapData.copyPixels(_bitmapData, _bitmapData.rect, destination, null, null, true);

I cached the result of _bitmapData.rect at object creation and my thousand of new rectangle calls were suddenly gone from the profiler.

Why the heck would BitmapData.rect create a new rectangle? Is there a way to check the core libraries or something and confirm this is true?

View 4 Replies


Similar Posts:


ActionScript 3.0 :: Detect Size Of Rect:rectangle In A Class?

Jan 29, 2010

From my main flex mxml, I am trying to detect the size of a rect:Rectangle that I created in my InfoBubble.as class. The info bubble itself is created in my InfoMap.as class. How can I access the attributes of the rectangle I created?

Here is the variable portion of the InfoBubble class:

Code:
public class InfoBubble extends Sprite
{
//public var textField:TextField;

[Code]....

View 1 Replies

ActionScript 3.0 :: Use TweenMax To Scale Up A Rectangle (instantiated As Rect) On Mouse Over?

Aug 28, 2009

i was trying to mess around with flash and I was hoping I would use TweenMax to scale up a rectangle (instantiated as rect) on mouse over, and then once it is scaled up I wanted to load an swf file to its center (the swf is called CircularPreloader.swf which is a fake preloader, just for messing around porpuse). Well, I tried but it didn't work cuz I kept getting this

error: TypeError: Error #1009: Cannot access a property or method of a null object reference.
at scaleUp_fla::MainTimeline/frame1()

Here's the code:

import gs.*;
import gs.easing.*;

[code]....

View 12 Replies

ActionScript 3.0 :: Text To Bitmap Error (Creates Rectangle)?

Jul 15, 2010

I'm doing a basic reflection class that will take any MovieClip, create a copy (using BitmapData), and do the flipping, alpha, gradient mask, etc to create a nice reflection.The class works great, with the exception of dynamic text.I've done quite a bit of searching, and I realize that you must put the TextField into a MovieClip and then take the BitmapData of the MovieClip.

Sounds great... but when I actually do this, the BitmapData that is display on the screen is a box (like a bounding rectangle around the text) that is filled with white.
Other relevant info:

1.) The TextField has embedFonts = true;

View 4 Replies

Actionscript 3 :: Resize A Rect Within Another Rect?

Aug 27, 2011

I draw a rectangle within another rectangle like this (I use it as a mask):

CanvasBorder.graphics.beginFill(0xf0ff00,0.1);
CanvasBorder.graphics.drawRect(100,100,550, 300);
CanvasBorder.graphics.drawRect((stage.stageWidth/2-Canvas.width/2),(stage.stageHeight/2-Canvas.height/2),250, 150);
CanvasBorder.graphics.endFill();

effectively its a 550x300 box with a 250x150 cutout.

Within one of my functions I need to resize the INNER 'cut-out' box from 250x150 to 150x100 - but keep the OUTER box exactly the same.

Normally when I'd resize a normal rectangle I'd do this:

rectangle .width = 150;
rectangle .height = 100;

View 1 Replies

ActionScript 3.0 :: Resize A Rect Within Another Rect?

Aug 27, 2011

I've got a tricky one that's stumping me, could you take a quick look over it I draw a rectangle within another rectangle like this:

Code:
CanvasBorder.graphics.beginFill(0xf0ff00,0.1);
CanvasBorder.graphics.drawRect(100,100,550, 300);

[code].....

View 2 Replies

ActionScript 3.0 :: BitmapData Of A Rotated Rectangle?

Aug 5, 2010

I'm using following code:

ActionScript Code:
var bd:BitmapData = new BitmapData(stage.stageWidth, stage.stageHeight);
bd.draw(stage, null, null, null, new Rectangle(tmpX - (tmpW/2), tmpY - (tmpH/2), tmpW,

[code]....

View 9 Replies

IDE :: Changing The BitmapData.rectangle - X And Y Locations

May 2, 2009

I'm trying to take a 'snapshot' of a movieclip that i've got on the stage with "BitmapData" and then starting a "draw()" command on it. I'm able to get it drawing.. however.. it only takes the things from (0,0).( the upper left corner of the movieclip. Doing a trace on "BitmapData.rectangle" gives me it's X and Y coordinates .. and it's width and height..

How do I change the X and Y locations of the BitmapData for it to start the drawing from? As I have some stuff on the negative side of x.

View 1 Replies

Actionscript 3 :: Apply ColorTransform To BitmapData In Circle Rather Than In Rectangle?

Jan 2, 2010

Is there a way to apply a colorTransform to a BitmapData in a circle rather than in a rectangle?

Instead of erasing rectangular parts of an image by reducing the alpha channel as in the code below, I'd like to do it in circles.[code]...

View 1 Replies

ActionScript 2.0 :: BitmapData - Calculations Of The X,y Coordinates Of The Rectangle Cropping ?

Oct 6, 2007

After seeing the I've been told that movieclips aren't suited for games, what do you use? thread, I thought I would try to incorporate the approach into a game I'm currently programming to make it a little less processor intensive.

I have a giant movieclip of a football field, of which only 5-10% is shown at any given time. I'm guessing that flash still has to make calculations for the other 90-95% of the field every frame, even though it's of no use. From what I understand (not much), copyPixels seems like the perfect candidate for such a situation.

It seems simple, but I'm having trouble actually implementing it, and I'm not sure which actions are needed and what might be introducing unnecessary work. I have a movieclip (mc_field, exported for as), but if it would save the processor some effort,I could easily save this as a bitmap and export that for actionscript. The width and height of the final product (bitmap/BitmapData) will be Stage.width, Stage. height,respectively,and I can handle making the calculations of the x,y coordinates of the rectangle cropping (which part of the source bitmap I want to crop).I'm sure it's only 3 lines of code, and I know that there are a few examples online, but for some reason.

Say, for frame one, I want to take the field (either mc_field or bm_field) and copy 500px x 300px, starting at 140,230 from the source bitmap to mc_container.Then, for frame two, I want to copy 500px x 300px starting at 240,540 from the source bitmap to mc_container.

View 4 Replies

Actionscript 3 :: Bitmapdata - GetColorBoundsRect - Find The Rectangle Area Or Each Circle

Jun 20, 2011

I have a BitmapData with 2 red circles. I want to find the rectangle area or each circle. If i use [B]getColorBoundsRect[/B] I get the smallest area enclosed by the 2 circles. How can i go about this and get individual area of the circles?

View 1 Replies

Actionscript 3 :: Use The Method SetPixels(rectangle, ByteArray) Of BitmapData In Adobe Flex

Feb 3, 2011

Error #2030: End of file was encountered.

This method is not working

I am using it like this

var ba:ByteArray = new ByteArray();
ba = bmd.getPixels(bmd.rect);
bmd.setPixels(srcRect, ba);
bm.bitmapData = bmd;
img.source = bm;

View 1 Replies

ActionScript 2.0 :: Flash 8 BitmapData - Getting Error : The Class Or Interface 'BitmapData.loadBitmap' Could Not Be Loaded?

Jan 31, 2007

I'm using Flash 8, with this code in the first frame:

import flash.display.BitmapData;
rissa._x=Stage.width/2;
rissa._y=Stage.height/2;[code].....

When I publish the file, I'm getting the following error message in the Output panel:

**Error** Scene=Scene 1, layer=Layer 2, frame=1:Line 7: The class or interface 'BitmapData.loadBitmap' could not be loaded.
var plaid:BitmapData.loadBitmap("plaid");

Total ActionScript Errors: 1 Reported Errors: 1

View 8 Replies

ActionScript 3.0 :: Error #2015: Invalid BitmapData At Flash.display::BitmapData()

Oct 14, 2009

I am trying to use the reflect class from "http://pixelfumes.blogspot.com/2007/03/reflection-class-v3-with-source .html" but I keep getting this error:
 
ArgumentError: Error #2015: Invalid BitmapData.
at flash.display::BitmapData()
at Reflect()
at Site_fla::GalleryPage_29/loadThumbs()
at Site_fla::GalleryPage_29/sortXML()

[Code]...

btw, first I used assigned thumbContainer as the mc argument (outside the loadThumbs() function) and it worked but not exactly what I wanted... because I thought it is supposed to update when the movieclip is animated but it actually didn't... when I use a scroller, only the thumbs that are first loaded to the stage get the reflection..

View 10 Replies

Actionscript 3 :: Scrollbar With Sprite And Rectangle Won't Move Text, Just The Rectangle It's Painted On?

Mar 8, 2010

For those of you still with me, I am tasked with making some scrollable content in Flash. Load in a TextFile using LoadURL(), then display it. To get the text, we've written our own class TextFieldExtended, which is basically just there to give the textfile location to the constructor and then have the class do the various steps of getting it and loading it for you.So I needed to get a Scrollbar, which I got hereThe thing is, it works with Sprites.After trying to get it to accept TextFieldExtended, I bumped into a block, since the scrollbar relied heavily on a Sprite property that TextFieldExtended didn't have or could have.

So I tried adding the TextFieldExtended instance to a Sprite instance using addchild.A problem occurs here that I do not know how to handle. It seems that a Rectangle is drawn and the Text is drawn on that. I say this because the scrollbar moves the Rectangle up and down a bit, but the text doesn't scroll, just the Rectangle it is positioned in and the text then moves along with it.My question: can this be fixed, or is does this implementation of scrollbars need a lot of adaptations before this is possible?

View 1 Replies

Draw Rectangle Should See Little Bold Circle To Indicate A Perfect Rectangle

May 20, 2009

I draw a rectangle i should see a little bold circle to indicate a perfect rectangle, I seemed to lost mine, can somebody please tell me how to get it back!

View 2 Replies

Flex :: Rect Rounded Corners Be Different?

Jun 21, 2010

When I use <s:Rect> to create a rectangle, I use radiusX to get rounded corners. Problem is all are the same roundedness. Is there something similar to Rect that lets me control the radius for each corner separately? If not, what's the best way to create this from scratch? graphics library or what?

View 3 Replies

Flash :: CreateEmptyMovieClip Creates It On All Frames?

Feb 15, 2011

I have a question regarding createEmptyMovieClip in AS2. I have a flash file separated out into sections with labels and menu buttons which allow you to move you to the relevant frame/section (which contains the information/contents relevant to that section). This works fine. What I can't work out is that if I manually put a movieclip on the stage in my 'about section' and then add contents to it via AS2 then it only exists within the about us section. If I do it using createEmptyMovieClip within the actions for the about frame this works fine but it then always exists on every other frame of the project. I assume this is because it isn't actually creating it within this frame but I can't work out how to make it do this, even when i use this.createEmptyMovieClip it has exactly the same effect. I can obviously remove the movieclip completely each time a user moves to another frame that doesn't contain it but I don't want to do this as it contains a youtube video and leaving it means it doesn't have to be reloaded each time they come back.

I would be massively grateful if anyone could shed any light on this for me as I know i'm not getting how to place it correctly but i'm not sure how I should be doing it?

View 1 Replies

ActionScript 3.0 :: Convert Rectangle To Curved Rectangle?

Aug 2, 2011

I am trying to convert a rectangle(actually multiple rectangles) to a curved rectangle. I think it should be pretty easy but I guess i am stupid. Basically I would have a start position and stop position (many of these), and they would be converted to curved rectangles and follow in a cicrle around.

View 0 Replies

ActionScript 3.0 :: Creating A Rectangle Inside Of A Rectangle?

Jun 26, 2010

I would like to create a rectangle inside of a rectangle, starting approximately 15% inward from the right side of the other rectangle.

I know how to create rectangles with:

Code:
var newHotRect:MovieClip = new MovieClip();
newHotRect.graphics.beginFill(0x00FF00);
newHotRect.graphics.drawRect(0, 0, 100, 100);
addChild(newHotRect);

But how would I make another rectangle on top of that (the black one pictured) that is approximately 15% from the right?

I toyed around with .right, and .bottomright with no success. Can anyone lead me in the right direction? or even finding the x and y of the upper right or bottom right side of a rectangle?

View 10 Replies

ActionScript 3.0 :: Rectangle To Rectangle Collision Response?

May 20, 2011

how to respond when a rectangle hits another rectangle? I already know how to detect the collision, I just don't know how to respond to it. I'm just trying making a simple side-scrolling platform game where I have platforms I can walk on and bump against on all sides. I have searched everywhere and just can't find the tutorials I'm looking for.

View 6 Replies

Flash :: Pro SC5 Creates Multiple Copies Of Images?

Feb 11, 2011

I load images into my .xfl project and use them amond movie clips - everything is ok at beginning. But after a some moment (which is absolutely undefined) Flash Professional CS5 starts duplicating all of them at saving and new copies names with "Copy 1", "Copy 2" and so one, or just with blank string. Because Flash duplicates them EACH saving, so after a several savings Flash refuse to save at all (shows "Too big project ..." error).

View 7 Replies

Flash 9 :: BeginFill Without MoveTo Creates Different Fill?

Oct 10, 2008

. As far as I could see in the reference manuals, the beginFill() method of the flash.display.Graphics class ends any previous incomplete (i.e., not ending back at the start point) fills by automatically drawing a line to the latest MoveTo() location.But, it seems it also ends any previous incomplete drawing even without fills, by drawing that final line.

But that's ok. The weird part is, even when I draw just one line and begin a fill immediately after that, I guess it tries to complete that line by drawing one more line back to the starting point and the messes up the display with the fill color in the following beginFill() call.

public class MyContainer extends Container
{
public function MyContainer()
{

[code]....

The output is as in the attachment.The first part creates a weird fill along the side of the line till the end of the container object.I even tried a endFill() at line 4, but same result. The only way to prevent this is to explicitly moving to some point as in line 11.

View 0 Replies

ActionScript 2.0 :: Get An Xml Fed Into Flash That Creates Multiple Icons?

Dec 11, 2007

i got an xml fed into flash that creates multiple icons. When icon is clicked it will load an external swf into a container. I am having issues with this part:

Here is question

Why does this work in a test file:
myContainer._lockroot = true;
myContainer.loadMovie("movie.swf");
xml:
myContainer._lockroot = true;
myContainer.loadMovie(this.link);

this.link refers to location of swf file that is related to the icon pressed in xml.Everything works fine and dandy however here is the trouble, they all have different parameters and when loaded into another container thus in a swf they lose some of these. However in my test file when it is simple and straight just 2 lines of code (see above) everything works.

View 2 Replies

Flex :: Converting Mxml Rect & SolidColor To Actionscript?

Mar 19, 2010

how to use actionscript over mxml for flexibility. I have this simple block of mxml that I'm trying to convert to actionscript, but I'm stuck half way though

<s:Rect id="theRect" x="0" y="50" width="15%" height="15%">
<s:fill>
<s:SolidColor color="black" alpha="0.9" />

[Code]....

What's the most efficient way to add the SolidColor in as few lines of code as possible.

View 2 Replies

Flex :: Rect Drawn With Graphics Appear Below Background Of BorderContainer?

Nov 2, 2011

In a Flex component that inherits from BorderContainer I'm overriding the updateDisplayList function to draw a rect:

override protected function updateDisplayList(unscaledWidth : Number, unscaledHeight : Number) : void
{

[code].....

View 2 Replies

Professional :: Any Flash Component That Creates Slide Transition?

Mar 27, 2011

Has anyone seen a Flash Component that creates a slide transition similar to this [URL]. Looks like there is a looping background image and the other slides are loaded above it (hopefully via XML?) and the transition effect maybe in a component???

View 1 Replies

IDE :: Flash Does Not Remember To Delete The Previous Export And Creates Another One?

Feb 17, 2009

when I do linkage on a symbol and export it for AS3. Then I edit the symbol, for instance go in and modify anything inside, a shape, etc... the next time I try to publish flash, i get an error multiple constructor definitions found. constructor may not be defined in <Script/> code.I think may be it's because flash does not remember to delete the previous export and creates another one. The only way to resolve this, is to delete the entire symbol and re-create it.

View 1 Replies

ActionScript 3.0 :: Why Flash Creates Extra Instaces Of Class

Oct 7, 2009

I have linked a MovieClip to a class. After that I have places some movie clips of them on the stage. And now I like to do something with them, but I couldn't because some extra instances are created (I wonder how???) and they make me problems.The names of instances of the class I placed on the Stage are legs1 legs2 legs3,and the extra instances are: instance21, instance25,...(and they are not visible on the Scene)

View 2 Replies

Actionscript 3 :: Prevent A Rect From Moving From Its Position When Decreasing Width?

Apr 12, 2012

I seem to be having problems with rectangles moving from their assigned positions when all I want to do is decrease their width.A game I'm working on simulates an explosive with a fuse. The fuse decreases in size as a clock counts down to 0.I think the problem has to do with local coordinates vs. global coords, but I'm not sure how to rectify the problem. Here is some code:

//fuse
_fuse = new Sprite();
_fuse.graphics.beginFill(0x000000);[code]........

Nowhere in my code does the x position of the fuse change.Aside from this one issue, the rect functions exactly how I want it to.

View 1 Replies







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