Skip to content

Quick Programming Guide

canab edited this page Oct 1, 2014 · 2 revisions

DisplayObject

Flunity.DisplayObject Class Reference

DisplayObject is the base class for all drawable objects. DisplayObject contains functionality to control how object is appeared. Basic properties: scale, rotation, position, color, tint.

DisplayObject is animable and can contain one or more frames: currentFrame, totalFrames properties.

DisplayContainer

Flunity.DisplayContainer Class Reference

DisplayContainer inherits DisplayObject and contains nested DisplayObjects and/or DisplayContainers. You can add, remove and iterate objects in a container. Geometric and color transformations applied to the DisplayContainer affect all nested children.

FlashStage

Flunity.FlashStage Class Reference

FlashStage is a Unity Component that renders a flash scene. It has the root container: root property. To be rendered each DisplayObject should be added on the stage.

DiaplayObject is on the stage if it is added to the root container or to the other container which is continuously added to the root container. If DisplayObject is on the stage its stage property is set. If DisplayObject or any of its parent is detached from the stage - stage property is null.

FlashSprite

Flunity.FlashSprite Class Reference

FlashSprite is a DisplayObject that represents a bitmap. Sprites can have multiple frames and be animated. Sprite instances are created from the SpriteResource.

MovieClip

Flunity.MovieClip Class Reference

MovieClip is DisplayContainer with a timeline. MovieClip instances are created from the MovieClipResource.

Also custom class is generated for each exported from the Flash MovieClip . Another option to create a MovieClip instance is simply instantiate that class.

children naming

Suppose you have MovieClip (in Flash) which contains children named as "m1", "m2", "m3". In this case generated class for this MovieClip has fields "m1", "m2", "m3" of proper types with references to those children.

frame labels

Labels that are set on Flash Timeline are accessible at runtime. Label-related methods: GotoLabel(string), GetFrameLabels, SetLabelAction(string, Action)

Playing animation

Each display object with multiple frames can be played with this methods.

If MovieClip has nested animations they are played synchronously. This behavior can be changed by setting property nestedAnimationEnabled.

movieClip.OnPlayComplete(...).PlayToEnd();

Handling touches

Flunity.TouchListener Class Reference

var listener = new TouchListener(displayObject);
listener.TouchBegan += (it, touch) => {...};

Touch events:

  • TouchBegan: Dispatches when object is touched. Will be dispatched several times in case of multitouch.
  • TouchEnded: Dispatches when touch is ended. Will be dispatched several times in case of multitouch.
  • TouchCanceled: Dispatches when touch is canceled. Will be dispatched several times in case of multitouch.
  • Pressed: Dispatches when object is touched first time. Will be dispatched once in case of multitouch.
  • Released: Dispatches when all touches are ended. Will be dispatched once in case of multitouch.
  • Canceled: Dispatches when all touches are canceled. Will be dispatched once in case of multitouch.

TouchListener will not dispatch events if object's (or any parent's) touchEnabled property is false.