A Flash Developer Resource Site

Results 1 to 10 of 10

Thread: setMask, multple masks

  1. #1
    Member
    Join Date
    Mar 2007
    Location
    Ireland
    Posts
    31

    setMask, multple masks

    OK so I have a comic creator flash GUI I'm working on. I'm looking for a way to mask the images from on panel to the next. The images are dropped on comicPanelMC, which is a movieClip with 3 MovieClips inside (panel1MC, panel2MC, panel3MC). Once all the images are drug onto the comicPanel I need to find a way to mask each panel so that images from panel1MC don't overlap onto panel2MC, images from panel2MC don't overlap onto panel3MC etc.
    So first thing i need to do is find the images specific to each location, then to apply the appropriate mask. The confusing part is that the images are drug onto comicPanelMC, and I do now know a way to identify them by the more specific location, (i.e. comicPanelMC.panel1MC). As soon as I can group images to their appropriate location I can add the appropriate mask. Can I find all movieclip instances with some code like;

    PHP Code:
    for(var z in _root){
        if(
    _root[z] instanceof MovieClip){
            
    trace(_root[z])
        }

    and then perhaps sort by x and y position, and then apply the appropriate mask? Is there any examples of something simular anyone has come across? Can I, upon adding the images to the stage with attachMovie sort them into some sort of array depending on their x and y position?

  2. #2
    Member
    Join Date
    Mar 2007
    Location
    Ireland
    Posts
    31
    ok i overlooked the obvious... putting a hittest on the actual panels themselves, and then declaring an independant variable for each;
    PHP Code:
    var mouseListener = new Object();
    mouseListener.onMouseUp = function() {
        if (!
    activeMC.hitTest(comicPanelMC)) {
            
    removeMovieClip(activeMC);
            
    activeMC null;
        } else {
            
    //        activeMC.setMask(mask1Mc);
            //trace all onstage mcs
        
    }
        
    stopDrag();
        if (
    comicPanelMC.panel1MC.hitTest(activeMC)) {
            var 
    panel1Img1:String activeMC;
            
    trace(panel1Img1);
        }
        if (
    comicPanelMC.panel2MC.hitTest(activeMC)) {
            var 
    panel2Img1:String activeMC;
            
    trace(panel2Img1);
        }
        if (
    comicPanelMC.panel3MC.hitTest(activeMC)) {
            var 
    panel3Img1:String activeMC;
            
    trace(panel3Img1);
        }
    };
    Mouse.addListener(mouseListener); 
    now i believe the best solution is to create an array for each (panel1Img1, panel1Img2, panel1Img3) and have the setMask funtion applied to all objects in the array (assuming no more than 5 instances of one character are used per frame).

  3. #3
    Member
    Join Date
    Mar 2007
    Location
    Ireland
    Posts
    31
    any suggestions on how to organize the array?

  4. #4
    Member
    Join Date
    Mar 2007
    Location
    Ireland
    Posts
    31

    assigning images to a specific array with a corresponding mask

    Okay so i have an array for all the images dropped into the first panel;

    PHP Code:
    firstPanel = new Array(); 
    and when an object is dropped into panel 1 it is added to the array

    PHP Code:
    var mouseListener = new Object();
    mouseListener.onMouseUp = function() {
        if (!
    activeMC.hitTest(comicPanelMC)) {
            
    removeMovieClip(activeMC);
            
    activeMC null;
        }
        
    stopDrag();
        if (
    comicPanelMC.panel1MC.hitTest(activeMC)) {
            
    firstImage firstPanel.push(activeMC);
            
    trace(firstPanel);

        }
    }; 
    But the problem now is

    a) I am getting duplicate entries in the firstPanel array as activeMC is any object which is selected by the user, even if that object is already on the stage.
    b) I need to apply a setMask function to all the objects in the firstPanel array. I am not very familiar with arrays but most of what I've read treats them as collections of number values instead of objects.
    Last edited by emcdoe; 05-07-2008 at 11:01 AM. Reason: grammar

  5. #5
    :
    Join Date
    Dec 2002
    Posts
    3,518

    Maybe you can adapt this to what you are trying to do...

    Perhaps an alternative way to try is to create an empty movie clip inside each of the panels and mask it. And when an object is dropped on a panel attach it to the holder (empty movie clip).

    See attached file for a quick and dirty concept...
    Last edited by dawsonk; 05-21-2008 at 04:20 PM.

  6. #6
    Member
    Join Date
    Mar 2007
    Location
    Ireland
    Posts
    31

    masked container disabled input text, and key controlled input

    I've got the code working but now the masking has disabled many of the other things I had working previous... I realize this problem is getting beyond the scope of this flashkit and really appreciate all the help so far, any further suggestions would be very welcome.

    a) images no longer scale, rotate, change orientation (face left, face right)
    b) speech ballon with input text no longer allows text to be input (i'm not sure if this is because the movieClip is masked or because it is in a container)

    Anyways see attached file for current progress, thanks again.

    -emcdoe
    Attached Files Attached Files

  7. #7
    :
    Join Date
    Dec 2002
    Posts
    3,518
    Sorry, I only have Flash MX 2004 and can't open the posted file.

    (If you are using Flash 8, you can do a file 'Save as' and save it to a different filename and select MX2004 from the file type selector.)

  8. #8
    Member
    Join Date
    Mar 2007
    Location
    Ireland
    Posts
    31

    MX 2004 version

    here's the flash MX 2004 version... I think if implement the Listener to relate to the "holder" movieclip it will work. Still not 100% on the input text feild
    Attached Files Attached Files

  9. #9
    Member
    Join Date
    Mar 2007
    Location
    Ireland
    Posts
    31
    i don't think the speech bubble is an issue i've got a work around in mind

  10. #10
    Member
    Join Date
    Mar 2007
    Location
    Ireland
    Posts
    31

    masked container offsetting scale function

    okay I've gotten the file working with the keys, the problem now is that when scaling the objects, it is interpreting the middle of the object to be in the top right hand corner of the stage. I believe this code is not working because of the container mc, "holder"

    PHP Code:
            var dX onstageMC._x-_xmouse;
            var 
    dY onstageMC._y-_ymouse;
            var 
    dist Math.sqrt((dX*dX)+(dY*dY));
            if (
    dist>scaleMIN dist<scaleMAX) {
                
    onstageMC._xscale onstageMC._yscale=dist;
            } 
    However I would say the issue is resolved, thanks again!
    Attached Files Attached Files

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