ActionScript 3.0 :: Cropping Out Whitespace In BitmapData

Jun 4, 2008

Does anyone know of a way to crop out whitespace/transparent pixels in a BitmapData object? I've got this movieclip I'm rendering that has a huge amount of whitespace all around it. I'd like to crop all of that out before I convert it to a JPEG (with corelib). Is there a way to do this? I can't seem to find a way to figure out where the first opaque pixel starts on each axis to determine the extents.

View 6 Replies


Similar Posts:


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

Flash :: Rotate BitmapData When Using Draw Method. Width Height Bounds Clipping / Cropping?

Jan 29, 2010

I wrote a collision detection class that works off using BitmapData.hitTest. Basically, every update, the .draw method is called and then two BitmapData's are hitTest'ed against each other to see if there is a collision.It works pretty well, however if I start rotating the source MovieClip I use for the BitmapData, the transformations don't get registered in the draw method. So what I did was pass through a Matrix in the draw method. That works. But here's the actual issue. If I output the BitmapData to a Bitmap on the stage, I see that Bitmap is, in fact, rotating, but now it's exceeding the bounds (width and height) of the BitmapData. Which is cropping / clipping the image of the source MovieClip.

UPDATE: Basically, when the Bitmap clone of the MovieClip rotates outside the positive co-ordinate space, it doesn't get drawn. It rotates outside the bounds of the BitmapData set width and height. I can multiply the bounds by 2, and then center the bitmap inside the set bounds, but then the origin point is never fixed and the object is always being moved around. Works pretty well, but makes aligning the object to any specific point impossible.Here's my isolated test code. It requires you to have a MovieClip on the stage named "iTest". I used a fairly vertical arrow shape (higher than it is wide) so I could keep track of rotations visually accentuate the clipping problem:

var rotateTimer:Timer = new Timer(10);
function rotateObject_init():void
{

[code].....

View 2 Replies

ActionScript 3.0 :: Removing Whitespace In Jsp?

Aug 16, 2011

i am loading a jsp file, which had some space at the beginning. i want remove the space,then i need ot parse the data, just like ignoreWhiteSpace in xml.

View 5 Replies

Actionscript 3 :: Remove Whitespace In It?

Apr 22, 2010

How can one remove whitespace from a string in as3?

I would like to be able to remove all carriage returns, spaces, tabs etc.

View 2 Replies

ActionScript 1/2 :: Can't Strip Whitespace Or Returns

Mar 15, 2010

I have few ActionScript skills. But I have built a multimedia career by stealing chunks of AS2 code and reworking them to suit my purpose. I have searched long and hard here for a solution to my current problem. I have found code here that seems to address it, but I cannot make it work. I simply have some textAreas that I wish to validate. The user may input text that could include extra spaces, returns, and odd capitalization. It would be easiest for me to simply strip out the capitals, spaces and returns. I found some simple code that changed the caps to lowercase:[code]

View 5 Replies

Flash :: Trim Whitespace Around A Transparent PNG

Oct 22, 2010

I've managed to get myself stuck in a situation where a database full of images ( transparent images of various products ) needs to be placed on the stage, all of which need to be aligned the same by the products height. My problem is that the png's of products are 'floating' and I have no control of where about's in the png it will sit ( could be tight at the top and loads of room at the bottom, vice versa)

Does anyone know an existing way to find out the png's 'true' height ( width is an extra ). I've thought about looping through the bitmap data and checking but wondered if anyone has invented this wheel already?

View 4 Replies

ActionScript 3.0 :: Ignore Whitespace In Indexof?

Oct 4, 2011

I'm trying to serach for the following string "Type/Pages" in long external files and am using the follwoing code which works: indexOf("Type/Pages");

However, sometimes it appears in the file as "Type /Pages" - with the extra space

As the files can be VERY long, I don't want to search twice - is there anyway to search with or without the space?

I've tried all sorts of cominations with s* but to no avail

View 6 Replies

ActionScript 2.0 :: Cropping A Loadmovie?

Mar 15, 2006

I m building a site whit transparency so my background HTML can bee viewed, at some point I load a movie on level1, it's supposed to bee smaller than the Level0 movie but instead I end up getting flaps on the level0 movie because the original content of the level1 movie sticks out, I can't put a mask for it will occlude the HTML background, and it doesnt matter if I keep shortening the loaded movie it still shows up like it has a mind of its own...

View 3 Replies

ActionScript 3.0 :: Preserving WhiteSpace With HtmlText When Using CondenseWhite

Oct 24, 2008

I have a website I'm making. The contents of it is set via xml documents.Now because in the xml for the sake of keeping it clean I make sure when setting all text to any TextField I set it with condenseWhite set to true:[code]Now this condense white creates a few weird bugs when using htmlText... things like img tags acting really weird and the sort.But that isn't my concern right this second. What I want to do though is allow the user to choose the ability to preserve whitespace in some manner for instance here is the main xml document loaded and used to load all subsequent docs:[code]

I've tried stick in there and that fails. I've tried the <pre> tag from html, failed, which I assumed it would. %20 doesn't either.I also thought of sticking a "preserve" attribute on it and checking that before setting text (as you can see in the xml code)but in some scenarios in my application it creates very convoluted code just to update dynamic textFields (I have textfields that swap out a lot, like in the photogallery as can be seen here: URL...Or maybe knows a site that has a well documented explanation of the html abilities of the TextField.I've been reading around on the internet and playing in flash for a while now testing different things and still no result.

View 3 Replies

ActionScript 2.0 :: Detect Whitespace And Return Everything Before The Space ?

Jun 28, 2010

I have a variable that contains the text from an input box.

let's call it "name"

People may enter the persons first and last name into this box. If they do .. I want to be able to capture just the first name from that string. So somehow capture everything before the first whitespace.

View 3 Replies

Professional :: Cropping A Flash Document?

Dec 1, 2010

I recently made a flash document with animations and some AS at 1600 pixels wide. It turns out that my web developer is having trouble using the file and would like it cut down to 1200 pixels wide. I can make the document 1200 wide, but then everything is off-center. Is there any way that I can crop it to 1200 my taking 200 pixels off of each side instead of just 400 off of one side? If not is there an easier way to just select every layer and tween at one and move them over

View 1 Replies

Media Server :: Video Is Cropping In Swf

Mar 9, 2011

The Camera  video is played well in other applications, but when I am using Camera in flash applications to play the live video, then video is cropped.

View 1 Replies

Flex :: Cropping/Clipping A Sprite?

Jul 7, 2010

How is cropping/clipping accomplished on a Sprite in Flex?

<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" creationComplete="Init()">
<mx:Script>
<![CDATA[

[code]....

Notice that the lineTo completely leaves the UIComponent and Panel.How can I cause my UIComponent or Sprite, Or Panel for that matter, to be cropped/clipped? I realize I could just change the hard-coded 2222's to something more reasonable, but I need a generalized solution to this, since the actual project doesn't involve hard-coded values that I can alter, but works with dynamic data.

View 2 Replies

Flex TextFlowUtil.importFromString Ignoring Whitespace In Some Cases?

Feb 17, 2011

In the following complete functional Flex application the line breaks between the two links ought to be preserved when importing the input text into the TextFlow:

[Code]...

View 2 Replies

Flex :: 3 - Whitespace Required Before Attribute Error In Code

Apr 18, 2011

In my flex code I am getting error whitespace required before attribute what may be problem below is code

[Code]...

Even on this code too I am getting error whitespace required before attribute below is code

[Code]...

View 2 Replies

ActionScript 3.0 :: Loading Plain Text With Leading Whitespace?

Sep 13, 2009

When I try to load text from XML into a text field any leading line breaks or spaces are ignored. For example:

Code:
<text> some text</text>

The preceding loads into the text field without the leading spaces before "some text". How can I force the spaces to appear?

View 2 Replies

Professional :: Sprite Sheet Cropping Funny

May 2, 2010

SO I am working on animating a 20/fps sprite (an SCV from Starcraft 2). The animation is 1 second long, and thus 20 frames. I have made a sprite sheet in photoshop, and have each frame as a separate layer. I import the PSD into my library and have it convert the layers to "Flash Frames". I get each frame nicely tucked away as a layer in my library. Problem is, it gives an ugly white border (about 1 to 2 pixles thick) around my sprites, making it look like I did a terrible crop job. However, the crop job is fine (I can change the background in the PSD to black, and the cropped sprite frames look perfect! What have I done wrong or need to do?

View 1 Replies

ActionScript 3.0 :: ClipRect - Cropping An Image With Draw?

Nov 18, 2009

Using DRAW I want just a part of the original image. I am using the "Rectangle" bit of the paramaters, but I can't get the start of the crop away from the top left corner.

Here's my code :

ActionScript Code:
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.text.TextField;

[Code].....

View 1 Replies

ActionScript 3.0 :: Scaling In Aspect Ratio Without Cropping?

Jun 8, 2010

I want to know how can i make something like if any one scale browser my site will scale in aspect ratio without cropping

something like jimcarrey website [URL]

View 2 Replies

ActionScript 2.0 :: Dynamically Cropping (masking) An Image

Aug 24, 2009

I made an xml loaded dynamic image gallery and I cannot figure out how to crop the image should it be too big. Masking appears to work only with a movieclip created outside of actionscript (which cannot be created dynamically).

View 2 Replies

ActionScript 3.0 :: Click On Whitespace Of Text And React To Event Listener?

Mar 25, 2010

Not sure if I phrased that correctly. I have about 6 pieces of illustrator outlined text.imported into flash, set as symbols with event listeners and works fine. but i notice I can only click on the outline itself, if i click on the inside of an "o" or "R" it doesnt work.I added white boxes behind each of the symbols and that fixed the problem, but now i want to do a color transform on the symbol (the text only of course), but when I apply the transform, its the background box and the text that have the new color applied, just leaving me a rectangle. I gave the box an alpha of 0, hoping if i didn't affect the alpha in the transform, the pointer would still read the box, but no go, it doesnt even see the box again.

View 4 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 :: Quickly Rotate The Pixels That Make Up BitmapData Without Using BitmapData.draw()?

Dec 29, 2011

I've been using BitmapData.copyPixels() to draw graphics onto a canvas (Bitmap).I need to rotate the resulting graphics without the use of draw() because it's vastly slower.How can I rotate the target graphic? I'm assuming that there might be a formula or library that I can use which will first reorganize the pixels that make up a graphic based on an origin (point) and radians.I'm pretty certain that I'm not capable of creating such logic, so if there are any known libraries that do this, that would be awesome.I'd like to achieve something similar to XNA's SpriteBatch.Draw() method, which accepts rotation as its 5th argument.

View 3 Replies

ActionScript 3.0 :: BitmapData.hitTest - What Angle Or Coordinate Of The BitmapData The Collision Happens?

Sep 1, 2011

how to use the bitmapData collision method. Now I'm trying to figure out if there is a way to see at what angle or coordinate of the bitmapData the collision happens? I need it in order to figure the accurate bounce angle after the collision occurs.

View 2 Replies

ActionScript 3.0 :: Use Object Handle For Image Cropping And Rotation?

Feb 14, 2011

i have downloaded the rogue object handle 2.008 i need to know how to Use it to cropp and rotate the Image.

View 1 Replies

Actionscript 3 :: Scaling And Cropping An Image With Fixed Dimensions?

Dec 10, 2011

I want to display an image, and it should be transformed like this:If for example, my original image is 200x300 pixels in size, I want it to have a width of 150, and then scale the height accordingly. Then I want to crop the image, so that the result has a dimension of 150x150 pixels.

View 2 Replies

ActionScript 3.0 :: Cropping Externally Loaded SWF To Stage Bounds?

Jul 27, 2009

When using the Loader class to load an external SWF into another timeline and then displaying that SWF using addChild on the loader.content, one discovers to one's consternation that elements positioned off the stage of the external SWF are still displayed.To illustrate this with an example: suppose you have a 500x500 pixel "main" SWF, and it loads an external SWF at runtime and positions it in the center of the stage. And suppose that this external SWF's document properties set the stage width to 200 x 200 pixels. However, when authoring this external SWF, we draw a box that's 300 x 300 pixels, so part of this box is actually off-stage.

When you play the external SWF in the standalone Flash player, it is sized correctly at 200 x 200 pixels, and the rest of this box is cropped off.When you load this external SWF into the "main" SWF and use addChild() to put it on the stage, you will see the full 300 x 300 pixel boNow of course, we can simply solve the issue using a mask, but I'm wondering whether there's a more elegant solution that's built in, either to the MovieClip or the Loader or the LoaderInfo classes. Something that says "respect the document bounds of the original SWF" or "crop to stage dimensions".

View 1 Replies

Actionscript ::Why Is Typecasting (as Class) In FDT Formatter Formatted With The Relational Whitespace Option

Aug 13, 2011

Turning of the whitespace around relationals formats the code into:

getDefinitionByName("Helloworld") as Class

into

getDefinitionByName("Helloworld")asClass

Has this been changed in FDT 4.0?

View 1 Replies







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