-
Dragging 2 things at once
Hey Guys,
I have a annoying problem today,
I have mad a custom cursor (like the pdf one) to appear when i click on something to drag it, problem is I can only do one startDrag function at a time. I have tried making another function that starts when it is pressed and still wont work.
I am sure people have done this a million times.
Any help?
-
Senior Member
I don't understand your question. You can only drag when you place the cursor over an object. Another object would not be dragged, which means only one at a time.
- The right of the People to create Flash movies shall not be infringed. -
-
I have a cursor image (this is one thing I am dragging) and a image underneath it (that i am dragging at the same time) I want the cursor to change while I am dragging the image but to do that I need to make the cursor an image to be dragged aswell. understand? I hide the mouse and make one draggable object the replacement for that and the other one is the one underneath the cursor that is being moved.
-
Senior Member
The only thing you can do is this, but when the mouse moves the image from the onPress status will disappear.
PHP Code:
Mouse.hide ();
cursor_mc.onMouseMove = function ()
{
cursor_mc2._visible = false;
this._visible = true;
this._x = _xmouse;
this._y = _ymouse;
updateAfterEvent ();
};
cursor_mc2.onMouseDown = function ()
{
this._visible = true;
cursor_mc._visible = false;
this._x = _xmouse;
this._y = _ymouse;
updateAfterEvent ();
};
- The right of the People to create Flash movies shall not be infringed. -
-
Ok let me do it this way.
Imagine your playing a game, ok?
now when you click on something you want to be able to drag it around with the cursor.
So in this example I am saying you have a hand that you want to glows yellow when you go over a magic sword, so you click to pick it up in your hand and wave it around while your hand is still yellow and cursor is down. so the code is;
Code:
magic_sword.onRollOver = function ()
{
startDrag(hand_cursor);
hand_cursor._x = _xmouse;
hand_cursor._y = _ymouse;
Mouse.hide ();
};
magic_sword.onPress = function() {
startDrag(this);
};
magic_sword.onRelease = function() {
stopDrag();
}; ()
Now as you probably know you can do this a number of ways but every way I do it I can only drag one thing around with the mouse position, where i want both moving around until I release the mouse and i drop the item.
Dont panic I am not making a game with swords and stuff I am actaully making a navigation system.
and before you say it, Yes, I have put the
Code:
startDrag(hand_cursor);
into the on press functions but as you will see it stops it working.
I really thought this would be so simple but cant find anything anywhere.
Thanks for your help so far cancer.
By the way is that your real pic? Damn?!
- Budgi
-
This worked for me and i hope it is what you meant. Basically is uses onEnterFrame to continually place the custom cursor at the position of the mouse. but its hidden. Until, that is, you rollover your item. then it makes the cursor visible and you can click and drag that item to your hearts content. until you roll out...which can't happen until you let go of your mouse.
I hope that makes sense and i hope it works like you wanted.
Code:
customCursor._visible = false;
customCursor.onEnterFrame = function() {
customCursor._x = _xmouse;
customCursor._y = _ymouse;
};
magicsword.onRollOver = function() {
startDrag(customCursor);
customCursor._x = _xmouse;
customCursor._y = _ymouse;
customCursor._visible = true;
Mouse.hide();
};
magicsword.onPress = function() {
startDrag(this);
};
magicsword.onRelease = function() {
stopDrag();
};
magicsword.onRollOut = function() {
customCursor._visible = false;
Mouse.show();
};
-
Very close mate,
only difference is I want the cursor to change when you click down to another one.
So probably something like this:
I have just added a movieclip called glowingHand
Code:
customCursor._visible = false;
customCursor.onEnterFrame = function() {
customCursor._x = _xmouse;
customCursor._y = _ymouse;
};
magicsword.onRollOver = function() {
startDrag(customCursor);
customCursor._x = _xmouse;
customCursor._y = _ymouse;
customCursor._visible = true;
Mouse.hide();
};
magicsword.onPress = function() {
startDrag(this);
glowingHand._x = customCursor._x;
glowingHand._y = customCursor._y;
customCursor._visible = false;
glowingHand._visible = true;
startDrag(glowingHand);
};
magicsword.onRelease = function() {
stopDrag();
customCursor._visible = true;
glowingHand._visible = false;
customCursor._x = glowingHand._x;
customCursor._y = glowingHand._y;
};
magicsword.onRollOut = function() {
customCursor._visible = false;
Mouse.show();
};
See how the "sword" doesnt move now?
-
ok....remember how the first cursor worked with out startdrag? well we are going to do it the same way here. in the customCursor add another frame to it and call that frame: glowingHand. put the glowing hand cursor here.
Now you add this to the onpress function
Code:
customCursor.gotoAndStop("glowingHand")
and take out
Code:
glowingHand._x = customCursor._x;
glowingHand._y = customCursor._y;
customCursor._visible = false;
glowingHand._visible = true;
startDrag(glowingHand);
does that make sense/work?
-
sweet dude!!!
I just worked it out like you said, why the hell didnt I think of another frame!! GOSH!! Anyway all working now. All I have is on press gotoAndStop frame 2 deal and it works sweet. I have never named frames before so i am guessing i only need to put it in ("blah") format for the frame label to work?
Anyway, thanks again. Now I have bigger issues to work on
Like importing dynamic buttons into a movieclip inside a movieclip but I think I should save that for another thread.
-
thanks for your help too cancerinform
Last edited by budgi; 02-06-2007 at 09:04 PM.
-
Yep, that sounds right about the frame label...
and no problem, glad i could help.
-
hmmm... ok I know i should post this in a new thread but anyway.
I have a layer problem now. I have 3 layers
layer 1
layer 2
layer 3
and in the first frame of all of them i want to load onto a named layer.
get what i mean
so going back to the sword metaphor lets say i want to load sword into a movie clip on layer one and frame one
and i want to put cup into layer two but frame one.
Can that be done? At the moment I am loading them into blank movie clips but would like to just put them on a labelled frame.
-
rabid_Delineator
use eventDispatcher to broadcast an event that the dragable image and and the scollbar listen for. or use asBroadcaster.
-
I'm not sure if really understand what you mean....... and i have no idea what attackRabbit is getting at.
But layers? I don't think you can interact with layers through actionscript i think that they are purely to make authoring easier. if it is a case of an object appearing on top of another on the stage you can load MC's onto different levels. is that what you mean?
-
rabid_Delineator
budgi, so if im understanding your problem correctly you would like to load three images into a movieclip on three layers when the first frame actions are executed ? i would start by inserting a new symbol of type moiveclip, or dynamically create and attach a movieclip at run time in a for loop and use the this.getNextHighestDepth method to layer them. If you want your movie clip(s) on the time line , the place an instance of your empty movieclip on each frame and give each one a unique instance name like, myMC0, myMC1,myMC2, etc. Then on the first frame create an .as layer, use movieclip loaders to load your images ,swf, gifs, flvs , whatever. into then in the onLoadInit of the listener , toggle the visibilty of each movieclip on the time line, for example you could set the visibility of all three movieclips to false, then onloadInit, set a default clip as _visibile = true;
-
see i dont want to put any other movieclips on the stage because the things I am placing on the stage are buttons and want work at that level in. Its kinda too hard to explain and if I do tackle it I will start it in a new thread.
-
rabid_Delineator
sounds treacherous with flash buttons. i could mistaken but im pretty sure flash considers any object of type button to be of a component class. theres really no good reason ever to make a symbol of type button when you can assign eventHandlers through as to a movieclip. but hey whatever rubs your goat.
-
too complicated to explain, if explained will be in another thread.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|