ActionScript 3.0 :: Dynamic Coordinates For CopyPixels Rectangle

May 6, 2010

I believe this is esentially a math problem that may be easy for most of the programmers out there, but I am stuck. I have a fixed rectangle width = 50 height = 50 centered in the middle of the stage. I am using this rectangle to copyPixels of a bitmap that is also centered on the stage. The bitmap is draggable. I can define the initial x,y of the rectangle used for copyPixels with

[Code]...

View 1 Replies


Similar Posts:


ActionScript 2.0 :: Constrain To Rectangle Coordinates?

Oct 4, 2005

I'm doing a tutorial on using the startDrag function but have no idea how to get the coordinates for my rectangle.How do you find the 4 points? I've tried using my mouse to pinpoint the location but that doesn't work.Here is the generic code:myMovieClip.startDrag(false, left, right, top, bottom);

View 2 Replies

ActionScript 2.0 :: StartDrag - Constrain To A Rectangle (or Coordinates)

Jan 24, 2006

I have 9 images that are draggable on my screen - and when pressed become the top image- using the script below. I'd also like to constrain to a rectangle (or coordinates) - ideally adapting the exisiting script and movie clip set-up.

[Code]...

View 6 Replies

Actionscript 3 :: Generate Random Coordinates From Area Outside Of A Rectangle?

Apr 29, 2010

I'm working on a simple tutorial, and I'd like to randomly generate the positions of the red and green boxes in the accompanying images anywhere inside the dark gray area, but not in the white area. Are there any particularly elegant algorithms to do this? There are some hackish ideas I have that are really simple (continue to generate while the coordinates are not outside the inside rectangle, etc.)

View 2 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 2.0 :: Acquire Top Left Bottom Right Coordinates Of A Rectangle?

Apr 12, 2009

I want to accurately find out the top left bottom right coordinates of an object. Let's say an rectangle.

View 2 Replies

ActionScript 3.0 :: Dynamic Drawing Of Rectangle?

Jun 10, 2009

I am trying to make a dynamic drawing tool for rectangle like this link : [URL]
 
I was able to make a line tool.

View 3 Replies

ActionScript 3.0 :: Click And Drag Out A Dynamic Rectangle?

Apr 6, 2010

Basically using nothing but code I want to be able to hold down my mouse button and when I move my mouse a rectangle of any proportion based on from where the mouse left off is madeI can stretch this out to anywhere on screen till my finger is lifted off the mouse button.nce my finger is off the rect stays there till I create another and the previous rect disappears.I know how to creat a rect normally in AS3 but this has just stumped me

View 6 Replies

ActionScript 3 :: Creating Dynamic Rectangle With Text Inside

Jan 3, 2011

I'm wondering how I can create a dynamic rectangle wich has some text in it, the text is dynamic so the rectangle has to adapt to the length of the text. How to approach this?

View 3 Replies

ActionScript 3.0 :: Assigning X And Y Coordinates In Dynamic MovieClip

Jan 11, 2010

I cannot assign _x and _y coordinates in a movie clip dynamically. For example:
for (i=1; i<=5; i++) {
myThumb_mc = "thumb" + i;
myThumb_mc._x = Stage.width/2;
myThumb_mc._y = Stage.height/4;
}

But if I do:
thumb1._x = Stage.width/2;
this works.

View 3 Replies

ActionScript 2.0 :: Rendering A Dynamic Rectangle - Draw A Dashed Border?

Feb 1, 2004

Here's my latest attempt at rendering a dynamic rectange (w/ width, height, border_width, border_color & background_color) I'm trying to render a dashed border, and can't seem to get the code right...

I've reworked my logic about five times, and can get the dashes to render right (almost) but the fill color disappears. It's rendered using actionscript. You can see the issues if you change the border width... Anyone mind taking a look to see what I'm doing wrong? It seems like the moveTo function isn't behaving right when I get to the end of each line.

[Code]...

View 3 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

Actionscript 3 :: Convert Global Coordinates To Local Coordinates Of A UIComplenent In Flex Project?

Dec 19, 2011

I was trying to convert global coordinates to local coordinates of a UIComplenent in my flex project using below code using below code

var gp:Point = new Point(e.stageX,e.stageY); //global point
var lp:Point = uic.globalToLocal(gp); //local point

uic is UIComponent in which I have subclass of Sprite for drawing something I have set the sprite's mouseEnabled and mouseChildren to false to not interrupt the mouse event. above code is within uic's mousemove event where I was tracing the gp and lp gp was giving correct value and suprisingly lp was giving negetive values. when I move the move to the top left corner of uic i expect lp to be 0,0 but it is giving the -width of of uic. I broke my head for hours and ended up finding an alternate by using offsets. Infact my original code was much simpler like this which was same issue

var lp:Point = new Point(e.localX,e.localY);

I am not sure what exactly is causing this problem. the workaround had lot of issues and it creating a mess in my rest of the algorithms.Just now I found even more interesting thing (which is actually weird). for some reason I went and create a new lp2

var lp2:Point = new Point(e.localX,e.localY);

now surprisingly it was giving correct values as expected and I went back and changed the code as

var gp:Point = new Point(e.stageX,e.stageY); //global point
var lp:Point = uic.globalToLocal(gp); //local point
var lp2:Point = new Point(e.localX,e.localY);
var lp2:Point = uic.globalToLocal(gp);

now it is expected to have all the lp, lp2 and lp3 variables to be same but weiredly lp two is giving wrong value and lp2 and lp3 were giving correct. I am suspecting using the variable lp has something to do. I am not sure about that but above proves it so right now I am using lp2.

View 1 Replies

ActionScript 2.0 :: Converts 3d Coordinates To 2d Coordinates - Difference Between MoveTo And LineTo?

May 21, 2007

I was reading the 'Isometric Transformations' tutorial by Danko Kozar and I have a few questions. I understand what all the code does, but not how it does it. First of all, how does the following code work:

transforms x,y,z coordinates into Flash x coordinate
xFla = function (x, y, z) {
// cartesian coordinates[code].....

I understand that it converts 3d coordinates to 2d coordinates, but I don't understand how. What numbers whould be punched into x, y, and z to acquire certain desired effects?Also, what's the difference between moveTo and lineTo:

red line
style(1, "0xFF0000", 100);
plot(0, 0, 0);
draw(200, 0, 0);

View 4 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

ActionScript 3.0 :: Converting Papervision Coordinates Into Cartesian 2D Coordinates?

May 3, 2010

Im making a little app in flash using papervision I want to make a regular movieClip show up in the same place as a papervision object. The coordinates seem like perspective is affecting the number displayed.

View 2 Replies

ActionScript 2.0 :: Building A Dynamic Content Page In Flash That Consists Of Using AttachMovieClip And CreateEmptyMovieClip With Coordinates To Place Photos And Objects

Oct 15, 2006

I'm building a dynamic content page in flash that consists of using attachMovieClip and createEmptyMovieClip with coordinates to place photos and objects, which are loaded from an external source and scrolling their thumbnails I've run into a problem setting the variables correctly because the scrolling thumbnails required that the thumbnails be nested inside a scrolling controller clip and that has somehow messed up my preloading and sequential text caption loading for the tumbnails.

View 4 Replies

IDE :: Can't Get CopyPixels() To Work?

Sep 26, 2009

I did a function for blit scrolling successfully using Draw(), but then I heard that copyPixels is faster. Unfortunately, I'm not having the same success with that as I had with draw();

Specifically, no matter what I try to use for the source image, it keeps saying that it can't be coerced into a bitmapData object:

Code:

TypeError: Error #1034: Type Coercion failed: cannot convert SourceBitmap_bm$ to flash.display.BitmapData.

I tried referencing the bitmap in my Library (That's how I'd prefer to do it, copy from an item already sitting in my library) that has base class "flash.display.BitmapData", yet I get the error. I tried putting the bitmap into a movieclip and copying from that, same error. I tried copying from an offscreen instance of the mc (which worked fine with draw()), same error.

It's a mess by now because i've tried so many things, but this is my code:

[Code]...

I see are for copying pixels after loading in an external file. Does anyone know of an example that works with items already in library?

View 2 Replies

AS3 :: CopyPixels From A Huge BitmapData?

Sep 5, 2010

I need to load a very big image on AS3 (currently sized at 8192x8192). I am aware that it does not fit any of the limits imposed by Flash regarding drawing to screen or creating a BitmapData of that size. I just want to load the image so I can copyPixels() some parts of it here and there.The thing is, I'm loading the .jpg file of that size with no problems. The size is recognized correctly from my Loader object. I load it like this:[code]But I am greeted with the #2015 "Invalid BitmapData" error usually reserved for BitmapDatas that are too big. The error also happens if I try to do a copyPixels(), which is what I need to do.Is there any workaround I can use so I can get data from an image this big on AS3?

View 1 Replies

ActionScript 2.0 :: Using CopyPixels On A Isometric Map?

Aug 4, 2009

How would I go about using CopyPixels to build an isometric map? CopyPixels takes a specific rectangle and copies that onto a bitmap.. But how would one use that to build a seamless isometric map?Building a square top-down tiled map would be very simple as copypixels pastes each tile next to one another.. But for Isometric Maps, this would be different as some parts of the CopyPixels rectangle is over lapped into other tiles.. and this would 'erase' the bitmap of the other tiles currently on the bitmap..[URL]Fig2, is what happens when you try to do a copyPixel over an existing bitmap, assuming the white is transparent space.

View 0 Replies

ActionScript 3.0 :: CopyPixels Flip Or Rotate 90?

Nov 12, 2010

Traditionally, when blitting in old 2d games, flips and 90 degree rotations could be achieved with almost no performance hit. The reason for this is that the effect an be achieved by simply changing the order that pixels are copied.

I'm using copyPixels in Flash to get maximum performance. Is there any way to do a flip or 90 degree rotation using copyPixels? (Without pre-calculating and storing the flip/rotate). I couldn't find a way to do it, but it seems like it should be possible, because it is a very common technique in 2d games (well, not so much now that modern 2d games use 3d hardware acceleration... but Flash doesn't let us do that, so we need to use the traditional 2d techniques)

View 2 Replies

ActionScript 3.0 :: Memory Leak During CopyPixels?

Mar 1, 2012

I am making a custom renderer using the copyPixels function for my Haxe/Flash game. So I have this kind of code :

buffer.bitmapData.copyPixels(m_CurrentSkin, RECT3, POINT, null, null,true);

where :

-buffer is the bitmap where all my scene's objects are drawn

-m_CurrentSkinis the BitmapData that contains the current frame of the object to be drawn

Every time m_CurrentSkin contains a BitmapData that have never been drawn (the first time that an animation frame is drawn for example),I have a memory leak that is not garbage. However if m_CurrentSkin contains a BitmapData that have already been drawn (when the animation is played a second time for example), there isn't any memory leak.If I comment this line there is no leak so the problem comes from there.It seems that a copy of the BitmapData is cached in memory but I have checked in my code and there is no cacheAsBitmap explicitely set to true.

View 3 Replies

ActionScript 2.0 :: CopyPixels With Irregular Shape

Jan 19, 2009

Can anyone tell me if I can copyPixels with an irregular shape instead of just a rectangle?

View 0 Replies

ActionScript 2.0 :: Bitmap CopyPixels Not Copying?

Oct 1, 2009

I am playing around with an old Zelda: Link's Awakening tile set, and was trying to make an application that will display the current selected tile.

I am well versed in as2 but have never had need for the bitmap classes until now. I have found examples of the copyPixel() function that work but could not get it to work in my code.

I have attached the .fla file I saved it as a CS2 (Flash 8) file. (I use CS3 and/or CS4 depending on which computer that I am currently using. This one is in CS3)

ActionScript Code:
// -----
// ----- Author: Nathan Sepulveda
// ----- Date:   Oct 1, 2009

[Code]....

View 6 Replies

ActionScript 3.0 :: Rotating Bitmap Then Doing Copypixels?

May 8, 2011

I have a bitmap which has several frames (packed along the horizontal axis). In order to render them I copy it to the backbuffer as follows:

ActionScript Code:
public override function copyToBackBuffer(db:BitmapData):void
{

[code]........

View 0 Replies

ActionScript 3.0 :: CopyPixels On MovieClip With Children?

Jun 14, 2009

I'm working on my second flash game and have been stopped in my tracks trying to cache MovieClip Animations into arrays of BitmapData frames. To capture the frames I have set up a loop which runs through the frames in the MovieClip and use copyPixels to get a snapshot of the graphic.This works fine if the MovieClip to cache does not contain any child MovieClips, but if it does, these MovieClips are frozen on their first frames. I've been looking at MovieClip.getChildAt(index) in attempt to navigate their time lines but because that returns a DisplayObject it seems impossible.

So, my question is: Is it possible it to use copyPixes on a MovieClip and also step through child time lines, or should I be using sprite sheets?

View 2 Replies

ActionScript 3.0 :: Flash CopyPixels For MovieClip?

Aug 4, 2011

I'm not much of a scripter. I get by editing scripts similar to my needs. I learned a few things about blitting and I'm trying to get a rectangle area of a MovieClip to blit to a location on the stage. But I run into the error "Invalid BitmapData" which makes sense because I'm referencing a MovieClip and not an image. Is there a different AS3 command other then copyPixels that would work for a MC?

I know VCam would seem an obvious solution, however VCam scales to fill the entire stage. I only want to fill a small rectangle on the stage. I've already attempted to edit VCam with no success. Its probably not the same principle, but would it be possible to blit the matrix VCam uses?

View 2 Replies







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