LOADING
Loading
Hi , welcome back.
LogoutLOGOUT
 
  Lost password?  
Hi
 


  #1  
Old 03-05-2003, 05:36 PM
kud0s kud0s is offline
Registered User
 
Join Date: Mar 2001
Posts: 184
Rep Power: 13
kud0s is on a distinguished road
User Duplicate MovieClip

Hi All

i'd like to create several library objects, place them on the stage in a sort of menu...then when the user clicks on one they pick a copy of it up....they can then drop it anywhere on the stage by clicking again.

I understand the dragging part of it, but don't know how to attach a duplicate to the mouse

thanks if u can help me

Kud0s
__________________
"Think about how stupid the average person is, and then realize that half
of them are stupider than that!" - George Carlin
Reply With Quote
  #2  
Old 03-05-2003, 07:05 PM
dv8's Avatar
dv8 dv8 is offline

Admin Mod
 
Join Date: Mar 2001
Posts: 2,053
Rep Power: 15
dv8 is on a distinguished road
Hey Kud0s,
It's very simple actually.

Actionscript:
ball.onPress = function () {
	if (this._name != this._name + "_drag_copy"+this.copies && !this.draggin) {
		this.copies++;
		this.duplicateMovieClip(this._name+"_drag_copy"+this.copies, this.copies);
		eval(this._name+"_drag_copy"+this.copies)._alpha = 50;
		eval(this._name+"_drag_copy"+this.copies).startDrag(false);
		this.draggin = true;
	}
}
ball.onRelease = ball.onReleaseOutside = function () {
	stopDrag();
	eval(this._name+"_drag_copy"+this.copies)._alpha = 100;
	this.draggin = false;
}

[swf x=250 y=250]http://www.dv8flasher.com/flashmove/dragADuplicate/dragADup.swf[/swf]
Reply With Quote
  #3  
Old 03-06-2003, 09:08 AM
kud0s kud0s is offline
Registered User
 
Join Date: Mar 2001
Posts: 184
Rep Power: 13
kud0s is on a distinguished road
Thanks DV8

I've cut & pasted you code & got it working in my fla.

But I can't claim to have fully got to grips with it yet & am struggling to adapt it.

Once i have dropped the item I would like the possibility of picking it up again.

could you offer further enlightenment

kud0s
__________________
"Think about how stupid the average person is, and then realize that half
of them are stupider than that!" - George Carlin
Reply With Quote
  #4  
Old 03-06-2003, 09:39 AM
kud0s kud0s is offline
Registered User
 
Join Date: Mar 2001
Posts: 184
Rep Power: 13
kud0s is on a distinguished road
Ok I've done it

i've attached an invible button within the ball_MC with it's own Drag code.

It works a treat ;-)

Cheers DV8

p.s if there's a more logical/elegant way of doing this let me know
__________________
"Think about how stupid the average person is, and then realize that half
of them are stupider than that!" - George Carlin
Reply With Quote
  #5  
Old 03-06-2003, 02:27 PM
dv8's Avatar
dv8 dv8 is offline

Admin Mod
 
Join Date: Mar 2001
Posts: 2,053
Rep Power: 15
dv8 is on a distinguished road
Really by adding two addition functions for the Duplicate MovieClip you can assign a Drag Function.

For Example...
Actionscript:
ball.onPress = function () {
	if (this._name != this._name + "_drag_copy"+this.copies && !this.draggin) {
		this.copies++;
		this.duplicateMovieClip(this._name+"_drag_copy"+this.copies, this.copies);
		eval(this._name+"_drag_copy"+this.copies)._alpha = 50;
		eval(this._name+"_drag_copy"+this.copies).startDrag(false);
		
		// Duplicate Ball MovieClip Drag Function (start)
		eval(this._name+"_drag_copy"+this.copies).onPress = function () {
			this.startDrag(false);
		}
		// Duplicate Ball MovieClip Drag Function (stop)
		eval(this._name+"_drag_copy"+this.copies).onRelease = function () {
			stopDrag();
		}
		this.draggin = true;
	}
}
ball.onRelease = ball.onReleaseOutside = function () {
	stopDrag();
	eval(this._name+"_drag_copy"+this.copies)._alpha = 100;
	this.draggin = false;
}

Ball is the MovieClip your running this function on. I do not use Buttons in this example.

Also, I did this for fun
Actionscript:
/* Any MovieClip on the Scene will now act as desired... except duplicates hehehe */
MovieClip.prototype.onPress = function () {
	for (var mc in this._parent) {
		this.shift_depth += 100;
	}
	if (this._name != this._name + "_drag_copy"+this.copies && !this.draggin) {
		this.copies++;
		this.duplicateMovieClip(this._name+"_drag_copy"+this.copies, this.shift_depth + this.copies);
		eval(this._name+"_drag_copy"+this.copies)._alpha = 50;
		eval(this._name+"_drag_copy"+this.copies).startDrag(false);
		
		// Duplicate Ball MovieClip Drag Function (start)
		eval(this._name+"_drag_copy"+this.copies).onPress = function () {
			this.startDrag(false);
		}
		// Duplicate Ball MovieClip Drag Function (stop)
		eval(this._name+"_drag_copy"+this.copies).onRelease = function () {
			stopDrag();
		}
		this.draggin = true;
	}
}
MovieClip.prototype.onRelease = MovieClip.prototype.onReleaseOutside = function () {
	stopDrag();
	eval(this._name+"_drag_copy"+this.copies)._alpha = 100;
	this.draggin = false;
}
Reply With Quote
  #6  
Old 03-07-2003, 12:07 PM
kud0s kud0s is offline
Registered User
 
Join Date: Mar 2001
Posts: 184
Rep Power: 13
kud0s is on a distinguished road
Well Done DV8

That does exactly what i want. There's just one think I can seem to fathom.

Reading through the code (the last example you posted) souldn't i be able to place the Code & duplicatable MC's within an MC called Library. [for (var mc in this._parent)]

The extra functionality i'm trying to achieve is to have the DuplicatableMC's in a menu system that can be hidden or dragged as a unit.

if i've made any sense i'm greatful for any help you could offer ;-)

Kud0s
__________________
"Think about how stupid the average person is, and then realize that half
of them are stupider than that!" - George Carlin
Reply With Quote
  #7  
Old 03-07-2003, 03:03 PM
dv8's Avatar
dv8 dv8 is offline

Admin Mod
 
Join Date: Mar 2001
Posts: 2,053
Rep Power: 15
dv8 is on a distinguished road
Oh yeah sure you can. If your working with nested MovieClip within MovieClips, it all about referring to their specific target areas.

For Example:
Library MovieClip has 5 Nested MovieClips
Nest MovieClip Names:
- square
- ball
- triangle

By simply using the code I gave you and understanding a little about how Levels and Targeting works, you can achieve what you want.

Actionscript:
// In this line...
ball.onPress = function () {}

// You change the direct call to "ball"...
library.ball.onPress = function () {}// Now the Code is talking to the "ball" within the "library"

/* This goes for the same for all Nested MovieClips. The further the MovieClip is nested you have to include the Target.*/
Internet.Flashmove.Forum.Member.kud0s

Second thing you have to think about Levels and Targets, is who to refer to an MovieClip from within a MovieClip like "library".
So instead of using...
Actionscript:
eval(this._name+"_drag_copy"+this.copies)

// You will change it to...
this._parent[this._name+"_drag_copy"+this.copies]
/*
this._parent would be "library"
this._name would be "ball"
Plus, "_drag_copy" and this.copies (an incrementing number) and add it all together and it equals "library.ball_drag_copy1"
*/
Now some Flash Coders wouldn't code their whole movie from the Main TimeLine... I do. So, the usage of "_parent" may not nesscary all the time.
Also, the further down you go into Nested MovieClips the more you have to consider for "_parent"
Actionscript:
Internet.Flashmove.Forum.Member.kud0s
/* If I was to tell kud0s to run a function to move the FlashMove MovieClip 20 pixel to the right, it would look like... */
Internet.Flashmove.Forum.Member.kud0s.onEnterFrame = function () {
	trace(this._parent._parent._parent);
	this._parent._parent._parent._x += 20;
	delete this.onEnterFrame;
}

I hope this has filled you with a little knowledge on how to do what you want.
Reply With Quote
  #8  
Old 03-07-2003, 07:17 PM
kud0s kud0s is offline
Registered User
 
Join Date: Mar 2001
Posts: 184
Rep Power: 13
kud0s is on a distinguished road
Many Thanks

I'll have a chew over this at the weekend :-)

Kud0s
__________________
"Think about how stupid the average person is, and then realize that half
of them are stupider than that!" - George Carlin
Reply With Quote


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Duplicate Movieclip and have random image in each csr500 Flash CS3 / Flash 9 0 06-04-2009 03:43 PM
Making an interactive animation where user controls movieclip movement sukhraj Newbies 6 03-11-2007 10:56 PM
duplicate movieclip and gotoandplay together gobber Newbies 1 08-17-2005 10:17 AM
duplicate movieclip holder bugjuice Flash MX ActionScript 1 02-19-2004 11:48 AM
Duplicate movieclip choi_kathryn Flash 5 Actionscript 1 11-30-2002 11:13 PM




All times are GMT. The time now is 01:03 AM.