A Flash Developer Resource Site

Results 1 to 19 of 19

Thread: setmask not working on dynamil loaded image

  1. #1
    Senior Member
    Join Date
    Sep 2004
    Location
    West Mids, UK
    Posts
    101

    setmask not working on dynamil loaded image

    hey guys hope you can help with this one.
    I am loading in a dynamic image from an external file, now I am loading it into an existing movieclip btu when I do the masking on the MC doesn't work :S

    PHP Code:
    product_shadow.setMask(masker); 
    thats the code I am using to set the masker inside the MC, this code is contained in the movieclip itself

    PHP Code:
    loadMovie("padlock_big.png"_root.b0.product);
    loadMovie("padlock_big.png"_root.b0.product_shadow); 
    thats the code that loads the images in, anyone know of a way to get this working?

  2. #2
    Animal Lover, Flash lover eaglevision's Avatar
    Join Date
    Jan 2008
    Location
    In FlashKit
    Posts
    286
    Watch this!
    After a few minutes, somone else will post, its true!
    ~11-year old flasher

  3. #3
    Member
    Join Date
    Aug 2007
    Posts
    57
    What you need to do is set the mask on the clip that contains the image. When you load the external image file into product_shadow, you can no longer apply properties to product_shadow, so try setting the mask as such:

    _root.b0.setMask(masker);

    or if that screws up the image that gets loaded at _root.b0.product, you can do this:

    _root.b0.product_shadow.createEmptyMovieClip("new_ mc", this.getNextHighestDepth());
    then loadMovie("padlock_big.png", _root.b0.product_shadow.new_mc);

    then you'll be able to apply the mask to _root.b0.product_shadow

    Hope this helps.

  4. #4
    Animal Lover, Flash lover eaglevision's Avatar
    Join Date
    Jan 2008
    Location
    In FlashKit
    Posts
    286
    See.....it worked...
    ~11-year old flasher

  5. #5
    Senior Member
    Join Date
    Sep 2004
    Location
    West Mids, UK
    Posts
    101
    eaglevision you are so helpfull i mean this world could not live without you.

    HKR Chief, I have tried what you suggested previously (been googling it) but still cant seem to get it to work. Perhaps if I post the entire code it may help


    Basicly the system is to load up dynamic png's into the movie clip of products and have it as a rotating menu system.
    Attached Images Attached Images
    Attached Files Attached Files
    Last edited by neomaximus2k; 01-17-2008 at 10:18 AM.

  6. #6
    Animal Lover, Flash lover eaglevision's Avatar
    Join Date
    Jan 2008
    Location
    In FlashKit
    Posts
    286
    Thanks! but I really think it would...Sorry I can't help you, I can only help with basics
    ~11-year old flasher

  7. #7
    Member
    Join Date
    Aug 2007
    Posts
    57
    I don't have Flash on the computer I'm at right now but I'll take it home and look at it over night and let you know what I find out. I'm sure you'll probably figure it out by then though.

  8. #8
    Senior Member
    Join Date
    Sep 2004
    Location
    West Mids, UK
    Posts
    101
    doubt that I've drawn a complete blank

  9. #9
    Senior Member
    Join Date
    Sep 2004
    Location
    West Mids, UK
    Posts
    101
    well I've tried a few other methods and still nothing

  10. #10
    Member
    Join Date
    Aug 2007
    Posts
    57
    I forgot to look at yours last night. Sorry.

    Can you post more of your code? Then maybe I can figure out what's going on.

  11. #11
    Senior Member
    Join Date
    Sep 2004
    Location
    West Mids, UK
    Posts
    101
    erm the flash file is attached above

  12. #12
    Member
    Join Date
    Aug 2007
    Posts
    57
    I took a little time to work on your problem last night and I think I figured out how to do what you wanted.

    First I noticed you were using a separate product_[number] in the library for each item you were adding to the stage. To reduce the number of items in the library, I removed all but one and named it "product_x". For the number of balls to add, it attaches the product_x from the library and names it b_[number].

    Thne I figured out how the product_x movie clip is set up internally. I made a slight change inside it. Basically, instead of the upside down copy of the image being at _root.b0.product_shadow, I added another layer inside it and made it _root.b0.r.product_shadow (I think. I'm trying to remember from when I did it last night.)

    Now, when you attach the movie clip, after it loads, it attaches a bitmapdata copy of it inside the _root.b0.r.product_shadow clip which gets masked properly.

    So the result was what you were looking for, I believe. which is in the file carousel2.fla

    I took it a step further for what I think you were heading towards. I made an xml file called files.xml. This file lists any product images you want to attach. I then made modified copies of the picture and added their names into the files.xml file. Then I modified the code to automatically attach whatever pictures that are named in the files.xml file. This is all in the zipped file I'm attaching. **Edit**:Actually, I had to make the zip file in two parts because it was too large.

    One thing however that I couldn't figure out is, it plays fine when you do a control-enter from within Flash. But if you run the swf file by itself, it's not working and I don't know why that is.

    Anyway, take a look and let me know if you have any questions. I hope this gets you going in the direction you were looking for. Also, take a look within the product_x clip at where the mask is, and where the image gets attached to so you can see what I did to make it work compared to why it wouldn't work before.
    Attached Files Attached Files

  13. #13
    Senior Member
    Join Date
    Sep 2004
    Location
    West Mids, UK
    Posts
    101
    nice one chief, I had the xml code ready to insert and I was gonna do exactly as you said with just the one instance in the library (the multiple ones where there cause i was getting fed up of it not working lol)

    I will need to expand on it a lot more but when its done i'll post the code cheers

  14. #14
    Senior Member
    Join Date
    Sep 2004
    Location
    West Mids, UK
    Posts
    101
    The reason it didn't work from the html file is because it was set to access network files only and not local files, on the expert if you change it to local files it will then work a treat

    Now to develop the php code to generate the xml file with the images, titles and links

  15. #15
    Member
    Join Date
    Aug 2007
    Posts
    57
    Good deal. I was wondering if that's what it was, but I didn't have time to check. I was up an hour past my bedtime working on it as it was.

    I think I learned a little bit while helping you out, by reading through your code and the way the product_[number] clips were set up. I'm going to keep that stuff in my collection to refer back to when I need to figure out how to do something that relates. Glad I was able to help. Good luck on the rest of it.

  16. #16
    Senior Member
    Join Date
    Sep 2004
    Location
    West Mids, UK
    Posts
    101
    Only problem I am having now is defining a variable in each of the clips

    for instance I have the product title working but I wanted to set a variable called link on each movieclip that holds the link to the url, the xml works fine but for some reason the variables doesn't get set
    PHP Code:
    for (n=0n<=totalxmlitemsn++) {
        
    filename filenamearray[n];
        
    destinationclip "b"+n;
        
    loader.loadClip(filename_root[destinationclip].mainproductimage);
        
    _root[destinationclip].textbox titlearray[n];
        
    _root.destinationclip.linkage filenamearray[n];
        
    //I removed the following so it only loads the clip once.
        //loader.loadClip(filename, _root[destinationclip].r.holder);

    My flash skills are so off think i need to start it up again lol

  17. #17
    Senior Member
    Join Date
    Sep 2004
    Location
    West Mids, UK
    Posts
    101
    man i am rusty i was calling a direct _parent and not this._parent on the on mouse over lol

    PHP Code:
        target_mc.onRollOver = function() {
            
    this._parent.textbox this._parent.producttitle;        
        };
        
    target_mc.onRollOut = function (){
            
    this._parent.textbox " ";
        }
        
    target_mc.onRelease = function () {
            
    getURL(this._parent.linkage"_self");
        }
    };
    for (
    n=0n<=totalxmlitemsn++) {
        
    filename filenamearray[n];
        
    destinationclip "b"+n;
        
    loader.loadClip(filename_root[destinationclip].mainproductimage);
        
    _root[destinationclip].producttitle titlearray[n];
        
    _root[destinationclip].linkage linkarray[n];
        
    //I removed the following so it only loads the clip once.
        //loader.loadClip(filename, _root[destinationclip].r.holder);

    The only problem is when you hold the mouse on one of the products the text doesn't go away as it rotates, any ideas?
    Last edited by neomaximus2k; 01-19-2008 at 12:32 PM.

  18. #18
    Member
    Join Date
    Aug 2007
    Posts
    57
    I'm not sure I understand what you mean on your last question.

    The only problem is when you hold the mouse on one of the products the text doesn't go away as it rotates, any ideas?
    Do you mean if you hold the mouse in one position, then when the item rotates out from under the mouse, the text stays?

    Where is the textbox for the producttitle? Is it right there with the product image? Does it rotate around with the image? Or is there one standard location where the text comes up, regardless of which item you rollOver? Once I get these particulars, I should be able to get you on the right path.

  19. #19
    Senior Member
    Join Date
    Sep 2004
    Location
    West Mids, UK
    Posts
    101
    flash file attached you will see what i mean, i have attached the xml file aslwell but you will have to export as local files instead of network again (the file is edited on network machine hance why its set to network)

    just rename the files.xml.renametoxml.fla to files.xml

    this board really should check mime types otherwise it could easiy be hacked
    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