A Flash Developer Resource Site

Results 1 to 14 of 14

Thread: unable to duplicate dynamically created MovieClip

  1. #1
    Member
    Join Date
    Jan 2005
    Location
    Bangalore
    Posts
    93

    unable to duplicate dynamically created MovieClip

    Hi buddies,

    Am not able to duplicate dynamically created movie clip. I am retreiving images Path from an XML and load each image in a MovieClip.
    I have to display those image MC later when needed.
    The pbm i have is am not able to duplicate dat attached movie clips. Can anybody luk at the attachments and tell me y?
    See the attachement which is having XML file and ImgLoader.fla.

    Note: If i duplicate any other MC it is working but not with the dynamic one.
    Any suggestion wud be greatly welcome.....
    Attached Files Attached Files

  2. #2
    FK Slacker
    Join Date
    Jun 2000
    Location
    vancouver
    Posts
    3,208
    You can't duplicate a clip that has had an image dynamically loaded into it - you need to reload the image for each clip you want to create...

    From the docs:

    Duplicated movie clips always start playing at Frame 1, no matter what frame the original movie clip is on when the duplicateMovieClip() method is called. Variables in the parent movie clip are not copied into the duplicate movie clip. Movie clips that have been created using duplicateMovieClip() are not duplicated if you call duplicateMovieClip() on their parent. If the parent movie clip is deleted, the duplicate movie clip is also deleted.If you have loaded a movie clip using MovieClip.loadMovie() or the MovieClipLoader class, the contents of the SWF file are not duplicated. This means that you cannot save bandwidth by loading a JPEG or SWF file and then duplicating the movie clip.

    K.

  3. #3
    flip-flopper scottPadgett's Avatar
    Join Date
    Jan 2005
    Location
    Boston
    Posts
    425

    does anyone know a way around this?

    Without embedding the images that you need to load directly into the SWF library?

    I need to allow a client to specify the images to load and subesquently be duplicated from an XML file accompanying a map with over 400 properties. I need to load 16 images once and dupe them 400 times in the Flash player. If I have to resend requests for every image 400 times, I think that's going to cause some major problems.

    As I understand it even if the images have been called into cache, Flash will reload them at every call, thus exploding memory requirements for the SWF. Am I right?
    :: scott ::

  4. #4
    Member
    Join Date
    Jan 2005
    Location
    Bangalore
    Posts
    93
    Hi Scott,
    Literally u can not duplicate a MovieClip which contains images that are loaded dynamically. But it can be possible thru some work around. I had the same requirement dat i need to download the images only one time and then i need to duplicate them whenever needed.
    Hope u are using Flash version 8 or more....
    Use bitmapPainting in Flash 8 and above.
    I have done using beginBitmapFill() method in MovieClip
    Have image as a Bitmap data and then u can paint the same bitmapData(images) as many times in fraction of seconds. This will increase the performance by avoiding reloading of images again and again....

  5. #5
    Getting There! bitsk308's Avatar
    Join Date
    Jul 2000
    Location
    Phoenix, AZ
    Posts
    427
    Scott, I'm not sure if this is what you're asking, but I don't believe flash requests images from the server again if they exist in cache. I use 'Charles' on the mac to track all requests and responses going in and out of my browser. On a project of mine that loads images multiple times to get the same effect you're trying to get, I only have one out going request for the image. I'm only loading four images, each only two times, but there is definitely only once call per image.

    Don't know if that's what you're after or not, but may it helps.

  6. #6
    Junior Member
    Join Date
    Feb 2006
    Posts
    12
    im having real problems with this too. it definitely seems to be reloading the image each time i call for it, instead of grabbing a cached version.

    i've tried the bitmap stuff to no avail. i have no idea how to get it working and have been at it for so many hours.

    marudhappan, can you post the code you used? just when i think i have it working, it wont rewrite in another part of the movie (im trying to use globals for everything).

    any help would be appreciated. im on a super tight deadline for this (hence still being at work at 1am).

    thanks in advance to whoever can end this headache for me.

  7. #7
    Senior Member
    Join Date
    Aug 2000
    Location
    Montréal
    Posts
    14,141

  8. #8
    Junior Member
    Join Date
    Feb 2006
    Posts
    12
    seriously? 3 lines of code? man, last night sucked for absolutely nothing.

    either way, thanks a ton gparis. you definitely saved me a ton of headaches today. i just did it on a test_mc and it worked perfectly. if you're ever in rochester, i owe you a beer.

  9. #9
    flip-flopper scottPadgett's Avatar
    Join Date
    Jan 2005
    Location
    Boston
    Posts
    425
    brilliant. that's EXACTLY what i need to do.

    thanks so much gparis, and everyone else for input, too.
    :: scott ::

  10. #10
    flip-flopper scottPadgett's Avatar
    Join Date
    Jan 2005
    Location
    Boston
    Posts
    425
    So actually, i'm now looking at needing to be able to duplicate an swf that's loaded dynamically as opposed to a bitmap. I find that if the swf i need to dupe contains the necessary art in a linked movieclip that is set to export for Actionscript in frame one, i can load that swf into a MC in the main swf one time, and then attach the linked clip it contains many times to get the duplicated art i need without having to reload the swf. This definitely works if I'm attaching that clip as a child of the movieclip into which I loaded the swf initially. But if I try to attach it into a clip that is not under the hierarchy of the movieclip where i first loaded the swf, it doesn't seem to work.

    Does anyone know if this is because a movieclip is only available to be attached underneath the swf that contains the asset that's set with linkage?

    Am I making sense here? I'm trying to figure out if you can load an swf that contains a linked movieclip into a movie and then attach that linked movieclip anywhere in that movie, or if you can only attach it successfully underneath the loaded swf in the hierarchy of the movie--not above it.

    Help?
    :: scott ::

  11. #11
    flip-flopper scottPadgett's Avatar
    Join Date
    Jan 2005
    Location
    Boston
    Posts
    425

    method doesn't preserve transparency?

    Hi gparis,

    I am using the method for attaching the bitmap as is outlined in the .fla at that link that you posted. I have one problem, though. Even if you load the bitmapData with transparency set to true (which happens default anyway), and load a transparent png with the intention of the bg showing through, when you attach the bitmap to another clip, the transparency is not preserved in this new instance. It turns it white. Do you know a way around this by chance?

    Many thanks.
    :: scott ::

  12. #12
    Senior Member
    Join Date
    Aug 2000
    Location
    Montréal
    Posts
    14,141
    in the example .fla, you'd need to change this line:
    PHP Code:
    var visuals = new flash.display.BitmapData(from._widthfrom._height); 
    for:

    PHP Code:
    var visuals = new flash.display.BitmapData(from._widthfrom._heighttrue0x00000000); 
    more info on the BitmapData Class in the liveDocs (link in my footer). It's worth a good read!

    gparis

  13. #13
    flip-flopper scottPadgett's Avatar
    Join Date
    Jan 2005
    Location
    Boston
    Posts
    425
    whoa, what's that last parameter. didn't find that in the Flash docs. but good point about the live docs, too. i should be checking out comments on the documentation. i see you include the alpha channel in the color value. this is a big help. should save me from this less desirable hack i have implemented.

    thanks so much!
    :: scott ::

  14. #14
    Senior Member
    Join Date
    Aug 2000
    Location
    Montréal
    Posts
    14,141
    last parameter is the fillColor:
    BitmapData constructor
    public BitmapData(width:Number, height:Number, [transparent:Boolean], [fillColor:Number])
    Read more in the BitmapData constructor page

    gparis

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