color picker

  • makhan
  • Novice
  • Novice
  • No Avatar
  • Joined: Jun 02, 2007
  • Posts: 31
  • Status: Offline

Post June 30th, 2007, 2:48 am

I want to load an image into my swf using loadmovie and be able to pick color where i click on the image. Can someone please help me with the code for that.
Thanks
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post June 30th, 2007, 2:48 am

  • joebert
  • Sledgehammer
  • Genius
  • No Avatar
  • Joined: Feb 10, 2004
  • Posts: 13455
  • Loc: Florida
  • Status: Offline

Post June 30th, 2007, 4:21 am

Flash 8 version done with a BitmapData object.
Strong with this one, the sudo is.
  • makhan
  • Novice
  • Novice
  • No Avatar
  • Joined: Jun 02, 2007
  • Posts: 31
  • Status: Offline

Post June 30th, 2007, 6:29 am

Thanks joebert, your application load image from the library, I want to load image from any address by using loadMovie method. Can you please guide me how I can do that?


Thanks
  • joebert
  • Sledgehammer
  • Genius
  • No Avatar
  • Joined: Feb 10, 2004
  • Posts: 13455
  • Loc: Florida
  • Status: Offline

Post June 30th, 2007, 7:29 am

The path to the MovieClip that holds the image from _root is
Code: [ Select ]
_root.picker.subject

The BitmapData that is sampled from is
Code: [ Select ]
_root.picker.pbd


On the first frames' actions of the picker MovieClip, is where all of that is setup.
The event handlers attached to the subject MovieClip will need to be reassigned once a new image is loaded into it.

Setup a MovieClipLoader to load a new image into the subject MovieClip, then use the BitmapDatas' draw method to copy the pixel information from the MovieClip to the BitmapData object within the MovieClipLoaders' onLoadInit event handler (along with reassigning subjects event handlers to subject).
Code: [ Select ]
_root.picker.pbd.draw(_root.picker.subject);
Strong with this one, the sudo is.
  • makhan
  • Novice
  • Novice
  • No Avatar
  • Joined: Jun 02, 2007
  • Posts: 31
  • Status: Offline

Post June 30th, 2007, 10:19 am

Thanks man, can you also give me a simple code where I can load image using loadMovie into bitmapdata .
  • joebert
  • Sledgehammer
  • Genius
  • No Avatar
  • Joined: Feb 10, 2004
  • Posts: 13455
  • Loc: Florida
  • Status: Offline

Post June 30th, 2007, 11:33 am

Code: [ Select ]
// This fires once the MovieClipLoader has loaded the image into the MovieClip
var onLoadInit:Function = function(targ:MovieClip){

  // Create a new BitmapData object the width/height of the new image
  targ._parent.pbd = new flash.display.BitmapData(targ._width, targ._height);

  // Copy the pixels from the MovieClip to the BitmapData
  targ._parent.pbd.draw(targ);



  // Find the lines that assign events to "subject" within
  // the picker MovieClip & reassign them here.
  // ie - targ.onPress = function()...
}

// Create a MovieClipLoader
var mcl:MovieClipLoader = new MovieClipLoader();

// Register this MovieClips functions as event handlers for the MCLoader
// Any function named the same as a MCLoaders events (line the one above) will be fired as they happen in the MCLoader
mcl.addListener(this);

// Load the new Image
mcl.loadClip("myimage.jpg", _root.picker.subject);
  1. // This fires once the MovieClipLoader has loaded the image into the MovieClip
  2. var onLoadInit:Function = function(targ:MovieClip){
  3.   // Create a new BitmapData object the width/height of the new image
  4.   targ._parent.pbd = new flash.display.BitmapData(targ._width, targ._height);
  5.   // Copy the pixels from the MovieClip to the BitmapData
  6.   targ._parent.pbd.draw(targ);
  7.   // Find the lines that assign events to "subject" within
  8.   // the picker MovieClip & reassign them here.
  9.   // ie - targ.onPress = function()...
  10. }
  11. // Create a MovieClipLoader
  12. var mcl:MovieClipLoader = new MovieClipLoader();
  13. // Register this MovieClips functions as event handlers for the MCLoader
  14. // Any function named the same as a MCLoaders events (line the one above) will be fired as they happen in the MCLoader
  15. mcl.addListener(this);
  16. // Load the new Image
  17. mcl.loadClip("myimage.jpg", _root.picker.subject);
Strong with this one, the sudo is.

Post Information

  • Total Posts in this topic: 6 posts
  • Users browsing this forum: No registered users and 95 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.