A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: How to make DataGrid Clickable?

  1. #1
    Junior Member
    Join Date
    Jun 2011
    Location
    Traverse City, MI
    Posts
    2

    How to make DataGrid Clickable?

    I need a little help...I'm pretty new to AS3 and would greatly appreciate any help or guidance!

    So, I have dataGrid that is pulling data from an XML file. How do I make each data row clickable and load 1 of 3 SWF's (depending which you pick) onto the stage.

    Actionscript Code:
    import fl.controls.dataGridClasses.DataGridColumn;
    import fl.data.DataProvider;
    import fl.containers.UILoader;
    import fl.data.DataProvider;
    import fl.events.*;
    import flash.xml.*;

    var myXML:XML;
    var myList:XMLList;


    function parseXML():void
    {

    var url:String = "myData.xml";
    var urlRequest:URLRequest = new URLRequest(url);
    var loader:URLLoader = new URLLoader();
    loader.addEventListener("complete" , loadXML);
    loader.load(urlRequest);
    }

    parseXML();

    function loadXML(evt:Event):void
    {
    myXML = new XML(evt.target.data);

    myDP = new DataProvider(myXML);

    myData.dataProvider = myDP;

    // DataGrid Columns defined
    var yearCol:DataGridColumn = new DataGridColumn("year");
    yearCol.headerText = "Year";
    yearCol.width = 50;

    var makeCol:DataGridColumn = new DataGridColumn("make");
    makeCol.headerText = "Make";
    makeCol.width = 125;

    var modelCol:DataGridColumn = new DataGridColumn("model");
    modelCol.headerText = "Model";
    modelCol.width = 175;

    var typeCol:DataGridColumn = new DataGridColumn("type");
    typeCol.headerText = "Body Type";
    typeCol.width = 225;

    var myDP:DataProvider;
    myData.columns = [yearCol, makeCol, modelCol, typeCol]; // DataGrid column Array
    myData.width = 600;
    myData.dataProvider = myDP;
    myData.rowCount = myData.length;

    }
    "Give a man a fish and you feed him for a day. Don't teach a man to fish, and you feed yourself. He's a grown man. Fishing's not that hard." ~ Ron Swanson

  2. #2
    AS2 intolerant person
    Join Date
    Jan 2009
    Location
    Swansea
    Posts
    352
    The datagrid should have a few events for this.

    Follow this tutorial:

    http://www.youtube.com/watch?v=MS1lzB-dcsk

    It shows you how to do it at the end.

    Flosculus

Tags for this Thread

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