ActionScript 3.0 :: Drag And Resize Rectangle MovieClip
Jun 14, 2011
I would like to add the ability to resize a rectangle movieclip, plus have the ability to drag it horizontally. I have the horizontal drag code working, but I am not sure how to add the ability to grab the ends and resize it.. There are a lot of these bars on screen, so I am adding listeners in a loop:
this["box" + i].addEventListener(MouseEvent.MOUSE_UP, dropIt);
I imagine I need to add 2 movieclips to each rectangle to allow for resize handles, but I'm not sure how to refer to them or initalize them...Here is a pic of what I am looking to accomplish.
View 10 Replies
Similar Posts:
Jun 11, 2007
I need to make a form that allows the user to upload an image from their own computer, then dump that loaded image into a movie clip, and allow them to move it about on stage, and possibly scale it. I have the upload function working, it allows me to select a file, and i have the server side php to dump the images on the server, but im not sure how to go about dumping the image in the movie clip after the usser has selected and uploaded it. Ive found stuff around the net that dumps the file into a scroll pane, but im not really sure how to modify the code to work with a movie clip. I think dragging and resizing will be cake after that, because theyre functions ive used before. But i just cant seem to get past this upload hurdle.
View 4 Replies
Jan 20, 2010
I'm pretty new to Flash and seem to be struggling with variable scope, events and where to put code within movieclips/main area etc. What I'm trying to do is produce a Flash movie that will allow the user to click on a tool from a selection, i.e. a circle, then click on another part of the screen to place the centre of the circle, with a second click to set the radius of the circle (an alternative would be a single click and drag to place the circle and drag it out to the desired radius.) Once the mouse if clicked a 2nd time, or the drag operation is completed, the circle will stay at the selected radius.
The code I'm using so far to test out the idea is below:
_root.onEnterFrame=function(){
_root["item1"].onMouseMove=function(){
d = Math.sqrt(Math.abs(_xmouse-this._x)*Math.abs(_xmouse-this._x)+Math.abs(_ymouse-this._y)*Math.abs(_ymouse-this._y));
if(d<370){
this._width = d*2;
this._height = d*2;
}else{
this._width = 87;
this._height = 87;
}}}
This uses a simple circle movieclip, and the above code is placed in Frame 1 of the background as opposed to the movieclip itself. It resizes the circle movieclip ok, but I want to be able to control the resize with the mouse or with a single click/drag.
View 10 Replies
Mar 8, 2004
How can i dynamically resize a graphic like a rectangle.
View 8 Replies
Mar 28, 2010
I have a rectangle (90 degrees). I can drag the cateters, limitid by a rectangle. But I have tried to limit the dragging of the hypotenusa in a rectangle too, but can�t figure it out. Where I have the ?? I want to put values so that the hypotenusa can be dragged peripendicular like the kateters. Later I shal draw and fill the area beeing dragged.
[Code]...
View 5 Replies
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
Jul 27, 2008
I Created an action script code when the mouse Down and Drag I taks the X,Y postion in the first and when the mouse is Up it take the Final X, Final Y and Draw Rectangle
I need to Show the User the Rectangle with the mouse Motion (like when you draw in photoshop ) But in my Code the the Rectangle appears when the mouse up
I attached The Code to the msg
View 3 Replies
May 7, 2010
how to limit the region an object can be dragged in if the region is an irregular shape. I've tried with the 'set bounds' command and tried making a shape out of rectangles - but no joy.
View 2 Replies
Mar 10, 2011
Im running a movie clip from an AS class, and simply testing it using the addChild method in the FLA but all my code is in the external AS file. Inside this movieclip i have a my own custom Slider Component. I am using the drag and drop method and i want to constrain the image i am moving to a rectangle. I have drawn the rectangle (called rect) and i am using that MC to get the size and position propities. and my slider is called (slider_mc) anyway here is my code. I am getting the
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at com.spay.ticketpurchaser::TicketPurchaser()
at TicketPurchaser_fla::MainTimeline/frame1()
[code]......
View 1 Replies
Dec 2, 2010
in the following SWF example: [URL] you can see small iphone application created with flash cs5, this application has blue rectangle, you can drag and drop this rectangle with your mouse cursor.. ok no problem in the code, but i want ask a question: when i run this application in iphone device, my finger will drag and drop the rectangle instead of mouse cursor ? or I need change the code? here is the code i used:
[Code]...
View 1 Replies
Apr 27, 2011
I have a function that states when movieclip1 is dragged and hits a line then it stops the drag, however it seems to stop the entire drag function in the swf on the other movieclips even though they arent called in the function.[code]
View 1 Replies
Feb 27, 2006
I'm dragging a symbol that has been reduced in size, I'm dropping that symbol and I then want the symbol to resize itself, basically return to it's 100% h+w.
The dragging and dropping is no probs and I'm sure the resize would be setting some sort of symbol property value or something
View 21 Replies
Oct 24, 2006
how to resize an item (a vector square or such) on drag? In other words, I want to click a side and drag that side having it resize. Sort of like WACK [URL]
View 1 Replies
Jun 25, 2010
'i am doing a game for children where users can drag and drop resize and scale movie clips on stage!The drag and drop is not an issue...
View 2 Replies
Aug 5, 2011
I am using start drag to control an mc of a map which all works fine, this MC can be zoomed using a slider which also works fine. I have defined a bounding box in the usual way.
map_mc.startDrag (false, new Rectangle(0,0,500,500));
But when map_mc is zoomed in its size go beyond the bounding box's limit and obviously reacts unpredictably. I would like to put the rectangle size in a var which I can then scale with the map so that the mc is never bigger than the bounding box.
Code:
Select allvar rectangle;
number = (0,0,1000,1000)
View 1 Replies
Apr 20, 2009
I can create a MovieClip using the follwing process:
1. Select rectangle tool from ToolsWindow and draw a rectangle by dragging through mouse.
2. Then press F8 by selecting the drawn rectangle, select radio-button with "MovieClip" and click "OK".
3. Now give the instance-name to this newly created Movieclip(say,myMovie). Now, we are able to use this MovieClip.
But, I don't like to use this process and I like to use ActionScript 3.0 code as a sole to create a custom-sized MovieClip(here, size depends on MovieClip's "width & height" properties) upon which I need to place as many no. of text-fields( say, "n")& "n" value is known dynamically upon requirement. Hence the MovieClip size must be increased/decreased as per our requirement depending on "n"(i.e., no. of TextFields.
And my code writte in "Actions" panefor changing the MovieClip's size dynamically upon requirement looks like this:
HTML Code:
myBtn.addEventListener(MouseEvent.CLICK,onSubmit);
function onSubmit(evnt:MouseEvent):void
{
[Code].....
View 5 Replies
May 23, 2009
My need is:
1.) I need ActionScript 3.0 code to create a Rectangle shape which must be a MovieClip. So, I need to pass/access MouseEvent_CLICK events on this MovieClip.
2.) Now, this newly created MovieClip(or rectangle) should not be created with same/static size always. Instead, it's size is dependable on some value(say,var index:int).
In this case, I think it is better and good programming practice to write the code for dynamic-sized MovieClip in a user-defined method(say, createDynaMovieClip()).
I need the full requirement in ActionScript 3.0 code format only.
I got struck up with this problem and the sample code which I developed till now is as shown below(which creates the required rectangle):
Code:
import flash.display.MovieClip;
var rectangle:Shape = new Shape();
rectangle.graphics.beginFill(0xF3FAB8);
[Code]....
View 1 Replies
Jun 23, 2010
I was wondering if anyone could enlighten me as to how I could generate a rectangle movieclip on top of the longest section of a frame of a movieclip using AS3?
If this is the movieclip frame, I want it to find the longest portion of the movieclip on the right.
And then generate a rectangular movieclip on the longest section of the frame on the right side.
(Don't mind the white bg, I just used paint quick, it won't be there)
I can figure out how to generate the rectangle and all of that, but I am confused as to how I could determine the length of the longest portion of the movieclip, and how to tell AS3 to place it there.
View 9 Replies
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
Aug 11, 2009
I'm creating a quiz that has the user press a submit button.Everything was working perfectly until i tried to make the button look better by going in the clip and converting the rectangle to a movieclip.now the button looks great but says its calling a null reference.if i go in an break apart the mc on the first frame (up) then it works.why is it doing this? is putting a mc in a btn bad? is there a way around this.I really like the way by buttons look but dont know how to get the same effects without it being a movieclip.
View 2 Replies
Oct 25, 2010
I am trying to create a basic example. Using frames i know how to do that but i want to know how this can be done using as3. Using frame: A movieclip in which there are 6 frames: Red rectangle in first 3 frames Blue rectangle in last 3 frames
View 4 Replies
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
Nov 15, 2004
know how I can resize the stage to match the size of an external graphic/movieclip which is loaded into an empty movieclip,
View 3 Replies
Apr 20, 2009
I can create a MovieClip using the follwiFirst, select rectangle tool from ToolsWindow and draw a rectangle by dragging through mouse.Then press F8 by selecting the drawn rectangle, select radio-button with "MovieClip" and click "OK". Now give the instance-name to this newly created Movieclip(say,myMovie). Now, we are able to use this MovieClip.But, I need to create a custom-sized MovieClip upon which I place text-fields(not known i.e., it is dynamically known(say, "x" no. of text-fields are required)). Hence the MovieClip size must be increased/decreased as per our requirement
View 15 Replies
Jun 2, 2011
I would like to take a straight line/rectangle that is already created on stage and tween it with as3 so that when mouse is down, i can drag and bend it into an ark shape, and when i release the shape snaps back to its originally form?
View 2 Replies
Nov 16, 2010
Is it possible to resize a movieclip without stretching the contents of the movieclip??? I'm having the most frustrating time trying to do this.
View 5 Replies
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
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
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
Mar 26, 2010
I Have the drag and drop working where you drag a text movieclip onto a picture of an object movieclip but having some problems. I know its something to do with the hitTest function but when i drop the word "cow" onto the picture of a dog it actually says this is correct by displaying the word cow above the picture of the dog when instead it shouldnt allow me to drop the text onto the picture which doesnt match.
Basically i need to know how to seperate the drag hitTest function for the DogPic/DogText so that it has its own function to detect a hit. At the moment you can see in the below code I have 1 hittest fucntion detecting both collisions when they need seperate functions I tried making a seperate function for each but it didnt work
[Code]...
View 4 Replies