Daily Crunch: Wraiths
31 minutes ago
package
{
[Bindable]
public class A
{
public var val : int;
public var b : B;
public function A()
{
val = 0;
b = new B(0);
}
}
}
package
{
[Bindable]
public class B
{
public var val : int;
public function B(v:int)
{
this.val = v;
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical">
<mx:Button click="onClick()" label="Click Me" />
<mx:Text text="A: {myA.val}" />
<mx:Text text="B: {myB.val}" />
<mx:Script>
<![CDATA[
[Bindable] var myA:A = new A();
[Bindable] var myB:B = myA.b;
function onClick() : void
{
myA.val += 1;
myA.b = new B(3);
}
]]>
</mx:Script>
</mx:Application>
myB.val? myB.val to be 3, because myB was assigned to myA.b and A is a [Bindable] class. When I changed the value of myA.b, I expected myB to reference new instance of B that myA.b now referenced.myB.val == 0. Why? Because myB is still bound to the original instance of B referenced by myA.b at the time myB was assigned, rather than whatever instance of B that myA.b might reference in the future.myB was a pointer...
import org.apache.log4j.*;
...
Logger sqlLogger = Logger.getLogger("org.hibernate.SQL");sqlLogger.setLevel(Level.DEBUG);
... do your stuff ...
sqlLogger.setLevel(Level.OFF);
<cache:fragment timeout="${30 * 1000}">
Simple cache based on a timeout of 30 seconds.
</cache:fragment>
<cache:fragment timeout="-1" condition="${size(items)}">
Simple cache with no timeout, using instead an additional attribute to refresh the cache when the size of the collection "items" has changed since the cache was last updated. This works well in situations where data changes rarely, and you want it to be available immediately upon change.
</cache:fragment>
<cache:fragment timeout="${30*1000}" disable="${devMode}">
Simple cache based on a timeout of 30 seconds but with an attribute to disable the cache if devMode is flagged. Here, devMode is a application scope attribute set when the server starts up. It's nice to be able to selectively disable certain caches for testing, and have them enabled live without having to change any code.
</cache:fragment>
style="display:none;" to hide it initially. Then, if the user is logged in, we use a little JavaScript on page load to show all the report links, otherwise they stay hidden. This is the same technique used by 37Signals (see JavaScript Makes Relative Times Compatible with Caching). Since we also check server-side that a user is logged in before allowing them to mark a comment as spam, there isn't a significant downside to having the hidden spam links for users who are not logged in.When user A has triggered a cache refresh, what should happen to other users who hit the same fragment?Should they:
(a) Head over to user A's thread, wait for user A's thread to complete the query, and then ask for the result? or,
(b) Should they just see that user A is refreshing the cache and so grab the last cached fragment and return immediately?
<cache:fragment timeout="600000" waitOnRefresh="true">
... where waitOnRefresh enabled would indicate that the cache should not server the last fragment while being refreshed, but rather attach itself to the thread conducting the refresh and get the result when complete.
</cache:fragment>
ProgressBar between OS X and Windows when the mode = ProgressBarMode.MANUAL and indeterminate = true.
<mx:progressbar x="10" y="10" id="progress" labelplacement="bottom" indeterminate="true" enabled="true" minimum="0" maximum="100" label="" width="210"/>

ProgressBar for some non-indeterminate (er, determinate) purpose, like loading some data from a server. So, let's do this:
progress.indeterminate = false;
progress.mode = ProgressBarMode.MANUAL;
progress.setProgress(0,100);
someLoader.addEventListener(ProgressEvent.PROGRESS,someProgressListener);
someLoader will load something, and someProgressListener will keep us up-to-date about the progress. So, say we've loaded all the data and now we're doing some processing, the progress of which we don't know since our processing function is synchronous and does not dispatch ProgressEvents. So, we want to set indeterminate back to true so that our users will know something is still happening but not show possibly incorrect progress with a determinate ProgressBar. So, let's do this:
progress.removeEventListener(ProgressEvent.PROGRESS,someProgressListener);
progress.indeterminate = true;
ProgressBar looks like this:
ProgressBar looks identical to before, which is the expected behavior. But in Safari (at least) on OS X, we have this monstrosity. What happened? Shouldn't Flash look identical in any browser? Well, apparently it doesn't.progress.mode = ProgressBarMode.EVENT. Turns out that this ugly displacement only occurs in OS X if (progress.mode == ProgressBarMode.MANUAL && progress.indeterminate). Oh well, something to chalk up on the list of cross-browser differences in Flash.progress.setProgress(num,total) will not do anything unless you have set progress.mode = ProgressBarMode.MANUAL. This is another thing I think is ridiculous, but the ProgressBar will ignore any calls to setProgress if mode != ProgressBarMode.MANUAL. I understand that the different ProgressBarMode settings will instruct the ProgressBar where to expect progress changes from, but it still seems odd to fully ignore calls to setProgress WITHOUT throwing any kind of error or warning when mode != ProgressBarMode.MANUAL.