Jump to content


Duplicating an externally loaded JPG


  • You cannot reply to this topic
3 replies to this topic

#1 faulk

    Young Padawan

  • Members
  • Pip
  • 72 posts
  • Gender:Male
  • Location:Moosup, CT
  • Interests:Web design<br />Music<br />Audio engineering<br />Baseball (red sox!)<br />Snowboarding<br />Video production<br />Web app development

Posted 23 July 2007 - 05:00 PM

I've been working on this problem all day and I can't seem to get anything to work..

I would like to create a movieclip, load an external JPG into it and then duplicate the movieclip. When that is done I would like to do some masking, but that's for after I get part one done.

Here's what I've got (all in frame 1 actions):

//create an empty movieclip
this.createEmptyMovieClip("container", 1);

//load the JPG
var loader:MovieClipLoader = new MovieClipLoader();
var loadListener:Object = new Object();

loadListener.onLoadInit = function():Void {
	 duplicateMovieClip(container, "newContainer", 2);
	 trace(newContainer); //returns undefined
}

loader.addListener(loadListener);
loader.loadClip("http://www.helpexamples.com/flash/images/image1.jpg", "container");

If you throw that into a new flash document, it should return the same thing (I would hope). I've tried doing it several different ways, but the end result is that the 'newContainer' is never created where as everything else works perfect.

If anyone can help I would greatly appreciate it. :biggrin:

#2 Pax

    P2L Jedi

  • Members
  • PipPipPip
  • 911 posts
  • Gender:Male
  • Location:Windsor, ON, Canada

Posted 23 July 2007 - 09:42 PM

//create an empty movieclip
this.createEmptyMovieClip("container", 1);

//load the JPG
var loader:MovieClipLoader = new MovieClipLoader();
var loadListener:Object = new Object();

loadListener.onLoadInit = function(target_mc:MovieClip):Void {
	 duplicateMovieClip(target_mc, "newContainer", 2);
	 trace(target_mc.newContainer); //should return something
}

loader.addListener(loadListener);
loader.loadClip("http://www.helpexamples.com/flash/images/image1.jpg", this.container);

the target_mc argument should be equal to the target movieclip that you pass into the MCL's loadClip method. Also, you need to pass in an object to the loadClip method rather than a string. I replaced "container" with this.container, but you may need to change that to make it work. Give that a whirl and see if it'll work. My flash is currently screwed up, so I can't make anything to test :biggrin:

#3 faulk

    Young Padawan

  • Members
  • Pip
  • 72 posts
  • Gender:Male
  • Location:Moosup, CT
  • Interests:Web design<br />Music<br />Audio engineering<br />Baseball (red sox!)<br />Snowboarding<br />Video production<br />Web app development

Posted 24 July 2007 - 09:47 PM

this is actually a more complex problem than I thought, I found the answer on another website after doing a little more Googling:

This website can explain it much better than I can, however it did solve my problem, thank you for the help though! :huh:

#4 Pax

    P2L Jedi

  • Members
  • PipPipPip
  • 911 posts
  • Gender:Male
  • Location:Windsor, ON, Canada

Posted 25 July 2007 - 08:07 AM

Ah, I was wondering about suggesting that, but figured that duplicate movie clip would work for you. Using the BitmapData is very useful when you want to copy the data of the bitmap from one movie clip to a non-child movie clip.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users