SWF Scaling, Cropping, and Alignment

When embedding a SWF, there are a two parameters that control how it scales, crops, and aligns within the available width and height.

  • scale: Specifies the scaling method and/or cropping of display objects drawn outside of the dimensions of the object containing the SWF.
scale Parameter Scaling Effect Cropping Effect
showall Proportional No
noborder Proportional Possible
exactfit Stretch No
noscale No Possible
  • salign: Specifies where the scaled SWF is positioned within the dimensions of the object that contains the SWF.
salign Parameter Horizontal Alignment Vertical Alignment
(None Specified) Center Center
tl Left Top
t Center Top
tr Right Top
r Right Center
br Right Bottom
b Center Bottom
bl Left Bottom
l Left Center

“salign” is often confused with the HTML object tag’s “align” attribute. However, “align” is actually the same deprecated HTML attribute applied to <img>, <object>, and <applet> tags.

Posted in Uncategorized | Leave a comment

Creating Instances with Dynamic Names

Creating instances of MovieClips set to “Export for Actionscript” in Flash Professional is really easy to do with the following AS3 code:

var myClipClass:Class = getDefinitionByName("MyClip" + "01") as Class;
var myClip:MovieClip = new myClipClass();
addChild(myClip);

The magic occurs when you assign the returned Class to a separate variable. This enables you to construct instances of that Class, and assign them to other variables. Of course, you aren’t limited to only MovieClips, you could construct instances of any type of Class, as long as a definition exists for it.

This technique essentially allows you to do something like:

var test:MovieClip = new ("MyClip" + variable)();

Which is obviously invalid code.

Note: You must assign the Class to a separate variable before you can construct instances of it. Unfortunately, I haven’t found any way to eliminate the need for a separate variable that stores the Class reference.

Posted in Uncategorized | Leave a comment

Customizing TextFlow Hyperlinks Appearance

There are three states of TLF LinkElements (“hyperlinks” or “anchors”) that may be customized:

  • Normal: When the LinkElement is in both its non-hover and non-active state (or when ROLL_OUT is dispatched)
  • Hover: When the LinkElement dispatches a ROLL_OVER event and the primary mouse button is not pressed.
  • Active: When the LinkElement dispatches a MOUSE_DOWN, MOUSE_CLICK, or MOUSE_MOVE and the primary mouse button is pressed (MouseEvent.buttonDown).

LinkElements must be children of RichEditableText in order to function. If the “editable” property is set to “true” (which it is by default), the control key must be pressed concurrently with the LinkElement mouse activity. This is the special nature of FlowElementMouseEvent

Below is an MXML example using an inline TextFlow declaration which styles the LinkElement as so: normal, hover, & active. However, keep in mind TextLayoutFormat supports many other properties for styling.

<s:RichEditableText editable="false">
 <s:textFlow>
   <s:TextFlow>
     <s:linkNormalFormat>
          <s:TextLayoutFormat color="#FF0000" textDecoration="underline"/>
     </s:linkNormalFormat>
     <s:linkHoverFormat>
          <s:TextLayoutFormat color="#0066FF" fontStyle="italic"/>
     </s:linkHoverFormat>
     <s:linkActiveFormat>
          <s:TextLayoutFormat color="#00FF00" fontWeight="bold"/>
     </s:linkActiveFormat>
     <s:p>Hello <s:a href="http://www.adobe.com/">Adobe</s:a></s:p>
   </s:TextFlow>
 </s:textFlow>
</s:RichEditableText>

A few things to note:

  • The linkNormalFormat is blue (#0000FF) and underlined by default.
  • Both linkHoverFormat and linkActiveFormat reference the linkNormalFormat unless specified otherwise.
  • LinkElements may contain any of the following elements:
  • Link format elements must contain only one <TextLayoutFormat> child element which formats any LinkElement within the parent of that link format element
  • Link formats may be inherited from parent elements or you may override them in child elements.
  • Link format elements are not supported with TextConverter.TEXT_FIELD_HTML_FORMAT
  • FlowElementMouseEvent listeners may be added to LinkElements and the CLICK event handler may prevent the default navigateToURL behavior:
private function mouseClickHandler(e:FlowElementMouseEvent):void
{
     e.stopImmediatePropagation();
     e.preventDefault();
     trace("LinkElement clicked");
}

All of the preceding Text Layout Framework markup has been tested and proven functional with the following Flex SDKs:

  • Flex 4.0.0.14159 with its included TLF 1.0
  • Flex 4.1.0.16076 with its included  TLF 1.1
  • Flex 4.5.0.20967 with its included TLF 2.0
Posted in Uncategorized | Leave a comment

No More “Online Portfolio”

If you’ve been to this domain before now, it’s obviously official- I took down my old “portfolio”. It was just another ill contrived homework assignment while I was at UAT. My degree was for “digital art & design”, so having a flash & zend programming portfolio was unacceptable to the professors assigned to judge this graduation requirement. The closest sounding degree UAT offered was “web architecture”, but the classes available were still the same- irrelevant to the career I chased.

Lesson: don’t waste time and money at a tech school. The best tech teacher is the tech itself. Avoid obliging to a situation offering only impractical means of escape. There are better alternatives for mastering core classes. Always consider alternative possibilities.

Of course I do have a portfolio, however you need to contact me personally if you want to see it.

Posted in Uncategorized | Leave a comment