1 / 30

Flash platform – обзорный курс. Лекция 3

Flash platform – обзорный курс. Лекция 3. DisplayList – завершение Работа с медиа Сетевое взаимодейтсвие Локальное хранение и передача данных. Display List – древовидная структура. Фильтры. DisplayObject .filters :Array Пакет flash.filters GlowFilter BlurFilter DropShadowFilter

Download Presentation

Flash platform – обзорный курс. Лекция 3

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Flash platform – обзорный курс.Лекция 3 DisplayList – завершение Работа с медиа Сетевое взаимодейтсвие Локальное хранение и передача данных

  2. Display List – древовидная структура

  3. Фильтры • DisplayObject.filters:Array • Пакет flash.filters • GlowFilter • BlurFilter • DropShadowFilter • ColorMatrixFilter • GradientBevelFilter • GradientGlowFilter • ConvolutionFilter • DisplacementMapFilter • ShaderFilter

  4. Фильтры • DisplayObject.filters:Array • Пакет flash.filters • GlowFilter • BlurFilter • DropShadowFilter • ColorMatrixFilter • GradientBevelFilter • GradientGlowFilter • ConvolutionFilter • DisplacementMapFilter • ShaderFilter myObject.filters = [new BlurFilter(), new GlowFilter(0x00FF00)];

  5. Маски DisplayObject.mask

  6. DisplayObject.mask:DisplayObject • varmask:Shape = new Mask(); • //draw mask • myObject.mask = mask;

  7. 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 – извлечь пиксели.

  8. Лирическое отступление - ByteArray flash.utils.ByteArray – упакованный массив байтов

  9. 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*

  10. Работа с Медиа-данными Пакет flash.media Sound Microphone Video Camera

  11. 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

  12. 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

  13. flash.media.SoundChannel • .position:Number (in ms) • .soundTransform:SoundTransform • .leftPeak:Number • .rightPeak:Number • .stop() • Events: • Event.SOUND_COMPLETE

  14. flash.media.SoundMixer • Global sound control class • .soundTransform:SoundTransform • .stopAll():void • .computeSpectrum(outputArray:ByteArray, FFTMode:Boolean = false, stretchFactor:int = 0):void

  15. flash.media.Microphone • .getMicrophone(index:int= -1):Microphone • .names:Array • … • Events: • ActivityEvent.ACTIVITY • StatusEvent.STATUS • SampleDataEvent.SAMPLE_DATA

  16. flash.media.Video • Extends DisplayObject • .attachCamera(camera:Camera):void • .attachNetStream(netStream:NetStream):void • .clear():void • .videoHeight:int • .videoWidth:int • .smoothing:Boolean

  17. 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

  18. Взаимодействие с сетью Пакет flash.net URLLoader URLStream NetConnection, NetStream XMLSocket, Socket

  19. 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

  20. varrequest:URLRequest = new URLRequest(‘http://mydomain.com/service’); vardata:URLVariables = new URLVariables(); data.user = “nikitap”; data.action = “remove”; /// etc request.data = data; request.method = URLRequestMethod.POST; varloader:URLLoader = new URLLoader(request); loader.addEventListener(Event.COMPLETE, loader_completeHandler); //…. private function loader_completeHandler(event:Event):void { varloader:URLLoader = URLLoader(event.target); trace(loader.data);}

  21. flash.net.URLStream • Поточная загрузка • ProgressEvent.PROGRESS – загрузка порции • Чтение – аналогично ByteArray (IDataInput)

  22. 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

  23. flash.net.NetConnection/ flash.net.NetStream • Воспроизведение .flv/.f4v – файлов по HTTP • Обращение к Flash Remoting– сервисам (BlazeDZ, ZendAMF, AMFPHP, LCDS, GraniteDS, etc…) • RTMP-cервера • P2P-cоедиения

  24. flash.net.NetConnection - .f4v-видео varnc:NetConnection = new NetConnection(); nc.connect(‘null’); varns:NetStream = new NetStream(ns); ns.play(“http://mydomain.com/myvideo.f4v”); varvideo:Video = new Video(); video.width = 640; video.height = 480; video.attachNetStream(ns); addChild(video);

  25. 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

  26. flash.media.Camera

More Related