Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > Adobe Web Programming > Flex
|
Flex Discuss the Adobe Flex programming language
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Flex section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 15th, 2009, 11:51 PM
Authorized User
 
Join Date: Feb 2007
Posts: 37
Thanks: 1
Thanked 0 Times in 0 Posts
Default Custom TreeItemRenderer removes custom component

Hello,
I have created custom TreeItemRenderer in which i am trying to draw colored Hbox bar at each node except root. Intially when i click on root node it opens first child node with bar but when i open leaf node it does not showing bar and removing existing bard from other few child nodes. Its calling itemrenderer on mouseonver eventhough i have disabled. I am attaching code would please any one help me to resolve this issue.
Attaching Code here

package Adodbe.renderers
{
import flash.display.DisplayObject;
import flash.events.Event;
import flash.events.MouseEvent;

import mx.collections.*;
import mx.containers.HBox;
import mx.controls.Label;
import mx.controls.TextInput;
import mx.controls.treeClasses.*;
import mx.core.UITextField;

public class PercentCorrectTreeRenderer extends TreeItemRenderer
{

private var hBox:HBox;
private var barHBox:HBox;
private var itemLabel:Label;
private var textBar:Label;
private var fillBar:TextInput;

// Define the constructor.
public function PercentCorrectTreeRenderer()
{
super();
}

override public function set data(value:Object):void
{
super.data = value;

var treeItem:Object = TreeListData(super.listData).item;
if(!treeItem) return;
if(treeItem.Element && treeItem.Element == "Root")
{
this.setStyle("styleName", "percentCorrectTreeSection");
}
else
{
this.setStyle("styleName", "percentCorrectTreeSectionItem");
}
}

override protected function createChildren():void
{
super.createChildren();

label.addEventListener(MouseEvent.CLICK, onLabelClick);
label.addEventListener(MouseEvent.MOUSE_OVER, onLabelMouseOver);


barHBox = new HBox();
fillBar = new TextInput();
textBar = new Label();

fillBar.editable = false;
fillBar.styleName = "barStrengths";

barHBox.addChild(fillBar);
barHBox.addChild(textBar);
barHBox.setStyle("paddingLeft",200)

this.addChild(barHBox);
}

override protected function measure():void
{
super.measure();

var w:Number = data ? ( listData as TreeListData ).indent : 0;

if ( disclosureIcon )
w += disclosureIcon.width;

if ( icon )
w += icon.measuredWidth;

if ( label.width < 4 || label.height < 4 )
{
label.width = 4;
label.height = 16;
}

if ( isNaN( explicitWidth ) )
{
w += label.getExplicitOrMeasuredWidth( );
w += barHBox.getExplicitOrMeasuredWidth( );
measuredWidth = w;
measuredHeight = Math.max( barHBox.getExplicitOrMeasuredHeight( ), label.getExplicitOrMeasuredHeight( ) );
}
else
{
label.width = Math.max(explicitWidth - ( w + barHBox.getExplicitOrMeasuredWidth( ) ), 4 );
measuredHeight = Math.max( barHBox.getExplicitOrMeasuredHeight( ), label.getExplicitOrMeasuredHeight( ) );

if ( icon && icon.measuredHeight > measuredHeight )
measuredHeight = icon.measuredHeight;
}
}

override protected function commitProperties( ): void
{
super.commitProperties( );
}


override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
{
super.updateDisplayList(unscaledWidth, unscaledHeight);
barHBox.setActualSize(barHBox.getExplicitOrMeasure dWidth(),barHBox.getExplicitOrMeasuredHeight());

if (icon)
icon.y = (unscaledHeight - icon.height) / 2;
if (disclosureIcon)
disclosureIcon.y = (unscaledHeight - disclosureIcon.height) / 2;

var treeItem:Object = TreeListData(super.listData).item;
if(!treeItem) return;

if(treeItem.Element && treeItem.Element == "Root")
{
this.label.text = treeItem.Title +" - "+treeItem.NumberCorrect +" correct ("+treeItem.PercentCorrect+"%)";
barHBox.visible = false;
fillBar.setStyle("borderStyle","none");
}
else
{
if(treeItem.children.length > 0)
{
this.label.text = treeItem.Title +" "+treeItem.NumberCorrect;
fillBar.width = Math.round((200 * Number(treeItem.PercentCorrect))/100);
fillBar.height = 15;
textBar.text = treeItem.PercentCorrect + "%";
fillBar.styleName = "barStrengths";
barHBox.y = disclosureIcon.y - 5
}
else if(treeItem.children.length == 0)
{
disclosureIcon.visible = false;
this.label.text = treeItem.Title +" "+treeItem.NumberCorrect;
fillBar.width = Math.round((200 * Number(treeItem.PercentCorrect))/100);
fillBar.height = 15;
textBar.text = treeItem.PercentCorrect + "%";
fillBar.styleName = "barStrengths";
barHBox.y = disclosureIcon.y - 5

}
}
}
private function onLabelClick(event:Event):void
{
var obj:Object = event.target;
}
private function onLabelMouseOver(event:Event):void
{
var obj:Object = event.target;
}



}
}

Any help would much appriciated.
Thanks





Similar Threads
Thread Thread Starter Forum Replies Last Post
Custom Server Control....Custom Property Editor ZArrinPour ASP.NET 1.0 and 1.1 Basics 1 June 15th, 2010 11:30 AM
Web Service, Custom Control, Custom Return Type robzyc ASP.NET 2.0 Basics 6 June 10th, 2008 08:03 AM
How to deploy a custom component? asf BOOK: Professional SQL Server 2005 Integration Services ISBN: 0-7645-8435-9 1 September 26th, 2007 08:04 AM
Need help for creating custom component chocolate Biztalk 1 March 23rd, 2006 06:21 AM
Creating Custom Menu Component in JSF.....Pls help Finny J2EE 0 September 10th, 2004 06:24 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.