Ok, here goes:

I'm trying to implement a "Windows File Explorer"-like interface to a data 
repository. For the time being I'm assuming that I receive XML from some API. 
So I'm using a static XML file for now, it's called "treexmldatastruct.xml".

The problem I'm having is this ... I'd like the icons in my explorer interface 
(which is implemented as a Tree) to be indicative of the filetype. I've created 
icon files and written an IconFunction to do this and it works fine.

Except that branches of the Tree also wind up having their icons changed ... in 
spite of the fact that I've defined a folderOpenIcon and a folderClosedIcon. 
The docs claim that an IconFunction can't override these, but in fact it does 
seem to be.

Here's the relevant code:

<mx:Script>
                <![CDATA[
                        [Embed("icon_jpeg.png")]
                        public var jpegSymbol:Class;
                        
                        [Embed("icon_gif.png")]
                        public var gifSymbol:Class;
                        
//                      etc, etc ... more image embeds here

                        private function myIconFunction(item:Object):Class {
                                var filetype:String = [EMAIL PROTECTED];

                                switch (filetype) {
                                        case "jpg":
                                        return jpegSymbol;
                                        break;

                                        case "gif":
                                        return gifSymbol;
                                        break;

//                                      etc, etc ... more cases here

                                        case "normal":
                                        return normalSymbol;
                                        break;

                                        default:
                                        return normalSymbol;
                                }                               
                        return normalSymbol;
                        }
                ]]>
        </mx:Script>

<mx:XML source="treexmldatastruct.xml" id="myMenuStruct" format="e4x"/>

        <mx:Tree id="firstList" height="300" width="230" x="20" y="70"
        showRoot="true" dataProvider="{myMenuStruct}"
        labelField="@label"
        dragEnabled="true" dropEnabled="true" dragMoveEnabled="true"
        allowMultipleSelection="true"
                folderOpenIcon="@Embed(source='icon_open.png')"
        folderClosedIcon="@Embed(source='icon_closed.png')"
                iconFunction="myIconFunction"/>

The XML file "treexmldatastruct.xml" is:

<?xml version="1.0"?>
    <node label="Mail" date="27-06-2006">
        <node label="Inbox" date="28-06-2006"/>
        <node label="Personal Folder" date="29-06-2006" filetype="">
            <node label="Demo" date="30-06-2006" filetype="msword"/>
            <node label="Personal" date="31-06-2006" filetype="msword"/>
            <node label="Saved Mail" date="01-07-2006" filetype="msword"/>
            <node label="Spam" date="02-07-2006" filetype="msword"/>
        </node>
        <node label="Business Folder" date="29-06-2006">
            <node label="Instructions" date="30-06-2006" filetype="pdf"/>
            <node label="Personnel Database" date="31-06-2006" 
filetype="msaccess"/>
            <node label="Quarterly Spreadsheet" date="01-07-2006" 
filetype="msexcel"/>
            <node label="Company Logo" date="02-07-2006" filetype="jpg"/>
        </node>        
        <node label="Calendar" date="03-07-2006"/>
        <node label="Sent" date="04-07-2006"/>
        <node label="Trash" date="05-07-2006"/>
    </node>

Thanks for any help.
Cheers
John


This email and any files transmitted with it may be confidential and are 
intended solely for the use of the individual or entity to whom they are 
addressed. This email may contain personal information of individuals, and be 
subject to Commonwealth and/or State privacy laws in Australia. This email is 
also subject to copyright. If you are not the intended recipient, you must not 
read, print, store, copy, forward or use this email for any reason, in 
accordance with privacy and copyright laws. If you have received this email in 
error, please notify the sender by return email, and delete this email from 
your inbox. 



--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to