Skip navigation
Currently Being Moderated

Reference to child element

Dec 17, 2013 6:19 AM

Tags: #air #flex #actionscript_3.0

How can we reference to an element which is added dynamically on runtime?

Example code:

<?xml version="1.0" encoding="utf-8"?>

<s:WindowedApplication xmlns:fx="" xmlns:s="library://"

    xmlns:mx="library://" applicationComplete="init(event)">





    protected function init(event:FlexEvent):void {


        var newbtn:Button = new Button();

        newbtn.label = "New Button"; = "button3"; = "button3"; 









<s:HGroup id="mygroup">

    <s:Button id="button1" label="Button 1" />

    <s:Button id="button2" label="Button 2" />




When I try to run above code, it dispatch error

Error #1069: Property button3 not found on project1 and there is no default value.

So, how can I call to the newly added button?


Thank you.


More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points