PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
XML to AS3 to List component in flash - Page 3
A Flash Developer Resource Site

Page 3 of 3 FirstFirst 123
Results 41 to 47 of 47

Thread: XML to AS3 to List component in flash

  1. #41
    Member
    Join Date
    May 2011
    Posts
    39
    yep in my list the report names show up, my boss is about to come up to me within the hour so im searching nervously...

    how do i do this 5tonsoflax!! please help!!! all i need is when i click the textbox is filled with thatttt nodes description which i am stuck with

  2. #42
    Member
    Join Date
    May 2011
    Posts
    39
    i figured out how to add the reports name into another text box, wheenever any report is selected.. using this code


    rList.addEventListener(Event.CHANGE, selectReport);

    function selectReport (event:Event):void{

    rdesc.text=event.target.selectedItem.label;
    }

  3. #43
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    Try this:
    Code:
    function getReportList() { 
    
        var xmlLoader:URLLoader = new URLLoader(); 
        var xmlData:XML = new XML(); 
    
        xmlLoader.addEventListener(Event.COMPLETE, loadXML); 
        xmlLoader.load(new URLRequest("reports.xml")); 
        rList.addEventListener(Event.CHANGE, selectReport);
    
        function selectReport (event:Event):void{
          rdesc.text=event.target.selectedItem.data;
        } 
    
        function loadXML(e:Event):void { 
    
            xmlData=new XML(e.target.data); 
    
            parseReports(xmlData); 
    
        } 
    
        function parseReports(reportXML:XML):void { 
    
            var reportList:XMLList=reportXML.reportdetails; 
             
            rList.removeAll(); 
    
            for each (var report:XML in reportList) { 
    
                rList.addItem({label:report.@name, data:report.desc}); 
    
            } 
    
        } 
    
    }
    Edit: Changed capitalization. Variables begin with lower case. Classes begin with upper.

  4. #44
    Member
    Join Date
    May 2011
    Posts
    39
    i want to kiss U! hes coming over nowe pefect timeing!

  5. #45
    Member
    Join Date
    May 2011
    Posts
    39
    just so i understand for the future and when i do harder stuff :

    so instead of grabbing certain items you grab the whole report details firstly then i dont really understand how you got the description to the text box, i see that the labels are the names that appear in the list component. Enlighten me! to be honest the whole code is slightly confusing at parts, i have copied and pasted bits from all over the place i will try to understand it fully.


    function parseReports(reportXML:XML):void {

    var reportList:XMLList=reportXML.reportdetails;

    rList.removeAll();

    for each (var report:XML in reportList) {

    rList.addItem({label:report.@name, data:report.desc});

    }

    }

  6. #46
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    What we add to the list with the addItem line is an Object literal. That object has two properties: label and data. We get the values for those properties from the XML node for the reportdetails.

    Then, in the selectReport function, we get the selected item, which is the object we added, and get its data property. That is the description from the XML. Put that description in the textbox, and you're done.

  7. #47
    Member
    Join Date
    May 2011
    Posts
    39
    hey i have done a lot since talking to you! i have a huge problem but not sure you will know as you mentioned you do not know about List components.

    basically Is there a way to execute selectedItem on ROLL_OVER instead of click in a List component?
    When i try to use the roll over i get these errors.

    TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at FlashMenu__r3_fla::MainTimeline/selectReportOVER()[FlashMenu__r3_fla.MainTimeline::frame2:47]
    at flash.events::EventDispatcher/dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at fl.controls::SelectableList/handleCellRendererMouseEvent()

    the part of code doing this is here:

    Actionscript Code:
    rList.addEventListener(ListEvent.ITEM_ROLL_OVER, selectReportOVER);

    function selectReportOVER (event:Event):void
    {
            rdesc.htmlText= "<i>" + event.target.selectedItem.data.ReportDescription + "</i>";
            raddress.text=event.target.selectedItem.data.Address;
            matrixYear.text=event.target.selectedItem.data.Matrix.TimeDimension;
            matrixFields.text=event.target.selectedItem.data.Matrix.FieldsAvalible;
            matrixHierarchy.htmlText= event.target.selectedItem.data.Matrix.Hierarchy;
            matrixDrill.text=event.target.selectedItem.data.Matrix.DrillDown;

    //this changes the overskin color when either Local or insight report

        if(event.target.selectedItem.data.@Type=="LocalBU_Report"){
             var locBG:MovieClip = new MovieClip();
            locBG.graphics.beginFill(0x8800FF00);
            locBG.graphics.drawRect(0,0,200,30);
            locBG.graphics.endFill();
            rList.setRendererStyle("overSkin", locBG);
            ifbox.text="LOCAL"
            }
            else {
            var iBG:MovieClip = new MovieClip();
            iBG.graphics.beginFill(0xFF00FF);
            iBG.graphics.drawRect(0,0,200,30);
            iBG.graphics.endFill();
            rList.setRendererStyle("overSkin", iBG);
            ifbox.text="INSIGHT"
        }
       
       
            //show the labels when selected
            raddress.visible = true
            rdesc.visible = true
            matrixYear.visible = true;
            matrixFields.visible = true;
            matrixHierarchy.visible = true;
            matrixDrill.visible = true;
    }



    please help sir this is the final problem i have right now!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center