Permalink
Browse files

NileRenderer content wasn't being readded on 2nd run. ugh. fixed.

  • Loading branch information...
1 parent d2a9b64 commit 08b555ba533a05ea8ea65bb385cbff6173f69270 @jubishop committed May 7, 2009
View
@@ -26,7 +26,7 @@ package fbair.gc {
public static function get(type:Class):* {
if (!pool[type]) pool[type] = new Array();
- if (pool[type].length == 0) Output.bug("Creating new: " + type);
+ if (pool[type].length == 0) Output.log("Creating new: " + type);
return (pool[type].length > 0) ? pool[type].pop() : new type();
}
@@ -88,6 +88,13 @@
updateImageDimensions();
}
+ // When we remove old items from the attachment renderer
+ // we want to recycle them
+ private function itemRemoved(event:Event):void {
+ if (event.target is MediaItem)
+ Depot.put(event.target);
+ }
+
// When we got new data
override public function set data(new_data:Object):void {
super.data = new_data;
@@ -123,13 +130,6 @@
removeItemAtIndex(i--);
}
- // When we remove old items from the attachment renderer
- // we want to recycle them
- private function itemRemoved(event:Event):void {
- if (event.target is MediaItem)
- Depot.put(event.target);
- }
-
// Add item
private function addItem(item:Object):void {
// Create the item
@@ -17,7 +17,8 @@
Most attachments have media items,
which can be links, photos, or videos -->
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml"
- xmlns:util="fbair.util.display.*" >
+ implements="fbair.gc.Recyclable"
+ xmlns:util="fbair.util.display.*" >
<util:LinkImage id="linkImage"
styleName="mediaImage"
@@ -30,22 +31,43 @@
styleName="videoBadge"
source="@Embed('../../assets/video_badge.png')"
mouseEnabled="false"
- includeInLayout="{data.type == 'video'}"
- visible="{videoBadge.includeInLayout}" />
+ includeInLayout="{showVideoBadge}"
+ visible="{showVideoBadge}" />
<mx:Button id="photoFrame"
styleName="photoFrame"
height="100%"
width="100%"
buttonMode="true"
- includeInLayout="{data.type == 'photo'}"
- visible="{photoFrame.includeInLayout}"
+ includeInLayout="{showPhotoFrame}"
+ visible="{showPhotoFrame}"
click="{linkImage.gotoLink()}" />
<mx:Script><![CDATA[
+ import fb.util.Output;
+
import fbair.util.StringUtil;
+ private static const PhotoType:String = "photo";
+ private static const VideoType:String = "video";
+
[Bindable] public var maxImageWidth:Number;
[Bindable] public var maxImageHeight:Number;
+ [Bindable] private var showPhotoFrame:Boolean = false;
+ [Bindable] private var showVideoBadge:Boolean = false;
+
+ override public function set data(new_data:Object):void {
+ super.data = new_data;
+
+ showPhotoFrame = (data.type == PhotoType);
+ showVideoBadge = (data.type == VideoType);
+ }
+
+ public function recycle():void {
+ showPhotoFrame = false;
+ showVideoBadge = false;
+ maxImageWidth = undefined;
+ maxImageHeight = undefined;
+ }
]]></mx:Script>
</mx:Canvas>
@@ -133,10 +133,7 @@
super.createChildren();
// If we created content in our data setter then add it now
- if (content) {
- content.percentWidth = 100;
- contentBox.addChild(content);
- }
+ if (content) contentBox.addChild(content);
}
// Save the earth, kids!
@@ -257,7 +254,10 @@
// Create correct type of content
content = Depot.get(AttachmentRenderer);
+ content.percentWidth = 100;
content.data = data.attachment;
+
+ if (contentBox) contentBox.addChild(content);
}
}
@@ -18,6 +18,8 @@
// LinkImage is also careful to utilize maxWidth/maxHeight
// properly.
package fbair.util.display {
+ import fb.util.Output;
+
import fbair.util.StringUtil;
import fbair.util.display.StubbornImage;
@@ -51,7 +53,7 @@ package fbair.util.display {
// and set their sizes manually.
private function imageLoaded(event:Event):void {
if (explicitMaxWidth && explicitMaxHeight) {
- var maxAspectRatio:Number = maxWidth / maxHeight;
+ var maxAspectRatio:Number = explicitMaxWidth / explicitMaxHeight;
if (aspectRatio > maxAspectRatio) {
boundByWidth()
} else {
@@ -69,12 +71,12 @@ package fbair.util.display {
}
private function boundByWidth():void {
- width = Math.min(contentWidth, maxWidth);
+ width = Math.min(contentWidth, explicitMaxWidth);
height = width / aspectRatio;
}
private function boundByHeight():void {
- height = Math.min(contentHeight, maxHeight);
+ height = Math.min(contentHeight, explicitMaxHeight);
width = height * aspectRatio;
}
}

0 comments on commit 08b555b

Please sign in to comment.