color picker

  • makhan
  • Novice
  • Novice
  • makhan
  • Posts: 31

Post 3+ Months Ago

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
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13502
  • Loc: Florida

Post 3+ Months Ago

Flash 8 version done with a BitmapData object.
  • makhan
  • Novice
  • Novice
  • makhan
  • Posts: 31

Post 3+ Months Ago

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
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13502
  • Loc: Florida

Post 3+ Months Ago

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);
  • makhan
  • Novice
  • Novice
  • makhan
  • Posts: 31

Post 3+ Months Ago

Thanks man, can you also give me a simple code where I can load image using loadMovie into bitmapdata .
  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13502
  • Loc: Florida

Post 3+ Months Ago

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);

Post Information

  • Total Posts in this topic: 6 posts
  • Users browsing this forum: No registered users and 14 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
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.