ࡱ> BRoot Entry p|YrRASH1< *ContentsEd)Page 1n:Symbol 21i9 CASDFGHIJKLMNOPQRUVijklmopqrstuvwxyz{|}~Root Entry p|YrRASH`= *Contentsd)Page 1n:Symbol 21i9 C !"#$%&'()*+,-.ASDopqrstuvwxyz{|}~  CDocumentPage Page 1Scene 1N<eW< Symbol 21 close_buttonfV<pO' E܀PpC#)5I? CPicShaperUO+++w9z%T4Y?kExNT;x4<4)+1'5C+++$.$><pO' E܀PpC#)5I??Layer 7f CPicPage CPicLayer CPicFrame CPicShapeP?Layer 1OCPicPage CPicLayer CPicFrame CPicShapeHs@ 0`0@0?Layer 1OCPicPage CPicLayer CPicFrame@00P0@?frameOCPicPage CPicLayer CPicFrame CPicShapes 000 ?< 000 ?<s 000 ?<s 000 ?Layer 1OCPicPage CPicLayer CPicFrame CPicButtonon(rollOver) { _root.attachMovie("hilite", "hilite", 10); _root.hilite._x = _x; _root.hilite._y = _y; } on(rollOut) { removeMovieClip("_root.hilite"); } on(press) { mycolor.setRGB(0xFFFF00); //var cur_color = new Color(_root.cursor); _root.controller.cur_color.setRGB(default_color); } on(release,releaseOutside) { mycolor.setRGB(default_color); _root.controller.paint_color = default_color; } ? backgroundOCPicPage CPicLayer CPicFrame CPicSprite,,Pn[,,2 ?Layer 1OCPicPage CPicLayer CPicFrame CPicShape@s 000 ?peedSingleISDN0&PublishRNWKProperties::singleRateAudio0PublishQTProperties::Width200$PublishPNGProperties::OptimizeColors1PublishHtmlProperties::Units2Vector::Generator Command%PublishRNWKProperties::mediaCopyright 2000#PublishRNWKProperties::flashBitRate1200PublishGifProperties::Smooth1&PublishFormatProperties::flashFileName test9.swf%PublishFormatProperties::projectorMac0!PublishRNWKProperties::exportSMIL1 PublishRNWKProperties::speed384K0"PublishRNWKProperties::exportAudio1"PublishGifProperties::DitherOptionPublishHtmlProperties::Quality4(PublishHtmlProperties::VerticalAlignment1Vector::Generator Height160$PublishFormatProperties::pngFileName test9.pngPublishFormatProperties::html1Vector::Preview as GIF0'PublishRNWKProperties::mediaDescription"PublishPNGProperties::FilterOption!PublishHtmlProperties::DeviceFont0Vector::Generator ColorVector::Override Sounds0PublishQTProperties::Flatten1PublishJpegProperties::DPI4718592PublishPNGProperties::BitDepth24-bit with AlphaounterTimes New Roman(?Layer 1OCPicPage CPicLayer CPicFrame CPicSpritexxdCPicTextdH xTimes New Roman(This Flash movie clip creates a BMP file (24bit Windows BitMap) that depicts what the user has painted on the canvas area. The user can paint in the 3 basic colors and create 40x30 bitmaps. All binary processing involved is done within Flash and the resulting data is sent to the server as a URI encoded byte-stream. The server just saves the data in a .bmp file and sends it to the user. The process is demanding and teeters on the border of what can or should be done using Flash. Check the accompanying tutorixTimes New Roman(al (on the same page) for implementation details. The fla source is available for download at the bottom of the page. Coded by Fotios (http://fotios.cc/)?Layer 1O CPicButtonVqrp KK# 2on (release) { removeMovieClip(_root.help); }?buttonOOCPicPage CPicLayer CPicFrame0 0@0?Layer 1OCPicPage CPicLayer CPicFrame??? CPicShapes0@00?Layer 1OCPicPage CPicLayer CPicFrameCPicText"K(Tw Cen MT Condensed Extra Bold"(X?Layer 1OPublishPNGProperties::Smooth1"PublishGifProperties::DitherSolids0PublishGifProperties::Interlace0"PublishHtmlProperties::DisplayMenu0*PublishHtmlProperties::HorizontalAlignment1*PublishFormatProperties::generatorFileName test9.swtPublishFormatProperties::gif0Vector::Quality50Vector::Protect0Vector::Template0$PublishRNWKProperties::mediaKeywords!PublishRNWKProperties::mediaTitlePublishRNWKProperties::speed28K1PublishGifProperties::Loop1PublishGifProperties::Width200#PublishFormatProperties::qtFileName test9.mov$PublishRNWKProperties::speedDualISDN0$PublishRNWKProperties::realVideoRate100000PublishJpegProperties::Quality80"PublishPNGProperties::DitherOption#PublishGifProperties::PaletteOption#PublishGifProperties::MatchMovieDim1Vector::Generator LoadOrderVector::Generator Width200PublishFormatProperties::flash1$PublishJpegProperties::MatchMovieDim1#PublishPNGProperties::PaletteOption#PublishPNGProperties::MatchMovieDim1PublishHtmlProperties::Align0-PublishFormatProperties::projectorWinFileName test9.exe#PublishQTProperties::PlayEveryFrame0"PublishJpegProperties::Progressive0"PublishPNGProperties::DitherSolids0PublishHtmlProperties::Height100PublishHtmlProperties::Width100%PublishFormatProperties::jpegFileName test9.jpgVector::Debugging PasswordVector::Omit Trace Actions1PublishJpegProperties::Size0PublishPNGProperties::Interlace0PublishGifProperties::Height160'PublishHtmlProperties::TemplateFileName/D:\PROGRA~1\MACROM~1\FLASH5~1\Html\Default.html!PublishHtmlProperties::WindowMode0-PublishFormatProperties::projectorMacFileName test9.hqxPublishFormatProperties::rnwk0PublishFormatProperties::png0Vector::TopDown0PublishRNWKProperties::speed56K1PublishQTProperties::Height160%PublishPNGProperties::RemoveGradients0PublishGifProperties::MaxColors255'PublishGifProperties::TransparentOptionPublishGifProperties::LoopCountVector::Report0"PublishFormatProperties::generator"PublishRNWKProperties::audioFormat0$PublishGifProperties::OptimizeColors1PublishFormatProperties::qt0Vector::Event Format0Vector::Stream Compress7Vector::Version5 PublishRNWKProperties::speed512K0PublishJpegProperties::Height160PublishPNGProperties::Height160PublishPNGProperties::Width200%PublishGifProperties::RemoveGradients0PublishHtmlProperties::Scale0Vector::Event Compress7"PublishRNWKProperties::mediaAuthor(PublishRNWKProperties::speedCorporateLAN0&PublishRNWKProperties::showBitrateDlog1"PublishRNWKProperties::exportFlash1PublishQTProperties::Looping0*PublishQTProperties::UseQTSoundCompression0PublishJpegProperties::Width200!PublishPNGProperties::PaletteName!PublishPNGProperties::Transparent0&PublishGifProperties::TransparentAlpha128PublishGifProperties::Animated0$PublishFormatProperties::gifFileName test9.gifVector::Stream Format0PropSheet::ActiveTab1620"PublishQTProperties::PausedAtStart0%PublishQTProperties::ControllerOption0PublishPNGProperties::MaxColors255Vector::MatchMovieDim1Vector::Generator FPS12%PublishFormatProperties::rnwkFileName test9.smil%PublishFormatProperties::projectorWin0%PublishFormatProperties::defaultNames1 CColorDef3PfP0PHP`Px333(3f<03CH3F`3Hxf0f30ff(0f5Hf<`f@x3330333xf3d03]H3Z`3Xx3333303f3PPH33Px`33Px33Pf30f33PHff3(PHf3<x`f3Cxf3Ffff`f03f0ffx0fkHfd`f`x3f033fPH3ffxPH3fdx`3f]x3fZff0f3fPHfff`ffP0xffPxffPH3HfHxH̙n`hx3H33x`3fx`3xx`3̙kx3dfHf3x`ff0xfx0xf̙dxf]`3`f``x`px3`33x3fx3x3xx3nf`f3xffxfxfxxfkx3xfxxxxx3x333f333xfxf3fffffxxH3 HfH(H2`8x`3 `f`̙`(`0xx3xfxx x(xPx3H33x`f3x`3(x`35x3<3`33xf3 x̙3x3(x323x33f3 333(xfH3fx`ff0xf(0xf<xfCf`3fxffx̙fxf(xf5fx3ffff ff((xH3x`f0x̙PPP`3xfx̙P̙(P<x3f̙(xx`3xfxPxPd`3xfx̙PPx3f(xx3fxx3f̙xx3ff`zf*]Pn"PublishQTProperties::QTSndSettingsCQTAudioSettings///////////////////////////////////////////////////////////// //Push 4 bytes (1 DWord) //in endian order function pushDWord(arr, val, endian) { var B = new Array(); //Byte array - LSB is B[0] B[0] = Math.floor(val % 256); B[1] = Math.floor(val / 256); if (B[1] == 256) B[1] = 0; val = Math.floor(val / 65536); B[2] = Math.floor(val % 256); B[3] = Math.floor(val / 256) //Order bytes in Big //or Lil endian order if (endian) { i = 3; while(i > -1) arr.push(B[i--]); } else { i = 0; while(i < 4) arr.push(B[i++]); } } ////////////////////////////////////////////////////////////////////////////////////////////// //Pass width and height of the bmp, as well as the array containing the pixel color values //of the image. Then this functon will encode this data in an appropriate 24bit BMP envelope //and push the byte values representing the resulting BMP file in the passed output array. //The BMP is a simple uncompressed 24bit color Windows BMP (no color table indexing is used) // //Assumption: All bitmap scanlines are of equal size function create24bitBMP(width, height, inarr, outarr) { outarr.length = 0; //reset output array //Determine number of padding bytes for each scanline var padnum = Math.floor( (width * 3) % 4 ); var inarrsize = inarr.length; var datasize = inarrsize + height * padnum; //pixel bytes plus padding bytes //Push the 'BM' identifier byte sequence //since this is a Windows BMP outarr.push(66); //'B' outarr.push(77); //'M' //filesize -> 4 bytes (full header size + pixel data) var filesize = datasize + 54; pushDWord(outarr, filesize, 0); //reserved -> 4 bytes - zero pushDWord(outarr, 0, 0); //bmp data offset -> 4 bytes - file start to start of bmp data (54) pushDWord(outarr, 54, 0); //bmp header size -> 4 bytes - / 28h - Windows 3.1x, 95, NT, / 0Ch - OS/2 1.x / F0h - OS/2 2.x pushDWord(outarr, 40, 0); //width -> 4 bytes pushDWord(outarr, width, 0); //height -> 4 bytes pushDWord(outarr, height, 0); //planes -> 2 bytes (use just 1 plane) pushWord(outarr, 1, 0); //bits per pixel -> 2 bytes (24 for 24-bit bmp) pushWord(outarr, 24, 0); //compression spec -> 4 bytes (0 for no compression) pushDWord(outarr, 0, 0); //bmp data size -> 4 bytes (size of passed pixel array, pushDWord(outarr, datasize, 0); //HRes -> 4 bytes - pixels per meter (usually 3780) pushDWord(outarr, 3780, 0); //VRes -> 4 bytes - pixels per meter (usually 3780) pushDWord(outarr, 3780, 0); //Number of Colors in color table-> 4 bytes //All zero, since 24bit bmps do not use color table (palette) pushDWord(outarr, 0, 0); //Important Colors -> 4 bytes (all zero, since we use no palette) pushDWord(outarr, 0, 0); //Palette - Pallete colors are expressed by RGBByteQuads //There is nothing here since we use no palette in 24bit BMPs //BMP pixel data. 3 bytes per pixel (RGB Byte Triad) since this is a 24bit BMP). //Pad end of each scanline to next 32 bit boundary if needed (scanlines must be DWORD aligned) //RGB triad bytes should be Lil-Endian aligned. This means that the B byte is stored //in the lower address and the R byte in the higher var i=0, j=0, k; while(i < inarrsize) { outarr.push(inarr[i++]); j++; //if we reach the end of a scanline if (j/3 == width) { if (padnum) for(k=0;k@ABCEFGHIJKLMNOPRSTUVWXYZ[\]_`abcefghiklmnpqrstuwxyz{}~Symbol 19Symbol 18 Symbol 17|/Symbol 16 v^Layer 1OCPicPage CPicLayer CPicFramepR45 :;Svu?Layer 1OCPicPage CPicLayer CPicFrame CPicShape fs00`0@?Pfunction sendData() { loadVariables("default.asp", _root.holder, "POST"); }Layer 1OCPicPage CPicLayer CPicFrameCPicText((Ic  CDocumentPage Page 1Scene 1N<dW< Symbol 21 close_buttonfV min_y; y--) { for(x = min_x; x < max_x; x++) { //i++; //if there is no stored reference in matrix //for current x,y coords then //push the white color (nothing painted here) if (matrix["x" + x + "y" + y] == null) { arr.push(0xFF); arr.push(0xFF); arr.push(0xFF); } else { acolor = matrix["x" + x + "y" + y].acolor; if (acolor == 0xFF0000) { arr.push(0x00); arr.push(0x00); arr.push(0xFF); } else if (acolor == 0x00FF00) { arr.push(0x00); arr.push(0xFF); arr.push(0x00); } else if (acolor == 0x0000FF) { arr.push(0xFF); arr.push(0x00); arr.push(0x00); } } }//for end }//for end //trace("number of scanned pixels = " + i); } actionsOds and sends the URI encoded string //of the generated BMP's byte values. //The loadVariables() call is in //the first frame of the clip //in the sendData() function onClipEvent(load) { var bmp_string = new String(); //will hold the URI encoded BMP //A value of end=1 will be set by return //of the loadVariables() call var end = 0; Symbol 15oSymbol 13j*Symbol 11dESymbol 10^P  !"#$%&'()*+,-./01245678:;<=>@ABCEFGHIJKLMNOPRSTUVWXYZ[\]_`abcefghiklmnpqrstuwxyz{}~Layer 1OCPicPage CPicLayer CPicFramepR45 :;Svu?Layer 1OCPicPage CPicLayer CPicFrame CPicShape fs00`0@?Pfunction sendData() { loadVariables("saveURI.asp", _root.holder, "POST"); }Layer 1OCPicPage CPicLayer CPicFrameCPicText((Ic  CDocumentPage Page 1Scene 1N<eW< Symbol 21 close_buttonfV min_x && _root._xmouse < max_x && _root._ymouse > min_y && _root._ymouse < max_y ) { mx = Math.floor(_root._xmouse); my = Math.floor(_root._ymouse); mxs = mx.toString(); mys = my.toString(); //If paint over occurs, remove old pixel if (matrix["x" + mxs + "y" + mys] != null) removeMovieClip(matrix["x" + mxs + "y" + mys]); _root.attachMovie("pixel", "pixel" + i, i); var pixelcolor = new Color("_root.pixel" + i); pixelcolor.setRGB(paint_color); //record pixel's color in the pixel mc itself _root["pixel"+i].acolor = paint_color; _root["pixel"+i]._x = mx; _root["pixel"+i]._y = my; matrix["x" + mxs + "y" + mys] = _root["pixel"+i]; i++;//increment pixel movie clip depth } //If mouse cursor is on top the canvas area do stuff if ( _root._xmouse > min_x && _root._xmouse < max_x && _root._ymouse > min_y && _root._ymouse < max_y ) { paint = true; Mouse.hide(); _root.cursor._x = _root._xmouse; _root.cursor._y = _root._ymouse; startDrag(_root.cursor); } else { paint = false; stopDrag(); _root.cursor._x = -62; _root.cursor._y = -62; Mouse.show() } } onClipEvent(mouseDown) { down = 1; } onClipEvent(mouseUp) { down = 0; } controller(( cursorH@H@g//This clip holds and sends the URI encoded string //of the generated BMP's byte values. //The loadVariables() call is in //the first frame of the clip //in the sendData() function onClipEvent(load) { var bmp_string = new String(); //will hold the URI encoded BMP //A value of end=1 will be set by return //of the loadVariables() call var end = 0; //the url value will be set by the loadVariables() return //and will point to the BMP on the server var url = ""; } onClipEvent(enterFrame) { if (end) { end = 0; _root.status = "BMP successfully sent"; //show the generated BMP, that is now stored on the server, in a new window getURL("javascript:void(window.open('" + url + "','bmp','width=40,height=30,status=no,menubar=no,scrollbars=yes,screenX=0,left=0,screenY=0,top=0,left=0'));"); } }holder? backgroundO CPicButtonnr on (press) { status = "Creating. Please wait..."; } on (release) { status = "Scanning canvas. Please wait..."; //Scan paint area. Paint area is defined by the dimensions of the 'canvas' clip scanPixelsBottom( _root.controller.matrix, pixeldata, _root.canvas._x, _root.canvas._x + _root.canvas._width, _root.canvas._y, _root.canvas._y + _root.canvas._height ); status = "Creating BMP data. Please Wait..."; create24bitBMP(_root.canvas._width, _root.canvas._height, pixeldata, bmp); status = "Encoding byte-stream. Please Wait..."; _root.holder.bmp_string = fullURIEncode(bmp); status = "Sending byte-stream..."; _root.holder.sendData(); } Po[onClipEvent(load) { var default_color = 0xFF0000; var mycolor = new Color(this); mycolor.setRGB(default_color); } redPo[onClipEvent(load) { var default_color = 0x00FF00; var mycolor = new Color(this); mycolor.setRGB(default_color); } green4Po[4onClipEvent(load) { var default_color = 0x0000FF; var mycolor = new Color(this); mycolor.setRGB(default_color); } blue nr Bon(release) { getURL("javascript:self.location.reload();"); } nr ion (release) { attachMovie("help", "help", 32767); _root.help._x = 10; _root.help._y = 10; }CPicText $Times New Roman(Help3Times New Roman(Note:Times New Romanf( BTimes New Roman333(If you get a message asking you whether to stop the script or not,Times New Roman333( just say 'no'?buttons3  Times New Roman(Create BMP ZJTimes New Roman(Resetj "statusTimes New Roman(Readyj  TextField3Times New Roman(Statusi TextField3Times New Roman(HitsN@ N@ >onClipEvent(load) { loadVariables("counter.asp", this); }counter?labelsOxxcanvasZ |Times New Roman333(Flash Bitmap Creator?canvasOO?(//Assumption: 1 Word = 2 bytes, 1 DWord = 4 bytes //Convention: endian = 1 means Big Endian, endian = 0 means Lil endian var pixeldata = new Array(); //holds raw pixel color values (3 numbers for each color - RGB) var bmp = new Array(); //holds the values representing the bytes of the bitmap ////////////////////////////////////////////////////////////////////////////////////////////// //This function will return a string that represents the values //in the passed array (arr) in fully URI encoded form. //Values are assumed to represent individual byte values (0-255) function fullURIEncode(arr) { var i; var len = arr.length; var uri; var d1, d2; var val; var hexdigit = new Array("A","B","C","D","E","F"); for (i = 0; i < len; i++) { val = arr[i]; d1 = Math.floor(val / 16); d2 = Math.floor(val % 16); if (d1 > 9) d1 = hexdigit[d1 - 10] if (d2 > 9) d2 = hexdigit[d2 - 10] uri += "%" + d1 + d2; } return uri; } ////////////////////////////////////////////////////////////////////////////////////////////// //This function will push a value beetween //0 and 255 in the passed array, as a single byte value function pushByte(arr, val) { arr.push(val); } ////////////////////////////////////////////////////////////////////////////////////////////// //This function will push a value between 0 and 65535 in the passed array //as 2 consecutive byte values (representing a full word value) in endian order function pushWord(arr, val, endian) { var MSB, LSB; LSB = Math.floor(val % 256); MSB = Math.floor(val / 256); //Order bytes in big //or lil endian order if (endian) { arr.push(MSB); arr.push(LSB); } else { arr.push(LSB); arr.push(MSB); } } ////////////////////////////////////////////////////////////////////////////////////////////// //Push 4 bytes (1 DWord) //in endian order function pushDWord(arr, val, endian) { var B = new Array(); //Byte array - LSB is B[0] B[0] = Math.floor(val % 256); B[1] = Math.floor(val / 256); if (B[1] == 256) B[1] = 0; val = Math.floor(val / 65536); B[2] = Math.floor(val % 256); B[3] = Math.floor(val / 256) //Order bytes in Big //or Lil endian order if (endian) { i = 3; while(i > -1) arr.push(B[i--]); } else { i = 0; while(i < 4) arr.push(B[i++]); } } ////////////////////////////////////////////////////////////////////////////////////////////// //Pass width and height of the bmp, as well as the array containing the pixel color values //of the image. Then this functon will encode this data in an appropriate 24bit BMP envelope //and push the byte values representing the resulting BMP file in the passed output array. //The BMP is a simple uncompressed 24bit color Windows BMP (no color table indexing is used) // //Assumption: All bitmap scanlines are of equal size function create24bitBMP(width, height, inarr, outarr) { outarr.length = 0; //reset output array //Determine number of padding bytes for each scanline var padnum = Math.floor( (width * 3) % 4 ); var inarrsize = inarr.length; var datasize = inarrsize + height * padnum; //pixel bytes plus padding bytes //Push the 'BM' identifier byte sequence //since this is a Windows BMP outarr.push(66); //'B' outarr.push(77); //'M' //filesize -> 4 bytes (full header size + pixel data) var filesize = datasize + 54; pushDWord(outarr, filesize, 0); //reserved -> 4 bytes - zero pushDWord(outarr, 0, 0); //bmp data offset -> 4 bytes - file start to start of bmp data (54) pushDWord(outarr, 54, 0); //bmp header size -> 4 bytes - / 28h - Windows 3.1x, 95, NT, / 0Ch - OS/2 1.x / F0h - OS/2 2.x pushDWord(outarr, 40, 0); //width -> 4 bytes pushDWord(outarr, width, 0); //height -> 4 bytes pushDWord(outarr, height, 0); //planes -> 2 bytes (use just 1 plane) pushWord(outarr, 1, 0); //bits per pixel -> 2 bytes (24 for 24-bit bmp) pushWord(outarr, 24, 0); //compression spec -> 4 bytes (0 for no compression) pushDWord(outarr, 0, 0); //bmp data size -> 4 bytes (size of passed pixel array, pushDWord(outarr, datasize, 0); //HRes -> 4 bytes - pixels per meter (usually 3780) pushDWord(outarr, 3780, 0); //VRes -> 4 bytes - pixels per meter (usually 3780) pushDWord(outarr, 3780, 0); //Number of Colors in color table-> 4 bytes //All zero, since 24bit bmps do not use color table (palette) pushDWord(outarr, 0, 0); //Important Colors -> 4 bytes (all zero, since we use no palette) pushDWord(outarr, 0, 0); //Palette - Pallete colors are expressed by RGBByteQuads //There is nothing here since we use no palette in 24bit BMPs //BMP pixel data. 3 bytes per pixel (RGB Byte Triad) since this is a 24bit BMP). //Pad end of each scanline to next 32 bit boundary if needed (scanlines must be DWORD aligned) //RGB triad bytes should be Lil-Endian aligned. This means that the B byte is stored //in the lower address and the R byte in the higher var i=0, j=0, k; while(i < inarrsize) { outarr.push(inarr[i++]); j++; //if we reach the end of a scanline if (j/3 == width) { if (padnum) for(k=0;k min_y; y--) { for(x = min_x; x < max_x; x++) { //i++; //if there is no stored reference in matrix //for current x,y coords then //push the white color (nothing painted here) if (matrix["x" + x + "y" + y] == null) { arr.push(0xFF); arr.push(0xFF); arr.push(0xFF); } else { acolor = matrix["x" + x + "y" + y].acolor; if (acolor == 0xFF0000) { arr.push(0x00); arr.push(0x00); arr.push(0xFF); } else if (acolor == 0x00FF00) { arr.push(0x00); arr.push(0xFF); arr.push(0x00); } else if (acolor == 0x0000FF) { arr.push(0xFF); arr.push(0x00); arr.push(0x00); } } }//for end }//for end //trace("number of scanned pixels = " + i); } actionsO arr.push(0x00); arr.push(0xFF); } else if (acolor == 0x00FF00) { arr.push(0x00); arr.push(0xFF); arr.push(0x00); } else if (acolor == 0x0000FF) { arr.push(0xFF); arr.push(0x00); arr.push(0x00); } }