Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6470839
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:09:24+00:00 2026-05-25T06:09:24+00:00

I am declaring a variable outside the itemRenderer fx:Script body. However when I am

  • 0

I am declaring a variable outside the itemRenderer fx:Script body. However when I am setting it as such in my itemRenderer:

test_Var = data.@field_value;

It is giving an error “Access of undefined property test_Var”

Can I have 2 bodies, one inside the itemrenderer and the usual outside one?

    public var test_Var:Number = new Number();
    public function useVariableValue():void{
   // I will use the variable value in this function..
}
        ]]>
                                    </fx:Script>




    <mx:DataGrid id="myDG" rowCount="8" creationComplete="myDG_creationCompleteHandler(event)" resizableColumns="false" height="234">
                <mx:columns>
                    <mx:DataGridColumn headerRenderer="renderers.datagridHeaderRenderer" dataField="@field_label" headerText="Header1" width="130" />
                    <mx:DataGridColumn dataField="@field_value" headerText="Header2" itemRenderer="renderers.labelItemRenderer1" />
                    <mx:DataGridColumn headerText="Header3">
                        <mx:itemRenderer>
                            <fx:Component>
                                <mx:Canvas dataChange="canvas1_dataChangeHandler(event)">
                                    <s:Button horizontalCenter="1" id="button" click="onClick(event)" label="View"/>
                                    <fx:Script>
                                        <![CDATA[
                                            import mx.controls.Alert;
                                            import mx.events.FlexEvent;

                                            protected function canvas1_dataChangeHandler(event:FlexEvent):void
                                            {
                                                if(data.@field_visibility == "true"){
                                                    this.button.visible = true;
                                                }
                                                else{
                                                    this.button.visible = false;
                                                }
                                            }

                                            private function onClick(evt:Event):void
                                            {
                                                test_Var = data.@field_value;
                                            }
                                        ]]>
                                    </fx:Script>
                                </mx:Canvas>
                            </fx:Component>
                        </mx:itemRenderer>
                    </mx:DataGridColumn>
                </mx:columns>
            </mx:DataGrid>*
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T06:09:24+00:00Added an answer on May 25, 2026 at 6:09 am

    fx:Component defines a totally new scope. You can only access properties in your initial scope by using the outerDocument keyword.

    In your case change it to this:

    private function onClick(evt:Event):void
    {
        outerDocument.test_Var = data.@field_value;
    }
    

    For more information read (see the section on outerDocument):

    http://www.adobe.com/devnet/flex/articles/itemrenderers_pt1.html

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What is better for performance wise declaring the variable outside the foreach statment and
Is there a difference between declaring a static variable outside of a function and
I wish to define a type String such that declaring a variable of type
I'm loading an XML in SQL using OpenXML while declaring the variable the max
In C, declaring a variable static in the global scope makes it a global
In Java, there is a practice of declaring every variable (local or class), parameter
In Objective-C, what's the difference between declaring a variable id versus declaring it NSObject
Is there a difference in declaring the enabled variable as Boolean or boolean? Which
I have always wondered if, in general, declaring a throw-away variable before a loop,
Are declaring custom .NET event such as this , more common in a winform

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.