DataGrid Control using ActionScript

Hi,
Is it possible to generate the rows of a datagrid dynamically
using actionscript?
I want to put information of multiple XML's on one line of my
datagrid.
Mark

Ok, I found out my problem, the thing is i wanted to combine
info in a datagrid, from 2 xml's, but since it's not directly
possible to access a row of the grid, I created a labelfunction for
the datagridcolumns which i wanted to populate with a different
value.
Source is included below, hope it will help someone.
<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="
http://www.adobe.com/2006/mxml"
width="1120" height="300" initialize="doInit();">
<mx:XML id="dataContacts"
source="/data/Contactperson.xml"/>
<mx:XML id="dataCommunication"
source="/data/Communication.xml"/>
<mx:Script>
<![CDATA[
private function doInit():void {
trace(dataContacts.Contactperson.Firstname);
protected function getPhonenoById(row:Object,
column:DataGridColumn):String {
for each(var node:XML in row.Communicationid) {
var value:String = new String;
if (dataCommunication.Communications.Communication.@id ==
node.toString) {
value = dataCommunication.Communication.(@id ==
node.toString()).(@type == "Phone");
if (value != "") // if the string is empty
// return to the returning parameter.
break;
// returning the value to the cell
return value;
]]>
</mx:Script>
<mx:DataGrid x="10" y="10" width="493" id="dg"
dataProvider="{dataContacts.Contactperson}">
<mx:columns>
<mx:DataGridColumn id="dcFirstname" dataField="Firstname"
headerText="Voornaam"/>
<mx:DataGridColumn id="dcLastname" dataField="Lastname"
headerText="Achternaam"/>
<mx:DataGridColumn id="dcPhone"
dataField="Communicationid" labelFunction="getPhonenoById"
headerText="Telefoonnummer"/>
</mx:columns>
</mx:DataGrid>
</mx:Canvas>

Similar Messages

  • Nest a DataGrid within another DataGrid using ActionScript?

    I am running into an interesting issue. I am trying to nest a
    DataGrid in a column of another DataGrid by setting the
    ItemRenderer property. But I am hitting a well that might be due to
    the way setting itemRenderers are done in ActionScript or just my
    ignorance.
    Here's the issue -
    When I set the itemRenderer property of for a grid column, it
    has to be set as follows -
    col.itemRenderer = new ClassFactory(DataGrid);
    But if I do that, since I am dealing with the class and not
    the instance of the DataGrid, how do I set the dataProvider,
    columns and other properties for my nested grid? I know we can do
    this in MXML but how to achieve the same in ActionScript?
    Thank you.

    A very interesting question. I should try this myself at some
    point. If you were using a drop-in itemRenderer, it might look like
    this:
    <mx:DataGridColumn dataField="gridData" ... >
    <mx:itemRenderer>
    <mx:Component>
    <mx:DataGrid dataProvider="{data.gridData}" width="100%"
    height="100%" ...>
    </mx:DataGrid>
    </mx:Component>
    </mx:itemRenderer>
    </mx:DataGridColumn>
    In ActionScript, this might work, but you would need to
    extend DataGrid or use a container wrapper.
    class DataGridItemRenderer extends DataGrid {
    override public function set data(value:Object):void {
    super.data = value;
    dataProvider = data.
    gridData;
    This should do it.

  • Using ActionScript to control where a break happens in TLF linked text boxes

    Let's say you want to display a directory of people including name and department person works in. This information is in an xml file and ActionScript is used to read the information in and display the text in TLF text boxes that are linked. Is there a way to use ActionScript to control orphans/widows? Meaning, let's say that the first TLF text box fills up and at the very bottom of that text box another person's name appears. Then at the top of the linked text box the department name that person works in appears. Is there a way to use ActionScript to control it so that the persons name doesn't get separated from the department name? Thanks for any help!!

    Thanks for taking time to answer my post, kglad.
    Yes. I believe I understand. I could create another button
    and call it "Reset Grid" and call this function, however what I am
    hoping for is to have the grid redraw simply by the user entering
    new values for the width and height and then clicking "draw
    floorplan" again.
    Currently the first line of code is:
    my_button.addEventListener("onPress",gridf); Should not the grid
    redraw each time and then parse the new values in the width and
    height fields? I am sure I am just dense but my grid is not
    clearing each time the "draw " button is clicked.
    You can see this happen on the sample link below. After
    entering say 20 width and 20 height values and clicking "draw"
    button, the grid is created perfectly. Then if, say new values of
    10 width and 10 height are entered and "draw" button is clicked,
    the grid does not redraw correctly using these new values.
    Sample link:
    http://216.197.127.249/grid/grid_sample_1.html
    Could the problem be that the gridf function should happen as
    the first function in the script before the new values are parsed
    again? Should a: grid_container.removeMovieClip(); execute before
    anything else is executed each time the "draw" button is clicked?

  • Help needed to add an image to a datagrid cell in actionscript

    Morning all,
    I am still quite new to flex development and I have an application which uses xml to populate a datagrid. One of the row columns should display a small image but I don't know how to do that.
    Can anyone show me how to add an image to a datagrid cell in actionscript?
    I've added a sample of the code I have written already below. Any help would be much appreciated.
    Thanks in advance,
    Xander
    My XM
    <?xml version="1.0" encoding="UTF-8"?>
    <dataset>
    <modules>
    <module id="1">
    <icon>assets/sample_image1.png</icon>
    <key>core</key>
    <name>Core</name>
    <description>Description of module</description>
    <installed>Wednesday, 24th June 2009 @ 15:59 UK</installed>
    </module>
    <module id="2">
    <icon>assets/sample_image2.png</icon>
    <key>webproject</key>
    <name>Web Project</name>
    <description>Description of module</description>
    <installed>Wednesday, 24th June 2009 @ 17:32 UK</installed>
    </module>
    </modules>
    </dataset>
    My Actionscript
    private function dataSetHandler(event:Event):void {
        var ds:XML = new XML(event.target.data);
        var rows:XMLList = ds.elements('modules').elements('module') as XMLList;
        var columns:Array = new Array();
        for (var i:int=0; i<rows[0].elements().length(); i++) {
            var column:DataGridColumn = new DataGridColumn();
            var tag:String = rows.*[i].name();
            column.headerText = rows.*[i].name();
            column.dataField = rows.*[i].name();
            if (tag == 'icon') {
                var img:Image = new Image();
                img.id = "iconpath";
                img.width = 23;
                img.height = 20;
                img.source = rows.*[i].name();
               column.itemRenderer = img;   <-- this line shows as an error when I try to compile
            columns[i] = column;
        mydatagrid.columns = columns;
        mydatagrid.dataProvider = rows;

    you cant just set image object to itemrenderer, you need to use classfactory.
    http://livedocs.adobe.com/flex/3/html/help.html?content=cellrenderer_4.html

  • How to adjust the path of a tween using actionscript

    I'm a novice at Actionscript3 and would greatly appreciate an answer to what seems like a simple question:
    Here's my project:
    http://home.comcast.net/~samiri/director/mortals/amadoFlashPortrait/index.htm
    Click on the gray scale frame images. A larger version of that image tweens out along the z axis. However it comes from 'somewhere else' not from 'within the frame.' How do I get the each larger gray scale frame image to look like it comes directly from the place where the user clicks (not to one side or the other)?
    So I guess what I'm asking is how to adjust the path of the tween along the x and y axis using the actionscript code (below).
    My method:
    I'm using this line of code in my script:
    var myTween:Tween = new Tween(mdImg, "z", Strong.easeOut, 300, 0, 1, true);
    "mdImg" is the variable that holds the name of the hotspot clicked upon by the user.
    I have the larger (faded edge) image positioned directly on top of the frame image and just kept invisible until the User clicks on the hotspot over the frame image.
    Thanks much.

    Thanks moccamaximum,
    By "do your tweens manually" you mean to use the timeline to do frame-based tweening? That is an option but I'm wondering (as a newbie): Isn't it better to use actionscript to do animation since you have more control and it's time based rather than frame-rate based (and works better on low performance machines)? Just curious if I should be spending the time to learn actionscript or do it in the traditional way.
    Thanks

  • How to disable items (gray out) in DataGrid control?

    Hi,
    I need to implement a custom component to have a selectable list with a maximum selected items.
    that is, when the selected items reach the max number, all un-selected items will be gray out.
    Now I am able to use DataGrid control to display a selectable "checkbox" (through itemRenderer) at first column, to let user select the item.
    And the list name in second column.
    But I can't find a way to gray out (disable) those un-selected item when max is reached.
    Can anyone give any advise?
    Here is my code snippet:
    SelectableListView.mxml
    <mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" width="100%" height="100%" visible="true">
    <mx:DataGrid id="list_datagrid" dataProvider="{this.stringList}" showHeaders="false"
    editable="false" selectable="true" verticalGridLines="false" borderStyle="none" alternatingItemColors="[#F8F8F0, #FFFFFF]"
    left="5" rowCount="16" rowHeight="20" height="83" width="100%" top="0" doubleClickEnabled="true" doubleClick="onDoubleClick(event)" >
      <mx:columns>
        <mx:DataGridColumn id="listCheckBox_col" dataField="selected" editable = "false"
                                        itemRenderer="ListRenderer" width="18" headerText="" resizable="false" draggable="false"/>
        <mx:DataGridColumn id="listName_col" dataField="name" />
      </mx:columns>
    </mx:DataGrid>
    </mx:VBox>
    ListRenderer.mxml
    <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="100%" height="60" >
         <mx:Script>
              <![CDATA[
                   private function setInUse() : void
                        _data.selected = listInUse.selected;
              ]]>
         </mx:Script>
      <mx:CheckBox id="listInUse" width="18" height="18" click="setInUse()" selected="{_data.selected}"/>
    </mx:Canvas>

    what is listInUse insdie the itemRenderer? I am not very clear about how you use
    it. However there are 2 ways of doing it. Not sure if data.selected can be used
    to enable/disable the itemrenderer. So I will asume not. Have an extra bindable
    "enabled" property in your dataProvider model. So when you reach the maximum of
    selected items iterate through the collection and set the set the enabled
    accordingly. The renderer's enabled property is bound to the model's enabled so
    it should update accordingly. The other way is to bind the enabled of the
    renderer on the selected. But as I said I am not sure how your code works ...
    HTH,
    C

  • Using Actionscript to create complete scenes

    Ok let me paint a picture. I'm designing an online flash
    application that will dynamically display tutorials stored in a
    MySQL database. These tutorials will be added via a php control
    panel for tutors to add new tutorials to the database.
    So my flash will load, dynamically create a new scene, add in
    some static elements i.e. logo and some other images and then list
    the tutorials for the user to select.
    The user then selects a tutorial and a new scene is
    dynamically created to display the contents of this scene i.e. a
    scrollPane for the text, video component for the video elements and
    the title etc.
    I recently read this tutorial so getting the data from the
    database into Flash shouldn't be a major problem.
    http://www.webmonkey.com/webmonkey/03/40/index1a.html
    Here's what I think I need
    I'm about to start digging through my flash bible so I'll
    edit this and let you know what I've found out myself,
    1. How to create a new scene using Actionscript,
    2. How to add a few images (jpgs) from the library using
    Actionscript,
    3. how to add a scrollPane (all using actionscript),
    4. how to add some text fields,
    5. how to add a video player to access a video from a folder
    on the server and lastly
    6. some kind of back button..
    Majority of these components will be loading content from PHP
    which will access my MySQL server.
    Any help would be greatly appreciated.
    Thanks
    Steve

    A tall order for a single thread! There are many possible
    answers to each question. Plus there are not enough specifics to
    guide you to the correct alternative. The good news it you can do
    what you are planning.
    1. How to create a new scene using Actionscript,
    Do not be confused with the technical feature of a scene in
    Flash IDE. It is not something you use in Actionscript. However
    from a design view, you can create any page oriented content
    application you want. The usually dynamic element for creating a
    page is a MovieClip or the as you mentioned the component
    ScrollPane which is MovieClip.
    Beyond that there are many many ways to go.
    In general you would create one or more template layouts and
    load the content in selecting the template.
    A shell Flash movie would handle the loading of the templates
    and the data or content that would show.
    As well there could be swf that are custom pages that simply
    load and handle all the needed content separately.
    2. How to add a few images (jpgs) from the library using
    Actionscript,
    MovieClip.attachMovie
    You also can load externally using
    MovieClip.loadMovie
    or if you need to manipulate it after loading then
    MovieClipLoad.onLoadInit
    3. how to add a scrollPane (all using actionscript),
    Explained at
    ScrollPane.contentPath">MovieClipLoad.onLoadInit
    4. how to add some text fields,
    The question implies to create the TextField dynamically and
    a central method is:
    MovieClip.createTextField
    5. how to add a video player to access a video from a folder
    on the server and lastly
    Use the FLVPlayback component that is delivered with Flash 8
    Pro. You need to encode the video as FLV format using the video
    encoder that comes with Flash 8 (also possible with import except
    you elected to make it external) or a third party encoder.
    You put the flv files on the server with the swf containing
    the FLVPlayer and use the
    FLVPlayback.contentPath
    method.
    6. some kind of back button..
    Again many many ways to go: You can use the Flash component
    button or create your own. You can make a button from a MovieClip.
    You can do these dynamically or at design time and in either case
    change their functionality and respond to their interactions at
    runtime.

  • Using Actionscript to draw a link button

    I cannot seem to get a linkButton to be displayed using
    actionscript. I have the following:
    button_lnk.label = "SHOW ME";
    button_lnk.visible = true;
    button_lnk.x = a *10 + 20;
    button_lnk.styleName = "topMenu";
    //Alert.show (button_lnk.label);
    button_lnk.width = 100;
    button_lnk.height = 30;
    button_lnk.includeInLayout = true;
    button_lnk.id = "link123_"
    This code is called in a function, and I do know the function
    is getting called
    Any ideas?
    Thanks

    i did not understand what you are looking for.
    Is it on how to create buttons with a custom style (or controls in general)?
    Then have a look at http://www.drdobbs.com/jvm/a-javafx-20-custom-control/229400781
    If you really want to know how to use the path class to draw anything, just pop up a sample stage and start drawing. The JavaDoc for Path provides some good examples.
    you could as well just phrase your exact problem.

  • Screens, like them? hate them? also, how to use actionscript with them.

    So I haven't used a flash version since Flash 8. I've now been given CS4 and inheritid a flash document that uses screens. After 2 weeks of figuring out how the presentation is made to 'go' from slide to slide on keydown, I finally discovered today that it is the default behaviour.
    Ok, so this leads me to my next question. How do people here feel about screens? Like them? Hate them? I feel like I could do half of this stuff easier with actionscript. I feel constrained by this. Not to mention I put some animation into a movie clip and it seems like it's not playing, like it's just poping right to the stop action at the end of that clip.
    Can anyone tell me how to use actionscript with screens? I looked at help, but of course, the help file doesn't give me what I really need to know. I'd like to put my actions on frame one of the root and let that control everything else. But what is the syntax like? The help file recommends external scripts, but that is not an option as the CEO takes this presentation with him and I can't risk having him lose the code.
    Please give me any advice you may have. Thank you!
    Stan

    Not that I'm any kind of expert on this matter, but I've never heard of screens, at least not by that name, and I have been fiddling with Flash for about 9 years now (like this case, I still learn new things all the time... though I'm still clueless as to what they are... chances are I won't miss 'em).
    When you mentioned scenes though, my personal recommendation is along the party lines of avoid them like the plague... use one timeline and/or movieclips for everything.  I have never used them in my own work, and my bias is partly due to having inherited them in other people's work... they make it hard to find things, especially when you have to first discover they're being used to begin with.  From a technical stance, I have found them to be problematic to manage as far as navigation goes.

  • How can I change Label's text using ActionScript?

    Hi~ everyone~
    I want change Label's text using ActionScript.
    Test.mxml
    <?xml version="1.0" encoding="utf-8"?>
    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
          xmlns:s="library://ns.adobe.com/flex/spark"
          xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" initialize="init()">
    <fx:Script>
      <![CDATA[
       private function init():void{
        var btn:BtnScript = new BtnScript();
        this.addElement(btn);
      ]]>
    </fx:Script>
    <fx:Declarations>
      <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>
    <s:Label x="182" y="149" text="Label" id="lbl"/>
    </s:Application>
    BtnScript.as
    package
    import flash.events.MouseEvent;
    import mx.controls.Alert;
    import spark.components.Button;
    public class BtnScript extends Button
      public function BtnScript()
       super();
       this.addEventListener(MouseEvent.CLICK, eventHandler);
      private function eventHandler(event:MouseEvent):void{
              // lbl.text = "changed text";
           // HOW CAN I ACCESS LABEL IN MXML FILE?
    I'm about to learn flex. Please help me.
    Thanks in advanced.

    You could achive this very easily(but this shouldn't be used in production code as it'll be difficult to manage as the project grows) by defining a static data member varibale of DataType Label something like below, (modified/added code in BOLD)
    Test.mxml
    <?xml version="1.0" encoding="utf-8"?>
    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
          xmlns:s="library://ns.adobe.com/flex/spark"
          xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" initialize="init()"
          creationComplete="creationCompleteHandler(event)">
    <fx:Script>
      <![CDATA[
       private function init():void{
         var btn:BtnScript = new BtnScript();
         this.addElement(btn);
       private function creationCompleteHandler(event:FlexEvent):void{
         Model.someLabel = lbl;
      ]]>
    </fx:Script>
    <fx:Declarations>
      <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>
    <s:Label x="182" y="149" text="Label" id="lbl"/>
    </s:Application>
    BtnScript.as
    package
      import flash.events.MouseEvent;
      import mx.controls.Alert;
      import spark.components.Button;
      public class BtnScript extends Button
        public function BtnScript()
          super();
          this.addEventListener(MouseEvent.CLICK, eventHandler);
        private function eventHandler(event:MouseEvent):void{
              // lbl.text = "changed text";
          // Now use Model.someLabel which is basically 'lbl'.
          Model.someLabel.text = "changed text";  //Mission Accomplished....
    Model.as
    package
      public class Model
        public static someLabel:Label;
    Note: This approach is just to give you an idea but instead should use the MVC pattern.

  • Retrieving values from table control using DYNP_VALUES_READ

    Hi all,
    I am trying to retrieve the values from the table control using the FM DYNP_VALUES_READ. I have a situation where user enter values in table control in T.code FB60 in Withholding tab for validation purpose. There i'll have to check based on some entries maintained in SET.
    I am unable to get the values when i scroll to the next page in the table control. FM raising an exception invalid_dynprofield.
    Expecting reply...

    You have to populate the dynpfields internal table before calling the function,
    data: repid like sy-repid.
    dynpfields-fieldname = 'PNAME'.
    append dynpfields.
    repid = sy-repid.
    call function 'DYNP_VALUES_READ'
    exporting
    dyname = repid
    dynumb = sy-dynnr
    tables
    dynpfields = dynpfields
    exceptions
    others.
    read table dynpfields index 1.
    pname = dynpfields-fieldvalue.
    Now you will have the field value in pname
    Hope this helps
    Vinodh Balakrishnan

  • How to implement line selectability for a table control using table Wizard?

    Hello SDN Community,
    I have created a table control using the Table Wizard.  I found my exact question in this forum, but unfortunately it had not been andsered.  While I cannot paste a screen-print into this plane-text area, here are the steps I followed...
    1) SE51
    2) Create new screen 0100
    3) Click Layout button
    4) Clidk Table Control (with Wizard) and draw box on canvas.
    5) Step is "Start" - click Continue
    6) Step is "Name of Table Control" - provided name
    7) Step is "Table Name" - provided name of dictionary table (AUFK)
    8) Step is "Definition of Columns" - selected order numver and order text
    9) Step is "Table Control Attributes" - Line Selectability is in display mode - cannot set it.
    I would like to have a selectability column for my table.  Would appreciate any insight into how to do this.
    Thank you,
    Dean Atteberry.

    This is a puzzling...
    For the table control wizard, in the Table Control Attributes step, I was able to get line selectability to open up by declaring a char01 data element at the beginning of my type.
    The puzzling is in regards to the "Selection col. fld" entry field.
    If I leave it blank and try to go to the next step, I get message "Enter the name of the selection column if you are using a program table"
    So it looked like it wanted to know the name of my selection column.  So I type in "CHAR1".  and got the message "The field "CHAR1" for the selection column is already contained in the table."
    Hmmmmm.... don't understand............
    Dean Atteberry.

  • Do you need to use Actionscript 3 code in Flash player 9 and above?

    Can anyone tell me if I need to use Actionscript 3 code instead of Actionscript 2 code in the following situation:
    I am running a swf file which is contained in a browser window (all files are contained on a CD and I have a 'trust' file set up to let them play properly).  Up until now, I have been using the following Actionscript 2 code to close the browser window (the Actionscript 2 code is on an 'Exit' button within the swf):
    on (release) {
    getURL("javascript:window.close()");
    This Actionscript 2 code has always worked and still works in Flash player 8 and lower.  However, it does nothing when played using Flash player 9.  Can anyone tell me if Flash player 9 won't recognize Actionscript 2 code?  Is it essential to use ONLY Actionscript 3 code if you are using Flash player 9?
    I am having the same problem when I try to launch another html page containing a swf (popped up from the swf contained in the main html window).  I have the following code on the button to launch the popup html window.  It always worked, but suddenly no longer works with Flash player 9.  Here is the code I am using:
    on (release) {
                getURL("javascript:launchWin2('webpage2.html');");
    I have all the necessary background code to launch 'webpage2.html'.  It works everywhere except in Flash player 9.  Can anyone tell me if it is essential to use Actionscript 3 code ONLY on these buttons in Flash player 9?  I am pretty new to Actionscript 3, so any help with syntax would be appreciated. 
    Please note that I don't want to use the projector.
    Thanks!

    You can use both AS2 and AS3 based applications in both Flash 9 and 10.
    As for the issues you describe - perhaps Flash General Forum is a better bet:
    http://forums.adobe.com/community/flash/flash_general

  • How can I reference a winforms control using a variable in Powershell?

    I have a powershell winform that has a lot of text boxes, but for the sake of this post, lets say I have 5. I want to loop through the 5 text boxes to see if their text property is empty. If the textbox contains something, I want to add the text value to
    an array. Here's an example of what I'm trying to do.
    textbox1.text = "Red"
    textbox2.text = ""
    textbox3.text = "Blue"
    textbox4.text = ""
    textbox5.text = ""
    $MyArray = @()
    for ($i = 1; $i -le 5; $i++) {
    If ($textbox[$i].text -ne "") {
    $MyArray += $textbox[$i].text
    I realize the textbox object is not an array so this code will not work. I guess the simple question is, How can I reference a set of static controls using a variable without having to do something like this
    [object[]]$textboxes = New-Object System.Windows.Forms.TextBox
    For ($i = 1; $i -lt 5; $i++) {
    $textboxes += New-Object windows.forms.textbox
    $textboxes[$i].DataBindings.DefaultDataSourceUpdateMode = [System.Windows.Forms.DataSourceUpdateMode]::OnValidation
    $textboxes[$i].Name = $textboxes[$i]
    $BoxItems.Controls.Add($textboxes[$i])

    Hi D-Dub,
    here are two ways to retrieve the text value of $Textbox1:
    $Textbox1.Text
    (Get-Variable "Textbox1").Value.Text
    Now what could you do with the second way, inside a loop, I wonder ... ;)
    Cheers,
    Fred
    There's no place like 127.0.0.1

  • DYNAMIC CREATION OF LINE SERIES USING ACTIONSCRIPT

    There's something wierd about flex or im doing something
    wrong?
    - when i create a line series manually using mxml and specify
    a id for the series, it works.
    - similarly when i try to dynamically create a line series
    using actionscript & define an "id" property, flex does not
    understand! what am i doing wrong?
    code for reference:
    private function addSeries(series:Array,
    yField:String,id:String) // addseries(series,"date","1000")
    var ls:LineSeries= new LineSeries();
    var stroke:Stroke = new Stroke()
    ls.yField = yField;
    ls.xField="ts"
    ls.dataProvider=dp
    ls.id=id // tried defining it dynamically, but flex does not
    find
    this.mychart.series.push(ls)
    THIS IS THE ERROR I GET : "TypeError: Error #1010: A term is
    undefined and has no properties."

    I see... I played around with the line chart ...
    Hopefully this helps... if not forgive me...
    I know why you are trying to use the id property which i
    agree doesn't work.
    since the series is an array in your lineChart use the index
    to set the visible property false/true.
    lineChart.series[0].visible = true/false;
    <mx:Lineseries id="a1" visible="true"
    dataProvider="{whatever}" />
    <mx:Lineseries id="a2" visible="false"
    dataProvider="{whatever}"/>
    create a function called init();
    public function init():void
    var lineS1:LineSeries = new LineSeries();
    lineS1.visible = true/false;
    lineChart.series.push(lineS1);
    var lineS2:LineSeries = new LineSeries();
    lineS2.visible = true/false;
    lineChart.series.push(lineS2);
    ... and the key is to call this init function on initialize
    event...NOT on createComplete event
    <mx:LineChart.... initialize="init()" .... />
    and to show both lines... call this function...
    public function showLines():void
    lineChart.series[0].visible = true;
    lineChart.series[1].visible = true;
    Hope this helps....

Maybe you are looking for