DisplayList – завершение Работа с медиа Сетевое взаимодейтсвие Локальное хранение и передача данных FLASH PLATFORM – ОБЗОРНЫЙ КУРС. ЛЕКЦИЯ 3
DISPLAY LIST – ДРЕВОВИДНАЯ СТРУКТУРА Stage SpriteShapeSpriteMovieClip SimpleButton
ФИЛЬТРЫ DisplayObject.filters :Array Пакет flash.filters GlowFilter BlurFilter DropShadowFilter ColorMatrixFilter GradientBevelFilter GradientGlowFilter ConvolutionFilter DisplacementMapFilter ShaderFilter
ФИЛЬТРЫ DisplayObject.filters :Array Пакет flash.filters GlowFilter BlurFilter DropShadowFilter ColorMatrixFilter GradientBevelFilter GradientGlowFilter ConvolutionFilter DisplacementMapFilter ShaderFilter myObject.filters = [new BlurFilter(), new GlowFilter(0x00FF00)];
DisplayObject.mask МАСКИ
DisplayObject.mask:DisplayObject var mask:Shape = new Mask(); //draw mask myObject.mask = mask;
flash.display.BitmapData.draw(source:IBitmapDrawable, matrix:Matrix = null, colorTransform:flash.geom:ColorTransform = null, blendMode:String = null, clipRect:Rectangle = null, smoothing:Boolean = false):void Куча методов для работы с изображением Display – with new Bitmap().getPixels(rect:Rectangle):ByteArray – извлечь пиксели.
flash.utils.ByteArray – упакованный массив байтов ЛИРИЧЕСКОЕ ОТСТУПЛЕНИЕ - BYTEARRAY
BYTEARRAY.length:uint.position:uint.readByte():int.readBytes(bytes:ByteArray, offset:uint = 0, length:uint = 0):void.readBoolean():Boolean.readDouble():Number, readFloat():Number, readInt():int …etc.readUTF():String,.readUTFBytes(length:uint):String,.readMultiByte(length:uint, charSet:String):String.readObject():*.write*
Пакет flash.media Sound Microphone Video Camera РАБОТА С МЕДИА-ДАННЫМИ
flash.media.Sound new Sound(); sound.load(new URLRequest(soundUrl.mp3)); sound.play(startTime:Number = 0, loops:int = 0, sndTransform:flash.media:SoundTransform = null):SoundChannel sound.close():void sound.extract(target:ByteArray, length:Number, startPosition:Number = -1):Number sound.id3:ID3Info Events: Event.OPEN ProgressEvent.PROGRESS Event.COMPLETE IOErrorEvent.IO_ERROR Event.ID3 SampleDataEvent.SAMPLE_DATA
flash.media.SoundTransform.volume : Number (0 – 1) … flash.display.SimpleButton.soundTransform flash.display.Sprite.soundTransform flash.media.Microphone.soundTransform flash.media.SoundChannel.soundTransform flash.media.SoundMixer.soundTransform flash.net.NetStream.soundTransform
flash.media.SoundChannel.position:Number (in ms).soundTransform:SoundTransform.leftPeak:Number.rightPeak:Number.stop() Events: Event.SOUND_COMPLETE
flash.media.SoundMixer Global sound control class.soundTransform:SoundTransform.stopAll():void.computeSpectrum(outputArray:ByteArray, FFTMode:Boolean = false, stretchFactor:int = 0):void
flash.media.Microphone.getMicrophone(index:int = -1):Microphone.names:Array … Events: ActivityEvent.ACTIVITY StatusEvent.STATUS SampleDataEvent.SAMPLE_DATA
flash.media.Video Extends DisplayObject.attachCamera(camera:Camera):void.attachNetStream(netStream:NetStream):void.clear():void.videoHeight:int.videoWidth:int.smoothing:Boolean
flash.media.Camera.names:Array.getCamera(name:String = null):Camera.setMode(width:int, height:int, fps:Number, favorArea:Boolean = true):void … Events: ActivityEvent.ACTIVITY StatusEvent.STATUS
Пакет flash.net URLLoader URLStream NetConnection, NetStream XMLSocket, Socket ВЗАИМОДЕЙСТВИЕ С СЕТЬЮ
URLLoader.load(request:URLRequest):void URLRequest – new URLRequest(url:String = null).method – URLRequestMethod.GET/URLRequestMethod.POST.data – data to be sent. URLVariables/ByteArray/String.dataFormat:String = URLLoaderDataFormat.TEXT URLLoaderDataFormat.BINARY URLLoaderDataFormat.VARIABLES. data:*.bytesTotal:uint.bytesLoaded:uint Events: Event.OPEN ProgressEvent.PROGRESS SecurityErrorEvent.SECURITY_ERROR IOErrorEvent.IO_ERROR HTTPStatusEvent.HTTP_STATUS Event.COMPLETE
var request:URLRequest = new URLRequest( var data:URLVariables = new URLVariables(); data.user = nikitap; data.action = remove; /// etc request.data = data; request.method = URLRequestMethod.POST; var loader:URLLoader = new URLLoader(request); loader.addEventListener(Event.COMPLETE, loader_completeHandler); //…. private function loader_completeHandler(event:Event):void { var loader:URLLoader = URLLoader(event.target); trace(loader.data); }
flash.net.URLStream Поточная загрузка ProgressEvent.PROGRESS – загрузка порции Чтение – аналогично ByteArray (IDataInput)
flash.net.FileReference Чтение, запись и отправка локальный файлов; загрузка файлов с сервера.browse(typeFilter:Array = null):Boolean.load():void.download(request:URLRequest, defaultFileName:String = null):void.save(data:*, defaultFileName:String = null):void.upload(request:URLRequest, uploadDataFieldName:String = "Filedata", testUpload:Boolean = false):void.data : ByteArray.name : String.size : Number.type : Number Events: Event.OPEN, ProgressEvent.PROGRESS, Event.COMPLETE Event.SELECT, Event.CANCEL
flash.net.NetConnection / flash.net.NetStream Воспроизведение.flv/.f4v – файлов по HTTP Обращение к Flash Remoting – сервисам (BlazeDZ, ZendAMF, AMFPHP, LCDS, GraniteDS, etc…) RTMP-cервера P2P-cоедиения
flash.net.NetConnection -.f4v-видео var nc:NetConnection = new NetConnection(); nc.connect(null); var ns:NetStream = new NetStream(ns); ns.play( var video:Video = new Video(); video.width = 640; video.height = 480; video.attachNetStream(ns); addChild(video);
flash.net.XMLSocket / flash.net.Socket TCP – соединение с сервером Любые протоколы XMLSocket – null-terminated messages.connect(host:String, port:int):void (for XMLSocket).send(object:*) (for Socket) – the same as ByteArray Events: Event.CONNECT, Event.CLOSE (for XMLSocket) DataEvent.DATA (.data – received data) (for Socket) ProgressEvent.SOCKET_DATA
flash.media.Camera