Using loadmovie

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

Post 3+ Months Ago

Hi I want to use loadMovie function to load image into this movie which picks colors and display them in a small box. but when I do that using loadMovie it doesn't pick color as it does when I load image from the library

Example taken from here http://www.flashvalley.com/fv_tutorials ... _getPixel/


Code: [ Select ]

import flash.display.BitmapData;

linkageId = "landscape";
myBitmapData = BitmapData.loadBitmap(linkageId);

mc = this.createEmptyMovieClip("mc", 0);
mc.attachBitmap(myBitmapData, 0);

selectedColor.swapDepths(_root.getNextHighestDepth());
newColor = new Color(selectedColor.sample);

onMouseMove = function(){
myNewColor = "0x" + myBitmapData.getPixel(_xmouse,_ymouse).toString(16);
newColor.setRGB(myNewColor);
selectedColor.colorValue.text = myNewColor;
}
  1. import flash.display.BitmapData;
  2. linkageId = "landscape";
  3. myBitmapData = BitmapData.loadBitmap(linkageId);
  4. mc = this.createEmptyMovieClip("mc", 0);
  5. mc.attachBitmap(myBitmapData, 0);
  6. selectedColor.swapDepths(_root.getNextHighestDepth());
  7. newColor = new Color(selectedColor.sample);
  8. onMouseMove = function(){
  9. myNewColor = "0x" + myBitmapData.getPixel(_xmouse,_ymouse).toString(16);
  10. newColor.setRGB(myNewColor);
  11. selectedColor.colorValue.text = myNewColor;
  12. }
  • graphixboy
  • Control + Z
  • Mastermind
  • User avatar
  • Posts: 1828
  • Loc: In the Great White North

Post 3+ Months Ago

You need to convert your movieclip into the bitmap data class format. Most people use a combo of the getPixel and Draw functions

Here's an example using a snapshot of streaming video but you should be able to do the same thing with a movieclip.
  • makhan
  • Novice
  • Novice
  • makhan
  • Posts: 31

Post 3+ Months Ago

Thanks man for the help. Can you help me with the code here. I am new to actionscript and don't have much idea. I would really appreciate it
  • graphixboy
  • Control + Z
  • Mastermind
  • User avatar
  • Posts: 1828
  • Loc: In the Great White North

Post 3+ Months Ago

basically the problem is in these two lines with the loadBitmap() Its actually expecting an image here.

Code: [ Select ]
linkageId = "landscape";
myBitmapData = BitmapData.loadBitmap(linkageId);
  1. linkageId = "landscape";
  2. myBitmapData = BitmapData.loadBitmap(linkageId);


To get this to work with a movieclip try:

Make a movieclip on the stage (I think for this to work it should only be one frame) Delete the mc from the stage and then find it in the library. Right click on the movieclip in the library and select "Linkage..." Check the box that says "Export for ActionScript" and give the clip a linkage name like "myClip" in the identifier field. Click ok.

now back to the script... replace the above 2 lines of script (leave the rest as it is) with this (where "myClip" is the linkage name you provided in the step above)

Code: [ Select ]
var myMC = this.attachMovie("myClip","myClip_mc",this.getNextHighestDepth());
myBitmapData = new BitmapData(myMC._width, myMC._height);
myBitmapData.draw(myMC);
myMC.removeMovieClip();
  1. var myMC = this.attachMovie("myClip","myClip_mc",this.getNextHighestDepth());
  2. myBitmapData = new BitmapData(myMC._width, myMC._height);
  3. myBitmapData.draw(myMC);
  4. myMC.removeMovieClip();


what your doing is:
line 1: attaching the movie clip you created to the stage
line 2: creating a new BitmapData object with the same sizes as your your mc
line 3: turning your mc into bitmap data so you can use it in the object
line 4: deleting the clip you attached because you don't need it any more.
  • makhan
  • Novice
  • Novice
  • makhan
  • Posts: 31

Post 3+ Months Ago

Thankss man , but where I would load image from the loadMovie method. Becuase i don't want to load image from library( I can load from library and it works fine but it doen't work when I load it from loadMovie)
  • graphixboy
  • Control + Z
  • Mastermind
  • User avatar
  • Posts: 1828
  • Loc: In the Great White North

Post 3+ Months Ago

Well the moviecliploader solution that I thought would work keeps crashing the flash player (not sure why at the moment but it seems to be a scope issue) I'll tweak it a bit more tomorrow and get back to you.
  • makhan
  • Novice
  • Novice
  • makhan
  • Posts: 31

Post 3+ Months Ago

Thanks man I really appreciate your help.

Post Information

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

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