A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Dragging createEmptyMovieClips

  1. #1
    I'm not afraid Fearless's Avatar
    Join Date
    Jun 2000
    Posts
    351

    Dragging createEmptyMovieClips

    Hey Guys,

    After creating empty movie clips is there any possible way to drag them?

    Heres the creation code:

    Code:
    on(press) {
    	_root.createEmptyMovieClip("factor",_root.numFactors);
    	with (_root.factor) {
    		beginFill(0xFF0000, 25);
    		lineStyle(1, 0x000000, 100);
    		lineTo(240, 110)
    		lineTo(0, 220)
    		lineTo(0, 0)
    		endFill()
    }
    _root.numFactors++;
    _root.numFactors = 1;
    }
    It just creates another triangle over the last each time I click the button.
    I want to be able to drag them each individually. Any ideas would be much appreciated.

    Thanks,
    Fearless

  2. #2
    Senior Member
    Join Date
    Feb 2001
    Location
    On the fifth floor.
    Posts
    1,202
    Code:
    on(press) {
    	_root.createEmptyMovieClip("factor"+i,++depth);
    	with (factor) {
    		beginFill(0xFF0000, 25);
    		lineStyle(1, 0x000000, 100);
    		lineTo(240, 110)
    		lineTo(0, 220)
    		lineTo(0, 0)
    		endFill()
    }
    i+=1;
    }
    on(release){
    	factor.onPress = function(){
    	this.startDrag(false);
    		}
    	factor.onRelease = function(){
    		stopDrag();
    }
    }
    Now you can drag MC "factor", but to drag them each individually, I think you should make MovieClip.prototype.

  3. #3
    Junior Member
    Join Date
    Jul 2001
    Posts
    10
    Here's another way to look at it.

    Code:
    on (press) {
    	this.createEmptyMovieClip("factor"+_root.numFactors, ++depth);
    	with (_root["factor"+_root.numFactors]) {
    		beginFill(0xFF0000, 25);
    		lineStyle(1, 0x000000, 100);
    		lineTo(240, 110);
    		lineTo(0, 220);
    		lineTo(0, 0);
    		endFill();
    	}
    	_root["factor"+_root.numFactors].onPress = function() {
    		this.startDrag(false);
    	};
    	_root["factor"+_root.numFactors].onRelease = function() {
    		stopDrag();
    	};
    	_root.numFactors++;
    }
    -ag

  4. #4
    Senior Member
    Join Date
    Feb 2001
    Location
    On the fifth floor.
    Posts
    1,202
    Excellent! Thanks for this example.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center