A Flash Developer Resource Site

Results 1 to 1 of 1

Thread: Masking problem

Threaded View

  1. #1
    Junior Member
    Join Date
    Jul 2007
    Posts
    23

    Masking problem

    I tried posting this problem once before but got no reply so I thought I would try explaining it a little better.

    I use the following code within a movieclip (made of multiple other movieclips and named "mcMap") to drop circles (instances of a circle movieclip with the linkage name of "CircleSymbol") each time the player clicks in a designated area defined by a named movieclip "mcMap":
    Code:
    stop();
    var i:Number = 0;
    mcMap.onPress = function() {
        i++;
        _root.attachMovie("CircleSymbol", "mcCircle"+i, i, {_x:_root._xmouse, _y:_root._ymouse});
        _root.clipName = "mcCircle"+i;
        _root.xPos = _root._xmouse;
        _root.yPos = _root._ymouse;
        _root.scaleClip = true;
    	_root.allowClip = true;
    	_root["mcCircle" + i].setMask(mcMap);
    };
    
    mcMap.onRelease = function() {
        _root.scaleClip = false;
    };
    
    mcMap.onReleaseOutside = function() {
            _root.scaleClip = false;
    };
    The following code, placed on the first frame of the main timeline, allows the user to scale the size of the dropped circles if the user drags the mouse while holding down the mouse key:
    Code:
    stop();
    _root.onEnterFrame = function() {
        if (_root.scaleClip == true) {
            xDist = _root._xmouse-_root.xPos;
            yDist = _root._ymouse-_root.yPos;
            if (_root[_root.clipName]._width + (_root.xDist + _root.yDist) > 10 && _root[_root.clipName]._height + (_root.xDist + _root.yDist) > 10) {
                _root[_root.clipName]._width += _root.xDist + _root.yDist;
                _root[_root.clipName]._height += _root.xDist + _root.yDist;
                _root.xPos = _root._xmouse;
                _root.yPos = _root._ymouse;
            }
        }
    };
    mcGotoMap.onRelease = function(){
    	_root.mcMapAppear.gotoAndPlay("start");
    };
    The problem I am having is that although the circles are masked correctly when they are first dropped (i.e. they do not display outside of the "mcMap" area) once a subsequent circle is dropped the previous circle is no longer masked. I am using the following script in the first bit of code to define the mask for the dropped circles:
    Code:
    _root["mcCircle" + i].setMask(mcMap);
    Attached is an example fla. Press the "Press to Start" button to see what is happening.
    Attached Files Attached Files
    Last edited by BrianDP1977; 07-27-2007 at 09:28 PM.

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