A Flash Developer Resource Site

Results 1 to 11 of 11

Thread: create multiple empty movie clips

  1. #1

    create multiple empty movie clips

    Ok so basically I have a button that will create a empty movie clip and attach some things into that clip When the button is first clicked. My problem is that when the button is clicked a second time. The clip will reload itself and I need it to duplicate. So if I hit the button 5 times, there would be 5 items on the stage.

    Here is what I'm doing.

    Code:
    hold1.onPress = function(){
    	trace("your hit me");
    	_root.createEmptyMovieClip("conHolder",1);
    	//conHolder.hitArea = conHolder.content;
    	//_root.attachMovie(conButs,conBut,3)
    	_root.conHolder.attachMovie("conButs", "conButs", _root.getNextHighestDepth()+1);
    	_root.conHolder._x = 100;
    	_root.conHolder._y = 100;
    	_root.conHolder.startDrag();
    	//_root.conHolder._x += (_root._xmouse-10-this._x); 
      //_root.conHolder._y += (_root._ymouse-10-this._y); 
      _root.conHolder.conButs.hold.loadMovie("icons/couch2Seat.swf",1);
    	}

    Thanks for all and any help.

  2. #2
    :
    Join Date
    Dec 2002
    Posts
    3,518
    Code:
    hold1.onPress = function() {
    	var d = _root.getNextHighestDepth();
    	var myH = _root.createEmptyMovieClip("conHolder" + d, d);
    	var myCH = myH.attachMovie("conButs", "conButs", 0);
    	myCH._x = 100;
    	myCH._y = 100;
    	myCH.onPress = startDrag;
    	myCH.onRelease = stopDrag;
    	myCH.hold.loadMovie("icons/couch2Seat.swf", 1);
    };

  3. #3
    Thanks man.

    But how would I set it to start drag right off the bat. right now you have to click the item twice. I would like to know how to set up a swapDepth feature aswell. Sorry If im asking for alot its just those things wer secondary until moments ago.

    thanks again.
    Last edited by billy nugz; 08-20-2008 at 06:26 PM.

  4. #4
    :
    Join Date
    Dec 2002
    Posts
    3,518
    Code:
    hold1.onPress = function() {
    	var d = _root.getNextHighestDepth();
    	var myH = _root.createEmptyMovieClip("conHolder" + d, d);
    	var myCH = myH.attachMovie("conButs", "conButs", 0);
    	myCH._x = this._x;
    	myCH._y = this._y;
    	myCH.startDrag();
    	myCH.onPress = startDrag;
    	myCH.onRelease = stopDrag;
    	myCH.hold.loadMovie("icons/couch2Seat.swf", 1);
    };

  5. #5
    still lost on the swapDepth part

    this is what Im doing wrong

    Code:
    hold1.onPress = function() {
    	var d = _root.getNextHighestDepth();
    	var myH = _root.createEmptyMovieClip("conHolder" + d, d);
    	var myCH = myH.attachMovie("conButs", "conButs", 0);
    	myCH._x  += (_root._xmouse-10-this._x); 
    	myCH._y += (_root._ymouse-10-this._y); 
    	myCH.startDrag();
    	//myCH.onPress = startDrag;
    	myCH.onPress = function(){
    	myCH.startDrag();
    	myCH.swapDepths(d);
    	}
    	myCH.onRelease = stopDrag;
    	myCH.hold.loadMovie("icons/couch2Seat.swf", 1);
    };
    Any clues?

  6. #6
    :
    Join Date
    Dec 2002
    Posts
    3,518
    Code:
    hold1.onPress = function() {
    	var d = _root.getNextHighestDepth();
    	var myH = _root.createEmptyMovieClip("conHolder" + d, d);
    	var myCH = myH.attachMovie("conButs", "conButs", 0);
    	myCH.startDrag(true);
    	myCH.onPress = function() {
    		this.startDrag();
    		this._parent.swapDepths(_root.getNextHighestDepth());
    	};
    	myCH.onRelease = stopDrag;
    	myCH.hold.loadMovie("icons/couch2Seat.swf", 1);
    };

  7. #7
    New problem I now would like to rotate the myCH movie around its centre however I cant seem to get it. Here is what Im trying but its moving around the left corner. Here is what Im doing.

    Code:
    hold1.hold.loadMovie("icons/couch2Seat.swf",1);
    hold1.hold._xscale = 50;
    hold1.hold._yscale = 50;
    	
    	hold1.onPress = function() {
    	var d = _root.getNextHighestDepth();
    	var myH = _root.createEmptyMovieClip("conHolder" + d, d);
    	var myBtn = myH.createEmptyMovieClip("btnHolder" + d+1, d+1);
    	var myCH = myH.attachMovie("conButs", "conButs", 0);
    	
    	trace("W "+myCH.hold._width);
    	trace("H "+myCH.hold._height);
    	
    	myCH.startDrag(true);
    	myCH.onPress = function() {
    		this.startDrag();
    		this._parent.swapDepths(_root.getNextHighestDepth());
    	};
    	myCH.onRelease = function() {
    		this.stopDrag();
    		_root.btnHolder._x = myCH._x;
    		_root.btnHolder._y = myCH._y;
    	};
    	myCH.onRollOver = function() {
    		
    		myBtn.createEmptyMovieClip("theControls", 30);
    		myBtn.theControls.attachMovie("actButs", "actButs", 30);
    		myBtn.theControls._x = myCH._x;
    		myBtn.theControls._y = myCH._y;
    		myBtn.theControls.actButs.but1.onRollOver = function(){
    	
    	trace("action1");
    	
    	}
    	
    	myBtn.theControls.actButs.but2.onPress = function(){
    	
    	trace("action2");
    	//_root.tester._rotation+=10;
    	myCH._rotation+=10;
    	
    	}
    		
    	};
    	
    	
    	
    	myCH.hold.loadMovie("icons/couch2Seat.swf", 1);
    	trace("W "+myCH.hold.content._width);
    	trace("H "+myCH.hold.content._height);
    };
    
    function closeAbout():Void
    {
    _root.btnHolder.removeMovieClip()
    
    }
    
    /*onEnterFrame = function() {
    if(!this.hitTest(_root._xmouse , _root._ymouse , false)) {
    delayInt = setInterval(delay,3000);
    delete onEnterFrame;
    }
    }
    function delay() {
    _root.btnHolder.removeMovieClip();
    trace("delayed");
    clearInterval(delayInt);
    }*/
    Any further help would be great and thanks again

  8. #8
    :
    Join Date
    Dec 2002
    Posts
    3,518
    Change the copy of 'conButs' in the library, so it's registration is in the center.

  9. #9
    sorry its actually the "hold" move that I want to rotate around its center. But when the swf gets loaded its registration point is the left corner maybe im not making sense should I post a FLA?

  10. #10
    :
    Join Date
    Dec 2002
    Posts
    3,518
    If you can save it in MX2004, as I can't open anything newer...

  11. #11
    :
    Join Date
    Dec 2002
    Posts
    3,518
    Add this at the top
    Code:
    var myMcl = new MovieClipLoader();
    var myListener = new Object();
    myListener.onLoadInit = function(mc) {
    	mc._x -= (mc._width / 2);
    	mc._y -= (mc._height / 2);
    };
    myMcl.addListener(myListener);
    Change load movie to load clip.
    Code:
    //hold1.hold.loadMovie("icons/couch2Seat.swf", 1);
    myMcl.loadClip("icons/couch2Seat.swf", hold1.hold);
    And again change load movie to load clip.
    Code:
    	//myCH.hold.loadMovie("icons/couch2Seat.swf", 1);
    	myMcl.loadClip("icons/couch2Seat.swf", myCH.hold);

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