Archive for the ‘Flex’ Category

Flex Bug: Icon shadows in a TabNavigator’s Tabs

Tuesday, May 27th, 2008

This is likely a generic problem with anything that uses a Button but I have found this issue with Tabs in a TabNavigator specifically. When you have a TabNavigator with multiple complicated children that take a while to load, clicking one tab then clicking another quickly can lead to a “shadow” icon at the top-left of the tabs. See the bug for more: SDK-15656

Inverted Mask in Flex

Monday, March 17th, 2008

Today I took on the challenge of changing a component I built last year to fit into a new style our creative department just finished for a new website. The previous component had a drawn background and some text laid over it which was a different color. The new style called for the same thing with a different background color and the text cut out of the shape. The different background color was easy, I simply added a few styles (one for rollover too) and had it changing color. The harder part was cutting the text out of the background. I knew that this was possible in graphics programs by inverting the mask used or subtracting the shape from another shape and using that as the mask. I couldn’t find any options in Flex for inverting a mask and a google search provided nothing on inverting a mask. I did, however run into a graphics tricks article on InsideRIA. This reminded me of the blend modes that I’d played with in the San Francisco Papervision3D course.

Curious, I went looking and sure enough there was a BlendMode.INVERT. This didn’t, however, do what I wanted of course. This inverted the color values, not the mask. Looking further I found BlendMode.ERASE. This sounded promising but several iterations had it doing nothing, then showing as normal text, then “erasing” everything underneath it. I didn’t want my text to erase everything, just the shape behind it. After some more playing I found the key. cacheAsBitmap. Of course, cacheAsBitmap on one of the pieces didn’t work. Normal masking, for that matter, required cacheAsBitmap on both the mask and the maskee. The trick to make an inverse mask is to set cacheAsBitmap to true for the container of the things that are being masked.

I’m not sure what the performance implications of this are but the effect sure is nice. :-)

Example (click to invert, view source enabled):

The red horizontal lines are on the bottom level. The text and the green vertical lines are within containingCanvas on top of the red lines. The green lines are beneath the text and masked by the text by default. Click to have it mask the green lines in inverse.

Travian Resource Reallocator

Thursday, February 28th, 2008

Last but not least in this deluge of posts is a little utility I created to allow people to reallocate their resources efficiently in Travian. There is a feature in this game, for those who pay a little money, that allows you to change any type of resource (lumber, clay, iron, crop) into any other type. This is very useful for situations where you are producing way more of one resource than another or simply want to speed up your development but if you reallocate for one thing then want to use the remaining resources for another thing you would need to either calculate the amounts manually or reallocate multiple times (thus costing more “gold”). The resulting app allows you to reallocate your resources for any troop type in the game, allows for configuration of the # of them you wish to train, and lets you add any number of subsequent reallocations with the remaining resources.

Travian Tool

3D Sierpinski Gasket

Thursday, February 28th, 2008

Let’s keep the ball rolling with another fractal creation. I’ve been playing with Papervision3D lately due to its use in a recent site I worked on and the San Francisco Papervision3D class I attended a few weekends ago. This latest is a verson of the sierpinski gasket which follows the same ideas as the last one I made but using 4 points to make a tetrahedron in 3 space. The same symmetry is applied but 4-fold and the lines are drawn but soon after removed as they quickly overshadow the pixels and slow the rendering down quite a bit once there are more than a few. Also notice that the pixels have some nice effects applied to them, making a kind fo vortex. Thanks to Andy Zupko for the Effects branch of Papervision3D and his part in the class I attended.

Sierpinski3D

The Dragon (in Flex)

Thursday, February 28th, 2008

Ever snce I got my tattoo(s) I have been explaining the fractal known as the dragon to anyone who takes an interest in it. I’ve even named some of my villages in Travian after the turns you take to create some of them. While explaining the fractal yet again I remembered the way that I originally learned to build it: draw the next iteration over the old one. I originally found this fractal at the beginning of each chapter in Jurassic Park. Since it had a regular box shape I used to use graphing paper to draw it, then after time realized that I could turn the paper over and draw the next iteration over the old one using a simple algorithm. Start by drawing a right angle to one side of the first line, then draw a righ angle to the other side of the next line, and repeat. I have programmed this fractal many times before but I had never actually coded up this algorithm before. I also wanted it to animate so as to show the drawing steps. Without further ado:

Dragon

Sierpinski Gasket (in Flex)

Thursday, February 28th, 2008

While on the plane back from Indianappolis I had two new ideas for generation of a Sierpinski Gasket: 3-way symmetry and line display. For those that don’t know what a sierpinski gasket is, it is a fractal that starts as an equilateral triangle with another one inscribed inside it. The next iteration adds triangles inscribed in the 3 “edge” triangles. This continues over and over (forever).

This implementation uses a different method of generation. You start at a random corner of the triangle, choose a random corner, move halfway to it, and draw a dot. Continue to randomly choose a corner, move halfway to it, and draw a dot, and you get the same thing as above.

Sierpinski Gasket+

High quality Thermo video up on Adobe’s site

Thursday, December 6th, 2007

Required watching for any Flex developer. Thermo looks like an awesome tool for those dealing with custom-designed UI elements. Check out the video.

String.split() bug should be fixed in Flash Player 9.1

Tuesday, December 4th, 2007

My bug was marked a duplicate of ASC-1739, which is slated to be fixed in Flash Player 9.1. I’m glad that others found this issue too.

No loading of Flex within AIR beta 2

Wednesday, November 14th, 2007

I’ve been trying to load a Flex application which is hosted on a website from within an AIR application which is also built with Flex. Things looked good when an HTML component displayed the website the application was on and allowed me to interact with the page through the DOM (automatically filling out form fields and submitting while listening for a load is a nice hack to avoid rewriting code for webservices :-). Once I got to the page with the flex application on it, however, I got nothing but the “install flash” message we show in the div that is usually replaced by SWFObject. No problem, SWFObject probably wasn’t up to it. Alas, a simple object/embed tag also failed to show the flex aplication. Somewhat disheartened, I also tried SWFLoader but got a security error when the swf tried to access its parent (ugh). A little searching showed some posts on Adobe’s forum and some bugs in their bug system that showed that neither of these things were supported. Flash files aren’t loaded in the HTML component in AIR because they haven’t figured out how to deal with it yet and Flex apps can’t be loaded into Flex apps due to the security sandbox and a Flex bug that triggers it. Oh well, I’ll have to settle for opening up a web page.

How (not) to open Flash files from FlexBuilder 3 beta 2

Thursday, November 8th, 2007

For a while now I’ve had to manually right click on any fla files in my FlexBuilder projects then choose Open With then System Editor for them to open correctly. In FlexBuilder 2 simply trying to open the file would open a text editor in FlexBuilder with the binary file contents in it and FlexBuilder 3b2 would give me the following error:

Unable to open external editor null
(com.adobe.flexbuilder.ui.osx.FlashExternalEditor)

Reason:
Plug-in com.adobe.flexbuilder.ui was unable to load class
com.adobe.flexbuilder.ui.osx.FlashExternalEditor

But at least it was trying to load Flash. I just found a magic bullet workaround for getting this to work right every time in FlexBuilder 3b2 (at least for me).

  1. Go to the Flex Builder menu and choose Preferences…
  2. Expand General, then Editors and choose File Associations
  3. Choose *.fla in the File types list
  4. Choose Adobe Flash Editor in the Associated Editors list
  5. Click the Remove button to the right of the Associated Editors list
  6. Click OK

Now your fla files will open with the system editor (Adobe Flash hopefully) by default.

I’ve opened a bug with Adobe: FB-10670.

UPDATE: this is also needed and works fine for me with FlexBuilder 3 beta 3.