学flex2月了吧,经常都是问自己问题,今天上网突然有人qq小窗我问我哥关于flex弹出窗的问题,听起来不难我就想试试。代码如下
stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;
import flash.display.Bitmap;
import flash.display.BitmapData;
import com.adobe.images.JPGEncoder;
import com.yahoo.astra.fl.managers.AlertManager;
var snd:Sound = new camerasound();
var bandwidth:int = 0;
var quality:int = 100;
var cam:Camera = Camera.getCamera();
cam.setQuality(bandwidth, quality);
cam.setMode(512,384,30,false);
var video:Video = new Video(512,384);
video.attachCamera(cam);
//video.x = 20;
video.y = 120;
addChild(video);
var bitmapData:BitmapData = new BitmapData(video.width,video.height);
var bitmap:Bitmap = new Bitmap(bitmapData);
bitmap.x = 512;
bitmap.y = 120;
addChild(bitmap);
capture_mc.buttonMode = true;
capture_mc.addEventListener(MouseEvent.CLICK,captureImage);
function captureImage(e:MouseEvent):void {
snd.play();
bitmapData.draw(video);
save_mc.buttonMode = true;
save_mc.addEventListener(MouseEvent.CLICK, onSaveJPG);
save_mc.alpha = 1;
}
save_mc.alpha = .5;
function onSaveJPG(e:Event):void{
var myEncoder:JPGEncoder = new JPGEncoder(100);
var byteArray:ByteArray = myEncoder.encode(bitmapData);
var header:URLRequestHeader = new URLRequestHeader("Content-type", "application/octet-stream");
var saveJPG:URLRequest = new URLRequest("Image.aspx");
saveJPG.requestHeaders.push(header);
saveJPG.method = URLRequestMethod.POST;
saveJPG.data = byteArray;
var urlLoader:URLLoader = new URLLoader();
urlLoader.addEventListener(Event.COMPLETE, sendComplete);
urlLoader.load(saveJPG);
function sendComplete(event:Event):void{
AlertManager.createAlert(this, "上传成功");
}
}
function warnDown(e:MouseEvent):void{
navigateToURL(new URLRequest("images/1.bmp"), "_blank");
warn.visible = false;
}
warn.visible = false;
问题是弹出框不能正常弹出,就让他把 sendComplete(event:Event)和监听.addEventListener注释改成
if(Event.COMPLETE)
AlertManager.createAlert(this, "上传成功");
他改了之后竟然还成功了,很高兴,我让他该是认为监听是监听事件,而那个complete用if判断就行了,但后来同学说那个complete也可以监听,虽然说给别人改对了,但还得的再看下这方面的。
加油!!!
---------打一次发博客,格式什么都没弄好,sad。
阅读(857) | 评论(0) | 转发(0) |