|
|
|
#1 |
|
Member
Join Date: Sep 2004
Posts: 35
|
Simple Drag Function within an AS file
I have a movie clip Screen which contains another movie clip dragger. (a drag bar)
I will be attaching instances of this clip as needed. What I want to do is write a function so that when the dragger bar is pressed in any of the instances of the Screen clip, that instance of Screen can then be dragged. This function resides in a class Screen which is linked to the movie clip and I am using AS 2.0 This is more or less what I have come up with Code:
function drag() {
dragger.onPress = startDrag(true);
}
Thanks for your help
__________________
It's In The Mail |
|
|
|
|
|
#2 |
|
Senior Member
Join Date: Feb 2004
Location: Los Angeles
Posts: 2,920
|
One way to do it would be to attach the following script to the dragger instance:
|
|
|
|
|
|
#3 |
|
Member
Join Date: Sep 2004
Posts: 35
|
Hi,
Thanks but I am trying to centralize all the code which is common to the Screen clip. It's got to be something simple, I just can't see it.
__________________
It's In The Mail |
|
|
|
|
|
#4 |
|
Senior Member
Join Date: Feb 2004
Location: Los Angeles
Posts: 2,920
|
|
|
|
|
|
|
#5 |
|
Member
Join Date: Sep 2004
Posts: 35
|
That does it
Thanks
__________________
It's In The Mail |
|
|
|
|
|
#6 |
|
Member
Join Date: Sep 2004
Posts: 35
|
I am running into another problem. Can't figure it out.
The function works as long as I include Screen for example: Screen.dragger.onPress Of course In actuality it would be Screen1, Screen2 etc... So here is the button action, I pass the id to the as file. Code:
attachMovie("Screen", "Screen1", 2, {id:1});
Code:
var capt:String, id:Number; Code:
function Screen() {
path = "Screen" + id + ".dragger";
trace(path);
}
is this a type mismatch? what is going on? Thanks
__________________
It's In The Mail |
|
|
|
|
|
#7 |
|
Senior Member
Join Date: Feb 2004
Location: Los Angeles
Posts: 2,920
|
First off in when attaching the movie, you need to name the clip using a dynamic id number, like so:
myID = 2; attachMovie("Screen", "Screen"+myID, 2, {id:myID}); Secondly, your path is a string: path = "Screen" + id + ".dragger"; You'll need to evalulate it to use it like a movieclip. path._x += 3; // invalid mc = eval(path); mc._x += 3; // valid |
|
|
|
|
|
#8 |
|
Member
Join Date: Sep 2004
Posts: 35
|
Yes, that will work, thanks.
I thought they had done away with eval in 2.0
__________________
It's In The Mail |
|
|
|
![]() |
|
||||||
| Thread Tools | Search this Thread |
| Display Modes | |
|
|