ActionScript 3.0 :: StartDrag() Not Working For Child?
Jan 20, 2011
I have a movie clip that I want to drag, but it gives odd behavior. If I add the MC using:addchild(MC)it works fine. The problem occurs when I try to add it as a child of another MC:base.addchild(MC)When I do it like this the drag does not work (nothing happens). If I drag the parent, the child drags with it, but attempting to drag the child on its own does not work. The function used is:
function pickUp(event:MouseEvent):void {
if (drawMode == NONE) {
event.target.startDrag();
as you can see, I have a container MC which I have added to the stage. I set its drag constraints using a Rectangle(). I then add the 'cat' child movieclip to the container, and I want this to be dragable too. However, as soon as I click on my cat when testing the MC. It shoots to point x=0 y=0 on the stage and doesn't move.
The container MC can be moved without any trouble.
If I remove the rectangle bounds from the containers startdrag() function. both MC's can be dragged without any issue.
I have a MovieClip instance which can be moved around the stage using startDrag() and stopDrag(). The instance also has some child MovieClips using addChild(). The parent moves the children when dragging, which is fine. The children have there own startDrag() and stopDrag() which should apply only to the child object, however it also moves the parent and other children. When clicking a child the MouseEvent of the child is being called but so is the parent.
public class Component extends MovieClip { private var nodes_array:Array = new Array(); public function Component() { x = 60;
"Three-dimensional display objects follow the mouse and Sprite.startDrag() moves the object within the three-dimensional plane defined by the display object. Or, if the display object is a two-dimensional object and the child of a three-dimensional object, the two-dimensional object moves within the three dimensional plane defined by the three-dimensional parent object."
However, this does not seem to be the case. I have a 2D object which is the child of a 3D object, but startDrag will not work on the child. If I remove any tweens in code from the parent's rotationY then startDrag will work. If I have any reference to rotationY it will not work, even if it is set to 0.
I have a MovieClip with other MovieClips inside of it. On each of the MovieClips inside, I have added a MOUSE_DOWN event and in the handler, I call e.target.startDrag(false, null);
But it doesnt seem to work :/
I have traced out the target name. I have tried current target and traced out it's name. THey both trace correctly. The target is being reached and it is the corect target. But the startDrag function doesnt make the MovieClip draggable.
I'm trying to work with a movie clip that I am loading into my main SWF. When run alone the draggable rail works fine but once loaded into the actual main SWF it won't drag. I put an on EnterFrame on it so that when I click it reads out some data and that still works within the main swf. Is there some sort of restriction on what loaded content can do?
I created a full flash template website loading external swf's.Lately, I managed to add a fake3D rotation with AS3 and CS4 to this global template with enterFrame.Problem : some of my external swf use a vertical scroller also using an enterframe function based on a startDrag bar with the x / y position of the mouse, the scroller dont work anymore.
all of the other buttons on an external movie are workign but the volume slider is not...
when i load the external file (the mp3 player) it works fine.
Code: /* volumeStartDragging(event:MouseEvent):void * Returns a mathematical value that we can use to adjust the volume * the value is the relation of the volume ball to the line
i have an .as class that extends mx.containers.Canvas (it's a draggable border of a resizable component), it becomes draggable on MOUSE_DOWN and stops being draggable on MOUSE_UP, MOUSE_OUT and ROLL_OUT. before calling startDrag() i create a Rectangle to define the drag area, i also have a _dragging: Boolean variable to control if it's draggable at the moment. the problem is that when i click this border it jumps to a negative coordinate without calling startDrag or switching _dragging to true.
i've overriden get x, set x, get y, set y and move() methods in order to solve it but the only thing i got was the fact that position changes without calling coords setters or move(), but at the moment it's changed a getter is called and returns new (negative) value so my question is what happens on startDrag() and how to filter unwanted incoming coords values?
I have 3 movieClips call A,B and C, and added to stage one after another, in a nested manner. where a is parent of b and c, b is parent of c and child of a.However I get an error after trying to add child to movieclip c into b?[code]
I am using equivalent of onReleaseOutside which is: this.stage.addEventListener (MouseEvent.MOUSE_UP, mouseUpHandler);
It works fine. but when I open this SWF in another SWF it doesn't work.. !!
when I press mouse on sq_mc and release outside, counter stops.
but I want to stop the counter when I press mouse on sq_mc and release outside where my SWF which contains sq_mc is in another SWF in browser.
in simple ways... if path of SWF is "browser >> SWF" it works.
but if path is "browser >> SWF1 >> SWF2 >> SWF3" it wont works. in this SWF1 is preloader, SWF2 is SWF loaded in preloader, SWF3 is SWF which contains sq_mc)
Code below:
Code: var excelClickTimer:Timer; var i:int; this.stage.addEventListener (MouseEvent.MOUSE_UP, mouseUpHandler); //counter
have made interactive quiz which have 12 movieclips each movieclip contains loop animation and sound in it(on Timeline), i export them as classes, clip1, clip2, clip3....etc, now i m doing when user reach on question 1, then clip1. comes on screen and playes that movieclip and after clickicking on right answer clip needs to remove from stage, but it is happening that clip is gone unvisible but is sound is till working
var hint:clip1=new clip1() addChild(hint) when user choose right answer
Ive got this piece of script where i place objects on the stage, to hittest eachother.Ive got two seperate addchilds: one child must hittest another child.[code]only one instance of the hitte_mc will hittest with the instances of Ring.
I'm trying to do now is to make the application auto click on the first thumbnail,[code]I've been trying to google it and found that maybe I'll have to add an event listener to know when the thumbnail is actually being added to the stage, and just then click on it.I just found out that the code that Ascension Systems provided worked, but it didn't work at first because of a different error I had,the thing is, I'm working with the youtube API, FLVPlayback and such,And Each one of them is in a different movieclip,In the youtube movieclip I added this function:[code]I am setting the player as an object in the beginning of the script like so:var player:Object;
I have a main MovieClip that creates a new instance of an imported class which is a page in the application. This class tries to call a function on the main MovieClip and it's not finding it. I've done this in the past without any problems with separate swf files and loaders, and with movieclips in a library. I'm at a loss on how to resolve this. Here's what I'm doing (simplified for posting):
I've found the solutions for most of my many problems with as 3 but this one is really baffling The frame actions of child-movieclips of dynamically added movieclips are not firing! If I have movieclip, say "mc", which contains a child-movieclip "submc" which has a timeline animation in it with "stop();" on the last frame and I add "mc" on the stage via addChild() the stop action inside the sub movieclip will not work.
All the frame actions inside "mc" itself work. Everything works if I drag the movieclip onto the stage manually. Right now the only way I can see to stop a movieclip on its last frame is by using the ENTER_FRAME event, but that's awfully cumbersome.
I have a picture on the stage that has multiple items that have hotspots/links over them that should open a child swf on top of the background and show details about the items. then have a button in the child swf itself that removes the child from over the background so the user can click on another item etc.I found this code in someone's post and I am trying to modify it so that works for multiple swf files...it currently works for a single swf.I wan to pass the name of the button in front of the .swf in the URLRequest to have the same name as the instance name of the referring button. But I can't figure it out. Here is the code I am using on the stage
is there a way to drag multiple movieClips at the same time? Flash help explicitly says: Only one movie clip can be dragged at a time. After a startDrag() operation is executed, the movie clip remains draggable until it is explicitly stopped by stopDrag() or until a startDrag() action for another movie clip is called. anyone know of a way to do it anyway? maybe combining them in a dynamic mc or something?
I have a zoom in function and when I'm zoomed in I can drag the movie clip around with a drag function I have a zoom out function which restores the movie clip to its original size but I would like the drag function to be disabled while zoomed out.[code]...
I've created a function called dragItem() that I call with the MOUSE_DOWN event. I've got it working....kind of. I can access the function when the mouse is clicked and I can even get the name of the instance when the mouse is down. I'm trying to use the same logic to get the single object to allow a drag. see my code below...
function dragItem(event:MouseEvent):void { var instName:String = event.target.name; trace(instName); trace(event.target.width); event.target.startDrag(); event.target.removeEventListener(MouseEvent.MOUSE_DOWN,dropItem); event.target.addEventListener(MouseEvent.MOUSE_UP,dropItem); }
I get this error when I try to drag the item...ReferenceError: Error #1069: Property startDrag not found on flash.display.Loader and there is no default value. at Main/::dragItem()
I have an index file in which I load my external .swf. One of the external .swf has a drag and drop quiz. And as you can guess, the startDrag doesn't work! In fact, when I publish within Flash it works just fine, but when played within the index file, it stops working!
For your information : all my files are in AS3.
So here's a bit of my code.
var interbouton : Number = 10; //I have 7 items that I can dragfor(var i:Number=0; i<7;i++){ var dragBtn :MovieClip = new Drag();
I have noticed when setting a bounding box on a drag object, if you go outside the bounds of the box you have set, the mouse won't let go of the object unless you go back inside the bounds and click on it again. Is there any way to force the stopDrag if you go outside the bounds while dragging? I have tried this bit of code:
I'm making a strategy game the uses a tile map to show information about the other players! Every tile is 50*50px and when you start the map it loads about 50 tiles and puts them together (all this from a Flash->ASP->MySQL which i managed to do on my own)
What i need to do is to make the map draggable (kinda like maps.google.com) and make every tile clickable! I can't manage to do both of these things at the same time All the tiles are in a movieclip called mapMc so by creating a big button above the visible map area and write:
ActionScript Code: on (press) { allSize = _global.fullMapSize/2; //This gets the size of the map after all tiles have loaded[code].....
And that kinda works (except for the boundaries)Second, when you press a tile, which i stupidly constructed as another button, so every tile is a button (loaded dynamically) with as that fetches the tile information (already fixed ) But how do I combine them?
Ok it's 5am so I'm just not thinking clearly and am straining to read my code and I cannot get this to work.
I have a zoom in function and when I'm zoomed in I can drag the movie clip around with a drag function I have a zoom out function which restores the movie clip to its original size but I would like the drag function to be disabled while zoomed out.
i created quiz. Questions of quiz, two question are fill inthe blank and others are multiple questions. i want to add matches question using startdrag-stopDrag. it runs in seperated fla. But it doesnt runk when i add to quiz.fla, actually mybadscrore doesnt work. However , how i can do to run only once square1.mc?
Code:
square1_mc.addEventListener(MouseEvent.MOUSE_DOWN, drag); stage.addEventListener(MouseEvent.MOUSE_UP, drop); function drag(e:MouseEvent):void
How to make a infinit startDrag So something like :Code: Select allstartDrag(this, false, 0, 0, infinit, infinit); Only this code acts like this:Code: Select allstartDrag(this, false, 0, 0, 0, 0); And also I'd like this startDrag to work with negativ cordinates.
trying to made a jigsaw puzzle, and using dynamic function to cut picture to pieces, but the pieces are not drag properly, except top-left coner one.how to make a good jigsaw, please share with me, it's my first game program in my life,