360Flex Presentation Clip - Monkey Patching

Doug McCune · 972 views · 2007 · 7:04

Open on YouTube

Web developmentSoftware (other)talkdated

Why Stack Overflow recommends it

Stack Overflow users link it when explaining how to monkey patch Flex SDK classes to change behavior that subclassing cannot reach.

Recommended by 1 people across 1 different months, 2009 to 2013.

What it is

A short clip from a 360Flex conference talk by Doug McCune about monkey patching the Flex framework source. It explains the technique of overriding SDK classes by placing your own copy in the same package. Presented informally as a developer talk excerpt from 2007.

What people said

Recommends RJ Owen · 2009-12 · Stack Overflow · on “How to create a "spacer" in a Flex LinkBar?”

You're going to need to monkey-patch the class for this. LinkBar is essentially a horizontal box who automatically adds spacer objects between its children. Check out the updateDisplayList method - note that the size of the separators is set with this bit of code: if (isVertical()) { ... separator.setActualSize(separatorWidth, verticalGap); ... } else { ... separator.setActualSize(horizontalGap, separatorHeight); ... } You'll need to change this behavior somehow. My recommendation is to detect if this is the last spacer in the object (by comparing the loop iterator "i" to the total number of objects "n" in the child list) and, if it is, set it's width to either 100% or an explicitly calculat

Cites Stan Reshetnyk · 2012-05 · Stack Overflow · on “Add a property to a Button or other type of Objects”

Subclass is main solution. Next works only with mx components (flex sdk 3). Most components have data : Object property that you can freely use to store data. Monkey patching [this video] sometimes is the only way to go. It allows you to add custom properties to flex sdk classes. I don't think you should use it in your case. But I used it to change core logic that is locked by private keyword in flex sdk. Hope that helps.

Cites Amy Blankenship · 2013-04 · Stack Overflow · on “Customize Adobe File”

What you want to do is called " Monkey Patching [this video] ." What you need to do is create your own version of the file in the same package location, and yours will be used in preference to the one from the swc.