on any Android or iOS products that supports Air apps moreover Starling desktop apps
- .as3proj (FlashDevelop AIR sample job)
- .as (source codes)
- Five sample vector avatars
- asDoc style Documentation
with applying this small but awesome library, you will be capable to initialize a speaking avatar in your Starling Air cell initiatives. You will be equipped to opt for from present-day obtainable avatars in your “bin” folder and insert your possess voice .mp3 file and then addChild the Avatar course any place in your project and you’re accomplished.
import com.doitflash.utils.avatar.StarlingAvatar import com.doitflash.utils.avatar.AvatarEvent // set Class variable var _avatar:StarlingAvatar // initialize a _holder. avatar will be addchilded in _holder. // _holder will have to have a precise width and peak so we create a new Condition() in the _holder var _holder:Sprite = new Sprite() var rect:Condition = new Form() rect.graphics.beginFill(0xf64a5f, 1) rect.graphics.drawRect(, , 400, 600) _holder.addChild(rect) _holder.x = 100 _holder.y = 100 this.addChild(_holder) // initialize the StarlingAvatar _avatar = new StarlingAvatar() // increase a listener to be notified when the avatar is loaded _avatar.addEventListener(AvatarEvent.LOADED_AVATAR, onLoadedAvatar) // insert a listener to be notified when the mp3 file is loaded _avatar.addEventListener(AvatarEvent.LOADED_VOICE, onLoadedVoice) _avatar.holder = _holder _avatar.avatarUrl = "WomanAvatar.swf" // set the address to the avatar graphic you would like to use _avatar.voiceUrl = "exam.MP3" // set the address to the mp3 file which you like to use for lip-syncing // contact this approach and load the avatar graphic starts _avatar.loadAvatar() personal function onLoadedAvatar(e:AvatarEvent):void // simply call this process and load the mp3 file begins _avatar.loadVoice() non-public function onLoadedVoice(e:AvatarEvent):void trace("audio duration: ", e.param) // mp3 duration is based on miliseconds // use this listener to be notified when the mp3 playback is finished. _avatar.addEventListener(AvatarEvent.Seem_Play_Completed, onPlayComplete) // contact this strategy and the mp3 file begins playing _avatar.enjoy() non-public operate onPlayComplete(e:AvatarEvent):void trace("onPlayComplete") // get in touch with this approach to pause the mp3 file whilst participating in and it returns the millisecond position of the audio. // you can use this posture to perform the mp3 yet again and commence from where by it was paused. // var placement:Amount = _avatar.pause() // _avatar.engage in(place) // // simply call this process to halt the audio. // _avatar.stop() // When you happen to be carried out with this course, get in touch with this strategy to thoroughly clean up the memory. // _avatar.dispose()
we used the DMT library for dynamically making textures to be used in Starling: https://github.com/XTDStudios/DMT