sup3r_ 1 Denunciar post Postado Março 30, 2014 Opa! boa noite caros colegas... estou aqui pedindo a ajuda de vocês... depois de 8 anos... sem usar o flash (actionscript) quando abro o código me deparo com tudo reformulado... e estou precisando algo rápido pra ontem... Sem delongas... este código utiliza a FileReference ou browse... gostaria de adicionar a opção URLrequest mas pelo visto isso ta mais dificil que antes... os eventos e tudo... a imagem seria uma array com 5 items... package com.hao { import flash.display.BitmapData; import flash.display.Loader; import flash.display.Shape; import flash.display.Sprite; import flash.events.Event; import flash.events.IOErrorEvent; import flash.events.MouseEvent; import flash.filters.DropShadowFilter; import flash.net.FileFilter; import flash.net.FileReference; import com.data.AppData; public class MenuConsole extends Sprite { /**add photo button*/ private var localFile:LocalFileBrowser; private var upLoadButton:UpLoadButton; /**snapshot button*/ private var screenShotButton:DownLoadButton; private var file:FileReference; private var backShape:Sprite=new Sprite; private var photoLoader:Loader; public function MenuConsole() { super(); if(stage){ init(); }else{ addEventListener(Event.ADDED_TO_STAGE,init); } } private function init(evt:Event=null):void{ drawBackGround(); } private function drawBackGround():void { backShape.graphics.beginFill(0xEAF2F5); backShape.graphics.drawRect(0,0,stage.stageWidth,34); backShape.graphics.endFill(); addChild(backShape); var array:Array=new Array; array.push(getFilter()); this.filters=array; addButton(); } private function addButton():void { localFile=new LocalFileBrowser; upLoadButton=new UpLoadButton; upLoadButton.addEventListener(MouseEvent.CLICK,addPhoto); screenShotButton=new DownLoadButton; screenShotButton.addEventListener(MouseEvent.CLICK,screenShot); //backShape.addChild(localFile); backShape.addChild(upLoadButton); backShape.addChild(screenShotButton); resize(); enabled(false); } /**load photo,jpg & png only**/ protected function addPhoto(event:Event):void { if(file==null){ file=new FileReference; file.addEventListener(Event.SELECT,onSelect); file.addEventListener(Event.COMPLETE,onCom); } file.browse([new FileFilter("Images", "*.jpg;*.png")]); } protected function onCom(event:Event):void { if(photoLoader==null){ photoLoader=new Loader; } photoLoader.loadBytes(event.target.data); photoLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,photoLoaded); photoLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR,ioError); } protected function ioError(event:IOErrorEvent):void { trace(event); } /**push bitmapdata into Model vector and throw event on stage to handle**/ protected function photoLoaded(event:Event):void { event.target.content.smoothing=true; var bmp:BitmapData=new BitmapData(photoLoader.width,photoLoader.height,true,0); bmp.draw(photoLoader,null,null,null,null,true); AppData.getInstance().bmps.push(bmp); photoLoader.contentLoaderInfo.removeEventListener(Event.COMPLETE,photoLoaded); photoLoader.unloadAndStop(); this.dispatchEvent(new Event(Event.CHANGE)); } protected function onSelect(event:Event):void { event.target.load(); } /**snapshot stage*/ protected function screenShot(event:MouseEvent):void { this.dispatchEvent(new HaoEvent(HaoEvent.SCREENSHOT)); } private function getFilter():DropShadowFilter{ //var dropshow:DropShadowFilter=new DropShadowFilter(2,90,0,.5,2,2); var dropshow:DropShadowFilter=new DropShadowFilter(0,0,0,0,0,0); return dropshow; } private function resize():void { for(var i:uint=0;i<backShape.numChildren;i++){ backShape.y = 175; backShape.getChildAt(i).x=440; backShape.getChildAt(i).y=i*80; } } public function enabled(value:Boolean):void{ screenShotButton.alpha=value==true?1:.5; screenShotButton.mouseEnabled=value; } } } Compartilhar este post Link para o post Compartilhar em outros sites
Elektra 102 Denunciar post Postado Março 30, 2014 A maneira mais rápida, eficiente, pra anteontem, é pesquisar alterações da versão do ActionScript no Adobe Help! http://help.adobe.com/pt_BR/FlashPlatform/reference/actionscript/3/flash/net/FileReference.html Fica legal conferir/postar as outras classes do package "com.hao". Compartilhar este post Link para o post Compartilhar em outros sites
sup3r_ 1 Denunciar post Postado Março 30, 2014 preguiça de ler tudo... que mudou... Compartilhar este post Link para o post Compartilhar em outros sites
Elektra 102 Denunciar post Postado Março 30, 2014 preguiça de responder Compartilhar este post Link para o post Compartilhar em outros sites