My favorites | Sign in
Project Home Downloads Wiki Issues Source
Project Information
Members

This library allows creating 9-slice scaling objects without distorted parts. Unlike standard flash 9-slice scaling where 5 of 9 object areas are distorted while scaled, Smart9Slice uses duplication instead of distortion.

Check the example here (click somewhere on the flash object).

Эта билбиотека позволяет создавать объекты использующие 9-slice scaling без растягиваемых частей. В отличие от стандартной реализации 9-slice scaling во флэше, где 5 из 9 частей растягиваются, Smart9Slice использует дупликацию вместо растяжения.

Вы можете посмотреть пример тут (тыкайте по флэш объекту).

How to Use

There are 2 versions of the class: Smart9Slice and AnimatedSmart9Slice. Both take their sub-object visuals from stage during creation, but unlike Smart9Slice which takes a snapshot of the first frame, AnimatedSmart9Slice stores MovieClips (which can be animated and can have mouse events) and duplicates them when needed.

Smart9Slice

You can created the objects of this class only in Flash IDE and use them in a SWF or SWC. To do that in linkage properties set base class of your object to ru.valyard.smart9slice.Smart9Slice, check Enable guides for 9-slice scaling checkbox, adjust these guides and voila, your object is set up.

Another way is to manually create 9 parts of your object, put them on stage (uncheck the 9-slice checkbox) and call them with the following names: tl, t, tr, l, c, r, bl, b, br, where t means top, b means bottom, r means right and l means left. You can also use "" after the name (like "tl") which indicates that this part should be scaled not duplicated. These objects will be used for constructing of a Smart9Slice object and can't be animated or have mouse events on them.

AnimatedSmart9Slice

AnimatedSmart9Slice can be configured only with the second way described earlier. But at this time object parts can have animation inside and can respond to mouse events. They are duplicated when needed. For this to work you must(!) specify a linkage identifier for each part on stage in its properties.

Advanced

You don't need to have all 9 objects on stage if you are creating your Smart9Slice object from sub-objects. Actually, you can have zero objects but why would you need it?

Smart9Slice takes width and height from stage and sub-objects' width and height from their width and height properties. But sometimes (for example when masks are involved) you want to specify them manually. For this purpose you can create an invisible Sprite called vMask or visibilityMask in your object or its parts and width + height will be taken from it.

Использование

Есть две версии класса: Smart9Slice и AnimatedSmart9Slice. Обе опираются на то, что было на сцене во время создания, но в отличие от Smart9Slice, который делает "снимок" кадра, AnimatedSmart9Slice хранит MovieClip'ы (которые могут быть анимированными и отвечать на события мыши) и размножает их когда нужно.

Smart9Slice

Вы можете создать объекты этого класса только во Flash IDE и скомпилировать их в SWF или SWC. Для того, чтобы это сделать поставьте в свойствах linkage вашему объекту в ru.valyard.smart9slice.Smart9Slice, включите чекбокс Enable guides for 9-slice scaling, настройте линейки как вам удобно и вуаля, объект готов к работе.

Другой способ — это вручную положить на сцену в объект 9 его частей (при этому нужно выключить чекбокс 9-slice) и назвать их следующими именами: tl, t, tr, l, c, r, bl, b, br, где t значит верхний, b — нижний, r — правый, l — левый. Также, вы можете добавить "" к названию (например "tl"), что означает, что этот элемент нужно скейлить вместо дуплицирования. Эти объекты будут использованы при создании объекта класс Smart9Scale и не могут быть анимированы или отвечать на события мыши.

AnimatedSmart9Slice

AnimatedSmart9Slice может быть сконфигурирован только вторым способом описанным выше. Но при этом части объекта могут быть анимированы и могут отвечать на события мыши. Они дублируются по необходимости. Чтобы это работало вым необходимо(!) выставить имя в свойствах linkage для каждого маленького объекта.

Advanced

Не обязательно создавать все 9 подобъектов. Вообще, можно не создавать ни одного, но зачем это нужно?

Smart9Slice берет ширину и высоту с самого себя и со свойств width и height подобъектов. Но иногда (например, когда дело доходит до масок) появляется необходимость вручную выставить эти параметры. Для этого вы можете создать невидимый Sprite с именем vMask или visibilityMask в своем объекте или его частях, с которого и будут браться ширина и высота.

Powered by Google Project Hosting