Fill in a mc ------------*/ Import flash. display. BitmapData; Import flash. geom .*; // Draw a rectangle Function createRectangle (x: Number, y: Number, w: Number, h: Number, mc: MovieClip ){ Mc. moveTo (x, y ); Mc. lineTo (x + w, y ); Mc. lineTo (x + w, y + h ); Mc. lineTo (x, y + h ); Mc. lineTo (x, y ); Mc. endFill (); } // McTarget: specifies the film to be filled with MovieClip. The mcraw: specifies the strMask of the MovieClip filling material. The name of the film to be filled. Function fillbmp MC (mcTarget: MovieClip, mcraw: MovieClip, strMask: String ){ Var rect_mc: MovieClip = mcTarget. createEmptyMovieClip ("rect_mc", mcTarget. getNextHighestDepth ()); Rect_mc.bmp = new BitmapData (20, 20, false ); Rect_mc.bmp .draw (mcraw ); Rect_mc.beginBitmapFill(rect_mc.bmp ); // You can only fill in the image drawn by the program. CreateRectangle (0, 0, mcTarget. _ width, mcTarget. _ height, rect_mc ); // If you fill in an irregular image, you need to put a shadow film in the film you want to fill in. If you don't need to, just pass a variable without declaration. If (strMask! = Undefined ){ Rect_mc.setMask (mcTarget [strMask]); } } // Obtain the file path Function getFilePath (): String { Var arrA: Array, strRen: String, strSplit: String; StrSplit = "/"; ArrA = _ root. _ url. split (strSplit ); If (arrA. length = 1 ){ StrSplit = "\"; } For (var I: Number = 0; I <arrA. length-1; I ++ ){ If (I = 0 ){ StrRen = arrA [0]; } Else { StrRen + = strSplit + "" + arrA [I]; } } StrRen + = strSplit; Return strRen; } // Prompt box Function talkYou (strA: String ){ TxtTalkYou. text = strA } // Var mcImg: MovieClip = _ root. createEmptyMovieClip ("mcImg", _ root. getNextHighestDepth ()); Var mcImg2: MovieClip; // Load the image movi1_loader listener object Var objLoad: Object = new Object (); ObjLoad. onLoadInit = function (target_mc: MovieClip ){ // TalkYou ("loaded, first frame "); TalkYou (""); // No masking Fillbmp MC (canvas, target_mc, strMask ); // Masked Fillbmp MC (mcMask, target_mc, "mcMask "); // Get rid of it after it is used up: P Target_mc.removeMovieClip (); }; ObjLoad. onLoadComplete = function (target_mc: MovieClip, httpStatus: Number ){ TalkYou ("full download "); }; ObjLoad. onLoadError = function (target_mc: MovieClip, errorCode: String, httpStatus: Number ){ TalkYou ("failed to load "); }; ObjLoad. onLoadProgress = function (target_mc: MovieClip, loadedBytes: Number, totalBytes: Number ){ TalkYou ("Loading..." + Math. floor (loadedBytes/totalBytes) * 100) + "% "); }; ObjLoad. onLoadStart = function (target_mc: MovieClip ){ TalkYou ("start Download "); }; Var myLoader: movi1_loader = new movi1_loader (); MyLoader. addListener (objLoad ); // Load the image path MyLoader. loadClip (getFilePath () + "test.jpg", mcImg ); |