ActionScript 2.0 :: Only First Drawn Rectangle Is Dragged All The Time
Jun 15, 2006
The code below is used to create one rectangle at a time when a button pressed. But they are randomly placed on the screen. I was trying to drag each and place each rectangle in a desired location on screen. But when I drag a rectangle (startDrag) with MouseDown ONLY THE FIRST CREATED RECTANGLE IS MOVED AND NOT OTHER RECTANGLES.
var i = 0
function newRectangle(x1,y1){
var r:MovieClip = this.createEmptyMovieClip("rectangles"+i, (i+2));
[Code].....
View 1 Replies
Similar Posts:
Aug 13, 2010
public class Greeter extends MovieClip
{
public function Greeter()
[code].....
View 3 Replies
May 18, 2010
I wrote the following code for drawing a rotate rectangle
var s:UIComponent = new UIComponent();
s.graphics.lineStyle(1, 0x0000FF);
s.graphics.drawRect(50, 50, 200, 200);
s.rotation = 30;
template.addChild(s);
Where template is a canvas. Its rotate nicely but the problem is the position is not in right place. i.e. it is not in (50,50) after rotate.
View 1 Replies
May 14, 2005
I had to create dynamic with AS some rectangular on stage using moveTO and lineTo. I had a button and when I press it should add a new rectangle on stage but it doesn't. Because the array that I am storing the MovieClip created are overriding I guess
var i:Number =0;
button_name.onRelease = function() {
i++;
var instancename:String ="new_mc"+i;
var mcClip:MovieClip=createEmptyMovieClipinstancename,this.getNextHighestDepth);
[Code] .....
View 1 Replies
Jun 17, 2010
I've got a movieclip of a rectangle in my library which I place on stage to attachMovie. Then I create an empty movieclip which I want to use as a mask on that rectangle clip through setMask. Users kan draw into that empty movieclip. My intention is that only those areas of the rectangle clip become visible where the user is drawing a line. So I used this:
Actionscript Code:
_root.attachMovie("clip", "clip", 0);
_root.createEmptyMovieClip("line", 1);
clip.setMask(line);_root.onMouseDown = function() {
line.moveTo(_xmouse, _ymouse);
line.lineStyle(10, 0x00FF00, 100);
this.onMouseMove = function() {
line.lineTo(_xmouse, _ymouse);
updateAfterEvent();};};
_root.onMouseUp = function() {
this.onMouseMove = null;};
But that doesn't work: both the line drawn and the rectangle clip become invisible. I know it works because without the setMask part the line is drawn. The other way around does work (line.setMask(clip)): the rectangle clip is now masking the drawn line so only the line becomes visible within the rectangle region. But I want it the other way around: the rectangle should become visible through the lines that are drawn!
View 3 Replies
Jun 7, 2004
i dragged an mp3 onto the time line and i want to be able to make it stop with the click of a button,
Code:
on (release) {
Sound.stop(["stap-1.mp3"]);
}
View 3 Replies
Jan 21, 2010
I'm using AS3. I have a timeline with 12 labeled frames (page 1...page12). On frames 1 to 10, I have 3 objects that users can drag and drop onto matching places. There is a timer (60 seconds) and a counter. Users should match 15 objects correctly. If so, they go to frame 12 (congratulations!). If not, they go to frame 11 (Sorry, try again), which returns them to frame 1 (page 1).
ISSUE When users drag an object (mouseDown) and don't release it when time is over, the dragged object remains on the screen. When users go to frame 11 and game starts over, the object remains throughout the entire game.
How can I get rid of the dragged object that isn't dropped when the time is over?
ActionScript Code:
//
// TIMER
var time1:int=60;
var myTimer1:Timer = new Timer(1000, time1);
[code]....
View 1 Replies
Feb 13, 2009
Is it possible to access the graphics.* - characteristics of objects that I have drawn at authoring-time at runtime? If I have drawn a single line in a movieclip I'd like to do sth like this:
[Code]...
View 2 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
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
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
May 10, 2009
I need help with MC's animation causing a weird conflict. I have a movie clip come out and appear to drag another to the side of the stage. I get a weird wobble and dither from the mc that is dragged in horizontal motion. I have included a simple example, the original has complex motion on the "arms: so I used a simple box to demonstrate problem. I am at a loss as to what is causing this. This is a flash cs4 file.
View 2 Replies
Nov 14, 2009
I have 2 mc's which can be dragged. When one is dragged I want the other to mirror the position of the dragged one.
say they are mcA and mcB
if mcA is dragged,
mcB's x should = mcA's x and
mcB'sY should = mcA's Y * -1
same for when B is being dragged but reverse obviously
I want this to execute continuously while one of the mc's is being dragged. I tried using while with a boolean, maybe you can't? here is what I tried to simply get one to work, just B to follow A when A is dragged.
PHP Code:
var dragging:Boolean = false;
main_mc.mcA.addEventListener(MouseEvent.MOUSE_DOWN, startDraggingAB);
main_mc.mcB.addEventListener(MouseEvent.MOUSE_DOWN, startDraggingAB);
[Code].....
View 2 Replies
Nov 28, 2009
I have set up some objects so that they can be dragged and dropped into an area(suitcase). This works fine but the thing is that when I move to another part of the timeline the object is put back in the same position it was in before being dropped in the suitcase. I need to be pointed in the right direction with this:
a) If an item is dropped into the suitcase then a message is displayed saying for example "you packed the socks"( I think I can handle this).
b) The object should stay in the case and be displayed there until the interaction moves on(I need this to happen).
c) The user must pack all objects before moving, so I need a way of recognising all objects are packed so that the user can move on..(I need this to happen).
View 3 Replies
Apr 21, 2010
Can i create a custom text animation or something. Ofcourse without involving variables. And can i use this Movie clip in various projects. What am i supposed to do, save it and keep it as a .fla or can the movie clip alone be saved and imported into various projects ?
View 5 Replies
Jul 2, 2009
I'm just wondering if it's possible to have a page of text that is 'invisible' (for want of a better word) and when you move your mouse over the page, the text appears in a circle (of whatever radius) around the mouse point.The text would be clearest and darkest at the mouse point, and fade out towards the outer circle, and 'appear' smoothly as the mouse is dragged around the white page.
View 3 Replies
Jun 4, 2010
how to determine if there's a dragged object. Is there a way to do this?
I know if you start another drag on the other object it will stop the current dragged object. Maybe there's a public function that will query about this?
View 5 Replies
Mar 7, 2010
I am using PopupManager in FB4 to display a custom dialog.
popwin = new TitleWindow();
popwin.addElement(myCustomDialog);
PopUpManager.addPopUp(popwin,this,false);
PopUpManager.centerPopUp(popwin);
It's possible to drag the popped up TitleWindow and let go of it when its gray title bar lies outside the bounds of the Flex app rectangle,and then the popup cannot be grabbed again.It's also possible to drag the TitleWindow downwards so it becomes completely invisible below the bottom edge of the Flex app rectangle.When the Flex app bounds are less than the full browser window,and the user is working quickly, this chances of this happening increase.Is there a simple setting that will keep this from happening, or must the programmer intercept the behavior during the drag operation?
View 2 Replies
Apr 19, 2010
how to make a draggable map but the map can only be dragged in an area. let say if i did a rectangle as the limit,so the map can only be dragged within the rectangle... outside of the rectangle cant be dragged and cant be seen...
View 9 Replies
Jun 22, 2011
I have attached a flash file with an audio slider component within it. how to get rid of the hand on rollover and when being dragged.
View 7 Replies
Jan 29, 2012
So I am using actionscript 3.0, not FLEX so I had to make my own drag and drop code. The only thing I now need is a way to create a copy of the datagrid row that follows the mouse when dragging. How would I make a 'semi-transparent image' of the row to drag along with the mouse when I drag? It would seem like there would be some way to render a row as an image, but as of now its unknown to me. I would use a MOUSE_MOVE event in combination with knowing that the drag is initiated, but how to I generate the image itself that will be dragged?
View 0 Replies
Feb 20, 2012
I have 26 letters(english alphabet) into a linkage movieclip(var let:Letter = new Letter() ) and I put a drag and drop function into the mc. My goal is to drag the movieclip leaving the original on its position. The reason why I want to duplicate is that when I spell a word with single vowels on it ex. "word" with single "o" that would have no problem. But when I spell a word ex. "banana" with 3 "a"`s there is where my problem is.
View 1 Replies
Jul 7, 2009
I have a simple game that allows the player to drag counters around a board (just a background image).There are 23 counters created in the main .as class by calling another class, called "Units.as". The counters are added into an array in the main class like this:counterarray[0] = new Units("1",2);(where "1" and 2 define the label and colour of the counter)I do this for all 23 counters.[code]The class Units.as defines the counters as rectangles and places mouse listeners so they can be dragged around.My problem: I want to save the information about the counters to a shared object, but if you move a counter around, the counterarray[0].x and .y remain stubbornly where I originally set them - as 100 and 50.
I tried passing the x and y co-ordinates to Units (e.g. counterarray[0] = new Units("1",2,100,50); ) but while this works for placing the units, the value of counterarray[0].x is now zero and doesn't change when the counter is dragged around.I've only been using AS3 for a couple of weeks so suspect I am missing something obvious, but I've spent the last couple of days searching the internet & can't find it.
View 5 Replies
Mar 11, 2009
i already made a working tooltip.now i want the tooltip to be dragged by the mousepointer movements....but the tooltip should always keep the same y-axis position....something like maybe:
Code:
startDrag("_root.tooltip", true);
y_mouse = 20;
View 1 Replies
Aug 20, 2009
what I have are pieces of a truck and the user needs to be able to drag and drop the pieces to the correct locations. I can get the pieces to drag, but I need help locking them into place once they get within a certain area. So for example if they drag and drop the wheels of the truck towards the back, but not in the exact location, then the movieclip will move and lock into place and then the movieclip becomes disabled.
var dragMC = finalMC.graphicMC;
///////////////////////////////////////
onMouseMove = function () {
updateAfterEvent();
[code]....
View 1 Replies
Nov 17, 2010
I have an masked image that is externally loaded onto my stage that the user can drag and position.I then need to be able to record or save where and how the user has positioned the image by either -taking a bitmap copy of where the user has positioned the image (my first and easiest thought of how to do this) -or is it possible to get X and Y co ordinates of where they have positioned it I have a movie currently set up but when the user clicks 'save and continue' it takes a copy of the original position of the image - not from where you have last dragged it to?Full code and attached fla file below
Code:
stop();
//--------------
// Loader
//--------------
var imageP1:Loader = new Loader();
[code]....
View 1 Replies
Jul 21, 2011
I'm doing a little drag and drop work and I'm wondering if it's possible to change the size of an object when it is dragged over another object on the stage..
For example I would like to drag a square movieclip around, but when it is dragged over a certain object it either play the movieclip and 'morph' into a rectangle or simply become rectangular (using a frame label or something) !
Is it possible to do this sort of thing with hitTestObject or hitTestPoint or dropTarget without contiuously checking if the objects are in contact ?
View 3 Replies
Oct 16, 2009
I think there is a simple solution to this question, just not simple enough for me to find it.Question:How do you constrain a TitleWindow in Flex 3 from being dragged off the screen/stage? Is there a way to restrict the TitleWindow to the viewing area? Example: Let's say I have an application that take 100% of the screen. Next, I create a TitleWindow via the PopUpManager. I can then proceed to click and hold (drag) that window off the screen, then release the mouse button. That window is now lost off-screen somewhere. Is there a way to keep the window from being dragged beyond the viewing area?
View 6 Replies