Nested TabNabvigator/Repeater error

classic Classic list List threaded Threaded
16 messages Options
Reply | Threaded
Open this post in threaded view
|

Nested TabNabvigator/Repeater error

Tom McNeer
Hi,

I am trying to create nested TabNavigators which are built dynamically from
server data. The top TabNavigator is static. Its children are created by a
Repeater. Within each Repeater's child (VBox), another TabNavigator is
created, and a second Repeater creates the children of the TabNavigator.

This is a revision of a old application, so it's using a 3.6 SDK.

The top level tabs represent types of Documents. The second level of tabs
represent subtypes. And each time this area is accessed, there will be
different trees of types/subtype/documents.

The process throws an error intermittently as the elements are created:

RangeError: Error #2006: The supplied index is out of bounds.
    at flash.display::DisplayObjectContainer/getChildAt()
    at
mx.core::Container/getChildAt()[C:\autobuild\3.x\frameworks\projects\framework\src\mx\core\Container.as:2377]
    at
mx.controls::ToggleButtonBar/hiliteSelectedNavItem()[C:\autobuild\3.x\frameworks\projects\framework\src\mx\controls\ToggleButtonBar.as:441]
    at
mx.controls::ToggleButtonBar/updateDisplayList()[C:\autobuild\3.x\frameworks\projects\framework\src\mx\controls\ToggleButtonBar.as:364]
    at
mx.core::UIComponent/validateDisplayList()[C:\autobuild\3.x\frameworks\projects\framework\src\mx\core\UIComponent.as:6510]
    at
mx.core::Container/validateDisplayList()[C:\autobuild\3.x\frameworks\projects\framework\src\mx\core\Container.as:2720]
    at
mx.managers::LayoutManager/validateDisplayList()[C:\autobuild\3.x\frameworks\projects\framework\src\mx\managers\LayoutManager.as:622]
    at
mx.managers::LayoutManager/doPhasedInstantiation()[C:\autobuild\3.x\frameworks\projects\framework\src\mx\managers\LayoutManager.as:677]
    at Function/http://adobe.com/AS3/2006/builtin::apply()
    at
mx.core::UIComponent/callLaterDispatcher2()[C:\autobuild\3.x\frameworks\projects\framework\src\mx\core\UIComponent.as:8892]
    at
mx.core::UIComponent/callLaterDispatcher()[C:\autobuild\3.x\frameworks\projects\framework\src\mx\core\UIComponent.as:8832]

Since the error reference is to getChildAt(), and before that, to
hiliteSelectedNavItem, I assume that the error is coming as the framework
tries to select a tab that does not exist. But I have no clue what to do
about it.

Here is the opening MXML:

<mx:TabNavigator id="docTabs" width="100%"  height="100%" x="5" y="5"
backgroundAlpha="0.0" borderThickness="1" paddingTop="0"
creationPolicy="all">
        <mx:Repeater id="docTypes" dataProvider="{acCaseDocuments}"
recycleChildren="false">
            <mx:VBox id="docType"  horizontalAlign="center"
label="{docTypes.currentItem.friendlyName}" height="95%" width="95%"
styleName="contentWhite">
                <mx:TabNavigator id="docSubtabs" width="100%"
height="100%" x="5" y="5" backgroundAlpha="0.0" borderThickness="1"
paddingTop="0" creationPolicy="all">
                    <mx:Repeater id="docSubtypes"
dataProvider="{docTypes.currentItem.subtypes}" recycleChildren="false">
                        <mx:VBox id="docSubtype" horizontalAlign="center"
label="{docSubtypes.currentItem.friendlyName}" height="95%" width="95%"
styleName="contentWhite">

I have also tried creating the elements in ActionScript, to bypass the
Repeater action. This results in no errors. Both levels of tabs appear to
be created properly (by "appear," I mean "visually.") However, when a tab
on the second level (the subtypes) is clicked, rather than the selected
chlid appearing, the user is switched to an entirely different screen -
completely away from the Documents area.

I don't know why the click is taking me away from the screen, but as I walk
through the debugging, it appears that while the TabNavigator children are
created correctly, the children of its associated TabBar are not. Here's
the ActionScript, which is fired by a CollectionChangeEvent listener on the
ArrayCollection which contains the Document data:

private function buildUI(e:CollectionEvent):void{
                clearTabs();
                 for(var i:int=0;i<acCaseDocuments.length;i++){
                    var arSubtypes:Array = acCaseDocuments[i].subtypes as
Array;
                    var vb:VBox = new VBox();
                    vb.id='docType' + i;
                    vb.setStyle('horizontalAlign','center');
                    vb.label = acCaseDocuments[i].friendlyName as String;
                    vb.percentWidth=95;
                    vb.percentHeight=95;
                    vb.styleName='contentWhite';
                    var tn:TabNavigator = new TabNavigator();
                    tn.id='docSubtab' + i;
                    tn.percentWidth=100;
                    tn.percentHeight=100;
                    tn.x=5;
                    tn.y=5;
                    tn.setStyle("backgroundAlpha",0);
                    tn.setStyle('borderThickness',1);
                    tn.setStyle('paddingTop',0);
                    for(var j:int=0;j<arSubtypes.length;j++){
                        var ddg:DocDataGrid = new DocDataGrid();
                        ddg.id= 'docSubtype' + j;
                        ddg.label=arSubtypes[j].friendlyName as String;
                        ddg.percentWidth=95;
                        ddg.percentHeight=95;
                        ddg.gridData.source=arSubtypes[j].documents as
Array;
                        ddg.gridData.refresh();
                        tn.addChild(ddg);;
                    }
                    vb.addChild(tn);
                    docTabs.addChild(vb);
                }
            }

The "DocDataGrid" reference is simply a custom component that is a Box
containing a DataGrid.

Sorry for the lengthy post, but I wanted to make sure that the problem was
described thoroughly before I asked anyone for help.

Any thoughts on the issue would be greatly appreciated.

--
Thanks,

Tom

Tom McNeer
MediumCool
http://www.mediumcool.com
1735 Johnson Road NE
Atlanta, GA 30306
404.589.0560
Reply | Threaded
Open this post in threaded view
|

Re: Nested TabNabvigator/Repeater error

Alex Harui
Probably best to not use repeater.

In the AS version, I would guess there are relatively few ways to "switch to a different screen".  If you put a breakpoint on code that does that, does it get hit and will the stack info show you how it got there?

You might want to build out a simpler re-construction of this problem in a new Flex project so less of your other code can be run accidentally.

The TabBar children should just be Tabs that dispatch events.  The logic that responds to the change event should be the main concern.

-Alex

From: Tom McNeer <[hidden email]<mailto:[hidden email]>>
Reply-To: "[hidden email]<mailto:[hidden email]>" <[hidden email]<mailto:[hidden email]>>
Date: Tuesday, October 22, 2013 6:41 AM
To: "[hidden email]<mailto:[hidden email]>" <[hidden email]<mailto:[hidden email]>>
Subject: [flexcoders] Nested TabNabvigator/Repeater error



Hi,

I am trying to create nested TabNavigators which are built dynamically from server data. The top TabNavigator is static. Its children are created by a Repeater. Within each Repeater's child (VBox), another TabNavigator is created, and a second Repeater creates the children of the TabNavigator.

This is a revision of a old application, so it's using a 3.6 SDK.

The top level tabs represent types of Documents. The second level of tabs represent subtypes. And each time this area is accessed, there will be different trees of types/subtype/documents.

The process throws an error intermittently as the elements are created:

RangeError: Error #2006: The supplied index is out of bounds.
    at flash.display::DisplayObjectContainer/getChildAt()
    at mx.core::Container/getChildAt()[C:\autobuild\3.x\frameworks\projects\framework\src\mx\core\Container.as:2377]
    at mx.controls::ToggleButtonBar/hiliteSelectedNavItem()[C:\autobuild\3.x\frameworks\projects\framework\src\mx\controls\ToggleButtonBar.as:441]
    at mx.controls::ToggleButtonBar/updateDisplayList()[C:\autobuild\3.x\frameworks\projects\framework\src\mx\controls\ToggleButtonBar.as:364]
    at mx.core::UIComponent/validateDisplayList()[C:\autobuild\3.x\frameworks\projects\framework\src\mx\core\UIComponent.as:6510]
    at mx.core::Container/validateDisplayList()[C:\autobuild\3.x\frameworks\projects\framework\src\mx\core\Container.as:2720]
    at mx.managers::LayoutManager/validateDisplayList()[C:\autobuild\3.x\frameworks\projects\framework\src\mx\managers\LayoutManager.as:622]
    at mx.managers::LayoutManager/doPhasedInstantiation()[C:\autobuild\3.x\frameworks\projects\framework\src\mx\managers\LayoutManager.as:677]
    at Function/http://adobe.com/AS3/2006/builtin::apply()
    at mx.core::UIComponent/callLaterDispatcher2()[C:\autobuild\3.x\frameworks\projects\framework\src\mx\core\UIComponent.as:8892]
    at mx.core::UIComponent/callLaterDispatcher()[C:\autobuild\3.x\frameworks\projects\framework\src\mx\core\UIComponent.as:8832]

Since the error reference is to getChildAt(), and before that, to hiliteSelectedNavItem, I assume that the error is coming as the framework tries to select a tab that does not exist. But I have no clue what to do about it.

Here is the opening MXML:

<mx:TabNavigator id="docTabs" width="100%"  height="100%" x="5" y="5" backgroundAlpha="0.0" borderThickness="1" paddingTop="0" creationPolicy="all">
        <mx:Repeater id="docTypes" dataProvider="{acCaseDocuments}" recycleChildren="false">
            <mx:VBox id="docType"  horizontalAlign="center" label="{docTypes.currentItem.friendlyName}" height="95%" width="95%" styleName="contentWhite">
                <mx:TabNavigator id="docSubtabs" width="100%"  height="100%" x="5" y="5" backgroundAlpha="0.0" borderThickness="1" paddingTop="0" creationPolicy="all">
                    <mx:Repeater id="docSubtypes" dataProvider="{docTypes.currentItem.subtypes}" recycleChildren="false">
                        <mx:VBox id="docSubtype" horizontalAlign="center" label="{docSubtypes.currentItem.friendlyName}" height="95%" width="95%" styleName="contentWhite">

I have also tried creating the elements in ActionScript, to bypass the Repeater action. This results in no errors. Both levels of tabs appear to be created properly (by "appear," I mean "visually.") However, when a tab on the second level (the subtypes) is clicked, rather than the selected chlid appearing, the user is switched to an entirely different screen - completely away from the Documents area.

I don't know why the click is taking me away from the screen, but as I walk through the debugging, it appears that while the TabNavigator children are created correctly, the children of its associated TabBar are not. Here's the ActionScript, which is fired by a CollectionChangeEvent listener on the ArrayCollection which contains the Document data:

private function buildUI(e:CollectionEvent):void{
                clearTabs();
                 for(var i:int=0;i<acCaseDocuments.length;i++){
                    var arSubtypes:Array = acCaseDocuments[i].subtypes as Array;
                    var vb:VBox = new VBox();
                    vb.id<http://vb.id>='docType' + i;
                    vb.setStyle('horizontalAlign','center');
                    vb.label = acCaseDocuments[i].friendlyName as String;
                    vb.percentWidth=95;
                    vb.percentHeight=95;
                    vb.styleName='contentWhite';
                    var tn:TabNavigator = new TabNavigator();
                    tn.id<http://tn.id>='docSubtab' + i;
                    tn.percentWidth=100;
                    tn.percentHeight=100;
                    tn.x=5;
                    tn.y=5;
                    tn.setStyle("backgroundAlpha",0);
                    tn.setStyle('borderThickness',1);
                    tn.setStyle('paddingTop',0);
                    for(var j:int=0;j<arSubtypes.length;j++){
                        var ddg:DocDataGrid = new DocDataGrid();
                        ddg.id<http://ddg.id>= 'docSubtype' + j;
                        ddg.label=arSubtypes[j].friendlyName as String;
                        ddg.percentWidth=95;
                        ddg.percentHeight=95;
                        ddg.gridData.source=arSubtypes[j].documents as Array;
                        ddg.gridData.refresh();
                        tn.addChild(ddg);;
                    }
                    vb.addChild(tn);
                    docTabs.addChild(vb);
                }
            }

The "DocDataGrid" reference is simply a custom component that is a Box containing a DataGrid.

Sorry for the lengthy post, but I wanted to make sure that the problem was described thoroughly before I asked anyone for help.

Any thoughts on the issue would be greatly appreciated.

--
Thanks,

Tom

Tom McNeer
MediumCool
http://www.mediumcool.com
1735 Johnson Road NE
Atlanta, GA 30306
404.589.0560


Reply | Threaded
Open this post in threaded view
|

Re: Nested TabNabvigator/Repeater error

Tom McNeer
Hi Alex,

Thanks very much for the reply.


On Tue, Oct 22, 2013 at 12:56 PM, Alex Harui <[hidden email]> wrote:

> In the AS version, I would guess there are relatively few ways to "switch
> to a different screen".
>

Yeah, I would agree. The reason I used the vague "switch to a different
screen" is that the resulting action is nothing that is called in the
component or even its parent.

I'll lay this out as quickly as I can:

There's a view we'll call Cases which has a ViewStack that consists of
"Case Results" and "Case Details." A search triggered from a parent of the
Cases view results in a grid in Case Results being populated. A click on a
row in the grid calls the server for data on an individual Case and
switches to the Case Details view.

That view contains a TabNavigator for various aspects of the Case,
including Documents. The nested TabNavigators I'm trying to create are
within that Documents view.

When I say that a click on any second-level (Document subtype) tab goes "to
a different screen," what happens is that everything is switched back to
the Case Results view - taking you back to the first element in the Cases
ViewStack. There's no action or event defined in any of the child views
inside the Case Details TabNavigator that would switch the view that way.

That's why I find it confounding.


> If you put a breakpoint on code that does that, does it get hit and will
> the stack info show you how it got there?
>

The code would be in the framework. It would just be the handler for a
click on the TabBar.


> The TabBar children should just be Tabs that dispatch events.  The logic
> that responds to the change event should be the main concern.
>

Thanks. I understand that. But I'm not writing any code to react to the
click event. It's just the default action from the framework, which should
be to make the box corresponding to the Tab the selectedChild of the
TabNaviagator.

I have tried walking through my ActionScript, and the oddity I see (which I
may not really understand) is that even after all the custom components are
added as children to one of the second-level TabNavigators, the
TabNavigator and its TabBar show in debugging as having a different number
of children.



--
Thanks,

Tom

Tom McNeer
MediumCool
http://www.mediumcool.com
1735 Johnson Road NE
Atlanta, GA 30306
404.589.0560
Reply | Threaded
Open this post in threaded view
|

Re: Nested TabNabvigator/Repeater error

Alex Harui
I'm not sure what you mean by "the framework".  AFAIK, the framework doesn't have any code that automatically switches ViewStack views based on mouse activity.

But you could put a breakpoint on the ViewStack code and see why it is changing.

-Alex

From: Tom McNeer <[hidden email]<mailto:[hidden email]>>
Reply-To: "[hidden email]<mailto:[hidden email]>" <[hidden email]<mailto:[hidden email]>>
Date: Tuesday, October 22, 2013 12:30 PM
To: "[hidden email]<mailto:[hidden email]>" <[hidden email]<mailto:[hidden email]>>
Subject: Re: [flexcoders] Nested TabNabvigator/Repeater error



Hi Alex,

Thanks very much for the reply.


On Tue, Oct 22, 2013 at 12:56 PM, Alex Harui <[hidden email]<mailto:[hidden email]>> wrote:
In the AS version, I would guess there are relatively few ways to "switch to a different screen".

Yeah, I would agree. The reason I used the vague "switch to a different screen" is that the resulting action is nothing that is called in the component or even its parent.

I'll lay this out as quickly as I can:

There's a view we'll call Cases which has a ViewStack that consists of "Case Results" and "Case Details." A search triggered from a parent of the Cases view results in a grid in Case Results being populated. A click on a row in the grid calls the server for data on an individual Case and switches to the Case Details view.

That view contains a TabNavigator for various aspects of the Case, including Documents. The nested TabNavigators I'm trying to create are within that Documents view.

When I say that a click on any second-level (Document subtype) tab goes "to a different screen," what happens is that everything is switched back to the Case Results view - taking you back to the first element in the Cases ViewStack. There's no action or event defined in any of the child views inside the Case Details TabNavigator that would switch the view that way.

That's why I find it confounding.

If you put a breakpoint on code that does that, does it get hit and will the stack info show you how it got there?

The code would be in the framework. It would just be the handler for a click on the TabBar.

The TabBar children should just be Tabs that dispatch events.  The logic that responds to the change event should be the main concern.

Thanks. I understand that. But I'm not writing any code to react to the click event. It's just the default action from the framework, which should be to make the box corresponding to the Tab the selectedChild of the TabNaviagator.

I have tried walking through my ActionScript, and the oddity I see (which I may not really understand) is that even after all the custom components are added as children to one of the second-level TabNavigators, the TabNavigator and its TabBar show in debugging as having a different number of children.



--
Thanks,

Tom

Tom McNeer
MediumCool
http://www.mediumcool.com
1735 Johnson Road NE
Atlanta, GA 30306
404.589.0560


Reply | Threaded
Open this post in threaded view
|

Re: Nested TabNabvigator/Repeater error

Tom McNeer
Alex,

Thanks again for your reply. Sorry I was unclear. I wasn't suggesting that
the framework had code to switch the ViewStack on click.

I was responding to your comment about the concern being the logic that
responds to the change in the TabNavigator and TabBar. And I simply meant
that my code does not contain any handlers for any actions on the
TabNavigators created in my AS code, nor on the underlying TabBars. But
rather, the click on the visible Tab that _appears_ to be responsible for
switching the ViewStack is being handled somehow by the framework, since I
have not overridden it.

I realize that the proper course would be to follow the event into the
framework files. However, in my initial post, I was hoping that someone
might have experienced a similar problem and know a simple solution.

I am now trying to follow the event down into the framework. But I'm
running into what seems like a dumb problem: I am unable to set breakpoints
in the framework files. I can search for and open class files in the
correct version of the framework; but a right-click in the left margin does
not bring up a context menu at all.

The framework is being merged into the code at compile time.

I know this may be a silly question, but can you tell me why Flash Builder
(4.6) might be acting this way?


On Wed, Oct 23, 2013 at 2:40 AM, Alex Harui <[hidden email]> wrote:

> **
>
>
> I'm not sure what you mean by "the framework".  AFAIK, the framework
> doesn't have any code that automatically switches ViewStack views based on
> mouse activity.
>
> But you could put a breakpoint on the ViewStack code and see why it is
> changing.
>
> -Alex
>
> From: Tom McNeer <[hidden email]>
> Reply-To: "[hidden email]" <[hidden email]>
> Date: Tuesday, October 22, 2013 12:30 PM
> To: "[hidden email]" <[hidden email]>
> Subject: Re: [flexcoders] Nested TabNabvigator/Repeater error
>
>
>
> Hi Alex,
>
> Thanks very much for the reply.
>
>
> On Tue, Oct 22, 2013 at 12:56 PM, Alex Harui <[hidden email]> wrote:
>
>> In the AS version, I would guess there are relatively few ways to "switch
>> to a different screen".
>>
>
> Yeah, I would agree. The reason I used the vague "switch to a different
> screen" is that the resulting action is nothing that is called in the
> component or even its parent.
>
> I'll lay this out as quickly as I can:
>
> There's a view we'll call Cases which has a ViewStack that consists of
> "Case Results" and "Case Details." A search triggered from a parent of the
> Cases view results in a grid in Case Results being populated. A click on a
> row in the grid calls the server for data on an individual Case and
> switches to the Case Details view.
>
> That view contains a TabNavigator for various aspects of the Case,
> including Documents. The nested TabNavigators I'm trying to create are
> within that Documents view.
>
> When I say that a click on any second-level (Document subtype) tab goes
> "to a different screen," what happens is that everything is switched back
> to the Case Results view - taking you back to the first element in the
> Cases ViewStack. There's no action or event defined in any of the child
> views inside the Case Details TabNavigator that would switch the view that
> way.
>
> That's why I find it confounding.
>
>
>> If you put a breakpoint on code that does that, does it get hit and will
>> the stack info show you how it got there?
>>
>
> The code would be in the framework. It would just be the handler for a
> click on the TabBar.
>
>
>> The TabBar children should just be Tabs that dispatch events.  The logic
>> that responds to the change event should be the main concern.
>>
>
> Thanks. I understand that. But I'm not writing any code to react to the
> click event. It's just the default action from the framework, which should
> be to make the box corresponding to the Tab the selectedChild of the
> TabNaviagator.
>
> I have tried walking through my ActionScript, and the oddity I see (which
> I may not really understand) is that even after all the custom components
> are added as children to one of the second-level TabNavigators, the
> TabNavigator and its TabBar show in debugging as having a different number
> of children.
>
>
>
> --
> Thanks,
>
> Tom
>
> Tom McNeer
> MediumCool
> http://www.mediumcool.com
> 1735 Johnson Road NE
> Atlanta, GA 30306
> 404.589.0560
>
>  
>



--
Thanks,

Tom

Tom McNeer
MediumCool
http://www.mediumcool.com
1735 Johnson Road NE
Atlanta, GA 30306
404.589.0560
Reply | Threaded
Open this post in threaded view
|

Re: Nested TabNabvigator/Repeater error

Alex Harui
Never tried right clicking on the framework files before.  You're right that it doesn't work.  But double-clicking should set a breakpoint.  It does for me.

From: Tom McNeer <[hidden email]<mailto:[hidden email]>>
Reply-To: "[hidden email]<mailto:[hidden email]>" <[hidden email]<mailto:[hidden email]>>
Date: Thursday, October 24, 2013 7:44 AM
To: "[hidden email]<mailto:[hidden email]>" <[hidden email]<mailto:[hidden email]>>
Subject: Re: [flexcoders] Nested TabNabvigator/Repeater error



Alex,

Thanks again for your reply. Sorry I was unclear. I wasn't suggesting that the framework had code to switch the ViewStack on click.

I was responding to your comment about the concern being the logic that responds to the change in the TabNavigator and TabBar. And I simply meant that my code does not contain any handlers for any actions on the TabNavigators created in my AS code, nor on the underlying TabBars. But rather, the click on the visible Tab that _appears_ to be responsible for switching the ViewStack is being handled somehow by the framework, since I have not overridden it.

I realize that the proper course would be to follow the event into the framework files. However, in my initial post, I was hoping that someone might have experienced a similar problem and know a simple solution.

I am now trying to follow the event down into the framework. But I'm running into what seems like a dumb problem: I am unable to set breakpoints in the framework files. I can search for and open class files in the correct version of the framework; but a right-click in the left margin does not bring up a context menu at all.

The framework is being merged into the code at compile time.

I know this may be a silly question, but can you tell me why Flash Builder (4.6) might be acting this way?


On Wed, Oct 23, 2013 at 2:40 AM, Alex Harui <[hidden email]<mailto:[hidden email]>> wrote:


I'm not sure what you mean by "the framework".  AFAIK, the framework doesn't have any code that automatically switches ViewStack views based on mouse activity.

But you could put a breakpoint on the ViewStack code and see why it is changing.

-Alex

From: Tom McNeer <[hidden email]<mailto:[hidden email]>>
Reply-To: "[hidden email]<mailto:[hidden email]>" <[hidden email]<mailto:[hidden email]>>
Date: Tuesday, October 22, 2013 12:30 PM
To: "[hidden email]<mailto:[hidden email]>" <[hidden email]<mailto:[hidden email]>>
Subject: Re: [flexcoders] Nested TabNabvigator/Repeater error



Hi Alex,

Thanks very much for the reply.


On Tue, Oct 22, 2013 at 12:56 PM, Alex Harui <[hidden email]<mailto:[hidden email]>> wrote:
In the AS version, I would guess there are relatively few ways to "switch to a different screen".

Yeah, I would agree. The reason I used the vague "switch to a different screen" is that the resulting action is nothing that is called in the component or even its parent.

I'll lay this out as quickly as I can:

There's a view we'll call Cases which has a ViewStack that consists of "Case Results" and "Case Details." A search triggered from a parent of the Cases view results in a grid in Case Results being populated. A click on a row in the grid calls the server for data on an individual Case and switches to the Case Details view.

That view contains a TabNavigator for various aspects of the Case, including Documents. The nested TabNavigators I'm trying to create are within that Documents view.

When I say that a click on any second-level (Document subtype) tab goes "to a different screen," what happens is that everything is switched back to the Case Results view - taking you back to the first element in the Cases ViewStack. There's no action or event defined in any of the child views inside the Case Details TabNavigator that would switch the view that way.

That's why I find it confounding.

If you put a breakpoint on code that does that, does it get hit and will the stack info show you how it got there?

The code would be in the framework. It would just be the handler for a click on the TabBar.

The TabBar children should just be Tabs that dispatch events.  The logic that responds to the change event should be the main concern.

Thanks. I understand that. But I'm not writing any code to react to the click event. It's just the default action from the framework, which should be to make the box corresponding to the Tab the selectedChild of the TabNaviagator.

I have tried walking through my ActionScript, and the oddity I see (which I may not really understand) is that even after all the custom components are added as children to one of the second-level TabNavigators, the TabNavigator and its TabBar show in debugging as having a different number of children.



--
Thanks,

Tom

Tom McNeer
MediumCool
http://www.mediumcool.com
1735 Johnson Road NE
Atlanta, GA 30306
404.589.0560<tel:404.589.0560>



--
Thanks,

Tom

Tom McNeer
MediumCool
http://www.mediumcool.com
1735 Johnson Road NE
Atlanta, GA 30306
404.589.0560


Reply | Threaded
Open this post in threaded view
|

Re: Nested TabNabvigator/Repeater error

Tom McNeer
And weirdly enough, I had never double-clicked. You're right. It works.
Thanks.

I'll probably have more question once I start following the event.


On Thu, Oct 24, 2013 at 12:32 PM, Alex Harui <[hidden email]> wrote:

> **
>
>
> Never tried right clicking on the framework files before.  You're right
> that it doesn't work.  But double-clicking should set a breakpoint.  It
> does for me.
>
> From: Tom McNeer <[hidden email]>
> Reply-To: "[hidden email]" <[hidden email]>
> Date: Thursday, October 24, 2013 7:44 AM
>
> To: "[hidden email]" <[hidden email]>
> Subject: Re: [flexcoders] Nested TabNabvigator/Repeater error
>
>
>
> Alex,
>
> Thanks again for your reply. Sorry I was unclear. I wasn't suggesting that
> the framework had code to switch the ViewStack on click.
>
> I was responding to your comment about the concern being the logic that
> responds to the change in the TabNavigator and TabBar. And I simply meant
> that my code does not contain any handlers for any actions on the
> TabNavigators created in my AS code, nor on the underlying TabBars. But
> rather, the click on the visible Tab that _appears_ to be responsible for
> switching the ViewStack is being handled somehow by the framework, since I
> have not overridden it.
>
> I realize that the proper course would be to follow the event into the
> framework files. However, in my initial post, I was hoping that someone
> might have experienced a similar problem and know a simple solution.
>
> I am now trying to follow the event down into the framework. But I'm
> running into what seems like a dumb problem: I am unable to set breakpoints
> in the framework files. I can search for and open class files in the
> correct version of the framework; but a right-click in the left margin does
> not bring up a context menu at all.
>
> The framework is being merged into the code at compile time.
>
> I know this may be a silly question, but can you tell me why Flash Builder
> (4.6) might be acting this way?
>
>
> On Wed, Oct 23, 2013 at 2:40 AM, Alex Harui <[hidden email]> wrote:
>
>> **
>>
>>
>> I'm not sure what you mean by "the framework".  AFAIK, the framework
>> doesn't have any code that automatically switches ViewStack views based on
>> mouse activity.
>>
>> But you could put a breakpoint on the ViewStack code and see why it is
>> changing.
>>
>> -Alex
>>
>> From: Tom McNeer <[hidden email]>
>> Reply-To: "[hidden email]" <[hidden email]>
>> Date: Tuesday, October 22, 2013 12:30 PM
>> To: "[hidden email]" <[hidden email]>
>> Subject: Re: [flexcoders] Nested TabNabvigator/Repeater error
>>
>>
>>
>> Hi Alex,
>>
>> Thanks very much for the reply.
>>
>>
>> On Tue, Oct 22, 2013 at 12:56 PM, Alex Harui <[hidden email]> wrote:
>>
>>> In the AS version, I would guess there are relatively few ways to
>>> "switch to a different screen".
>>>
>>
>> Yeah, I would agree. The reason I used the vague "switch to a different
>> screen" is that the resulting action is nothing that is called in the
>> component or even its parent.
>>
>> I'll lay this out as quickly as I can:
>>
>> There's a view we'll call Cases which has a ViewStack that consists of
>> "Case Results" and "Case Details." A search triggered from a parent of the
>> Cases view results in a grid in Case Results being populated. A click on a
>> row in the grid calls the server for data on an individual Case and
>> switches to the Case Details view.
>>
>> That view contains a TabNavigator for various aspects of the Case,
>> including Documents. The nested TabNavigators I'm trying to create are
>> within that Documents view.
>>
>> When I say that a click on any second-level (Document subtype) tab goes
>> "to a different screen," what happens is that everything is switched back
>> to the Case Results view - taking you back to the first element in the
>> Cases ViewStack. There's no action or event defined in any of the child
>> views inside the Case Details TabNavigator that would switch the view that
>> way.
>>
>> That's why I find it confounding.
>>
>>
>>> If you put a breakpoint on code that does that, does it get hit and will
>>> the stack info show you how it got there?
>>>
>>
>> The code would be in the framework. It would just be the handler for a
>> click on the TabBar.
>>
>>
>>> The TabBar children should just be Tabs that dispatch events.  The logic
>>> that responds to the change event should be the main concern.
>>>
>>
>> Thanks. I understand that. But I'm not writing any code to react to the
>> click event. It's just the default action from the framework, which should
>> be to make the box corresponding to the Tab the selectedChild of the
>> TabNaviagator.
>>
>> I have tried walking through my ActionScript, and the oddity I see (which
>> I may not really understand) is that even after all the custom components
>> are added as children to one of the second-level TabNavigators, the
>> TabNavigator and its TabBar show in debugging as having a different number
>> of children.
>>
>>
>>
>> --
>> Thanks,
>>
>> Tom
>>
>> Tom McNeer
>> MediumCool
>> http://www.mediumcool.com
>> 1735 Johnson Road NE
>> Atlanta, GA 30306
>> 404.589.0560
>>
>>
>
>
> --
> Thanks,
>
> Tom
>
> Tom McNeer
> MediumCool
> http://www.mediumcool.com
> 1735 Johnson Road NE
> Atlanta, GA 30306
> 404.589.0560
>
>  
>



--
Thanks,

Tom

Tom McNeer
MediumCool
http://www.mediumcool.com
1735 Johnson Road NE
Atlanta, GA 30306
404.589.0560
Reply | Threaded
Open this post in threaded view
|

Re: Nested TabNabvigator/Repeater error [4 Attachments]

Tom McNeer
In reply to this post by Alex Harui
I've finally had time to check this out a little further.

As a reminder, I'm creating nested TabNavigator elements dynamically. I
avoided using a Repeater and attached a CollectionChange event listener to
the ArrayCollection that is the main data provider. The function called by
the listener walks through the structure, creating TabNavigators with VBox
children, and at the bottom level, a custom component (DocDataGrid) that is
a VBox which wraps a DataGrid.

The problem is that a click on a tab in the lowest-level TabNavigator
doesn't display the selected child. Rather, it sends the user several
levels back up the component tree.

I've followed the click through TabBars and NavBars and Buttons till
there's a click event fired where I can't determine what's supposed to hear
the click. The selectedIndex appears correct through each level in the
inheritance, but then the process fails.

I've even added some hack-y invalidateDisplayList() calls in hopes that
they might have an effect.

I'm including the code that creates the elements, along with some screen
shots that I hope will better explain what's going on.

If you have time to look them over, and if you see where I'm going wrong, I
would certainly appreciate any pointers.

Thanks very much in advance.

private function buildUI(e:CollectionEvent):
void{
                clearTabs();
                var vb:VBox;
                var tn:TabNavigator;
                var ddg:DocDataGrid;
                for(var i:int=0;i<acCaseDocuments.length;i++){
                    var arSubtypes:Array = acCaseDocuments[i].subtypes as
Array;
                    vb = new VBox();
                    vb.id='docType' + i;
                    vb.setStyle('horizontalAlign','center');
                    vb.label = acCaseDocuments[i].friendlyName as String;
                    vb.percentWidth=95;
                    vb.percentHeight=95;
                    vb.styleName='contentWhite';
                    tn = new TabNavigator();
                    tn.id='docSubtab' + i;
                    tn.percentWidth=100;
                    tn.percentHeight=100;
                    tn.x=5;
                    tn.y=5;
                    tn.setStyle("backgroundAlpha",0);
                    tn.setStyle('borderThickness',1);
                    tn.setStyle('paddingTop',0);
                    tn.creationPolicy="all";
                    for(var j:int=0;j<arSubtypes.length;j++){
                        ddg = new DocDataGrid();
                        ddg.id= 'docSubtype' + j;
                        ddg.label=arSubtypes[j].friendlyName as String;
                        ddg.gridData.source=arSubtypes[j].documents as
Array;
                        ddg.gridData.refresh();
                        tn.addChild(ddg);
                    }
                    tn.invalidateDisplayList();
                    vb.addChild(tn);
                    docTabs.addChild(vb);
                }
                setFirstTab(e);
            }


On Thu, Oct 24, 2013 at 12:32 PM, Alex Harui <[hidden email]> wrote:

> **
>
>
> Never tried right clicking on the framework files before.  You're right
> that it doesn't work.  But double-clicking should set a breakpoint.  It
> does for me.
>
> From: Tom McNeer <[hidden email]>
> Reply-To: "[hidden email]" <[hidden email]>
> Date: Thursday, October 24, 2013 7:44 AM
>
> To: "[hidden email]" <[hidden email]>
> Subject: Re: [flexcoders] Nested TabNabvigator/Repeater error
>
>
>
> Alex,
>
> Thanks again for your reply. Sorry I was unclear. I wasn't suggesting that
> the framework had code to switch the ViewStack on click.
>
> I was responding to your comment about the concern being the logic that
> responds to the change in the TabNavigator and TabBar. And I simply meant
> that my code does not contain any handlers for any actions on the
> TabNavigators created in my AS code, nor on the underlying TabBars. But
> rather, the click on the visible Tab that _appears_ to be responsible for
> switching the ViewStack is being handled somehow by the framework, since I
> have not overridden it.
>
> I realize that the proper course would be to follow the event into the
> framework files. However, in my initial post, I was hoping that someone
> might have experienced a similar problem and know a simple solution.
>
> I am now trying to follow the event down into the framework. But I'm
> running into what seems like a dumb problem: I am unable to set breakpoints
> in the framework files. I can search for and open class files in the
> correct version of the framework; but a right-click in the left margin does
> not bring up a context menu at all.
>
> The framework is being merged into the code at compile time.
>
> I know this may be a silly question, but can you tell me why Flash Builder
> (4.6) might be acting this way?
>
>
> On Wed, Oct 23, 2013 at 2:40 AM, Alex Harui <[hidden email]> wrote:
>
>> **
>>
>>
>> I'm not sure what you mean by "the framework".  AFAIK, the framework
>> doesn't have any code that automatically switches ViewStack views based on
>> mouse activity.
>>
>> But you could put a breakpoint on the ViewStack code and see why it is
>> changing.
>>
>> -Alex
>>
>> From: Tom McNeer <[hidden email]>
>> Reply-To: "[hidden email]" <[hidden email]>
>> Date: Tuesday, October 22, 2013 12:30 PM
>> To: "[hidden email]" <[hidden email]>
>> Subject: Re: [flexcoders] Nested TabNabvigator/Repeater error
>>
>>
>>
>> Hi Alex,
>>
>> Thanks very much for the reply.
>>
>>
>> On Tue, Oct 22, 2013 at 12:56 PM, Alex Harui <[hidden email]> wrote:
>>
>>> In the AS version, I would guess there are relatively few ways to
>>> "switch to a different screen".
>>>
>>
>> Yeah, I would agree. The reason I used the vague "switch to a different
>> screen" is that the resulting action is nothing that is called in the
>> component or even its parent.
>>
>> I'll lay this out as quickly as I can:
>>
>> There's a view we'll call Cases which has a ViewStack that consists of
>> "Case Results" and "Case Details." A search triggered from a parent of the
>> Cases view results in a grid in Case Results being populated. A click on a
>> row in the grid calls the server for data on an individual Case and
>> switches to the Case Details view.
>>
>> That view contains a TabNavigator for various aspects of the Case,
>> including Documents. The nested TabNavigators I'm trying to create are
>> within that Documents view.
>>
>> When I say that a click on any second-level (Document subtype) tab goes
>> "to a different screen," what happens is that everything is switched back
>> to the Case Results view - taking you back to the first element in the
>> Cases ViewStack. There's no action or event defined in any of the child
>> views inside the Case Details TabNavigator that would switch the view that
>> way.
>>
>> That's why I find it confounding.
>>
>>
>>> If you put a breakpoint on code that does that, does it get hit and will
>>> the stack info show you how it got there?
>>>
>>
>> The code would be in the framework. It would just be the handler for a
>> click on the TabBar.
>>
>>
>>> The TabBar children should just be Tabs that dispatch events.  The logic
>>> that responds to the change event should be the main concern.
>>>
>>
>> Thanks. I understand that. But I'm not writing any code to react to the
>> click event. It's just the default action from the framework, which should
>> be to make the box corresponding to the Tab the selectedChild of the
>> TabNaviagator.
>>
>> I have tried walking through my ActionScript, and the oddity I see (which
>> I may not really understand) is that even after all the custom components
>> are added as children to one of the second-level TabNavigators, the
>> TabNavigator and its TabBar show in debugging as having a different number
>> of children.
>>
>>
>>
>> --
>> Thanks,
>>
>> Tom
>>
>> Tom McNeer
>> MediumCool
>> http://www.mediumcool.com
>> 1735 Johnson Road NE
>> Atlanta, GA 30306
>> 404.589.0560
>>
>>
>
>
> --
> Thanks,
>
> Tom
>
> Tom McNeer
> MediumCool
> http://www.mediumcool.com
> 1735 Johnson Road NE
> Atlanta, GA 30306
> 404.589.0560
>
>  
>



--
Thanks,

Tom

Tom McNeer
MediumCool
http://www.mediumcool.com
1735 Johnson Road NE
Atlanta, GA 30306
404.589.0560
Reply | Threaded
Open this post in threaded view
|

Function from string?

A. P. Damien
I'm writing a game. Well, actually I guess it's more of a game engine. I
want the game logic to be in a script.  The script will take the form of
a series of rooms, each of which can contain:

   . doors to other rooms
   . characters the player can interact with
   . things the player can pick up and use

Any of these can have conditions on them. The condition can be expressed as:
   . Player must have (thing) in his inventory
   . Player must have at least X points
   . Player must have at least $Y money
   . Call function "f"

That last seems to be a problem. I would like to be able to take a
function name I've read from the script and call the corresponding
function. Or, alternatively, the script can contain the name of a class
which must contain a method named (for example) conditionTest.

But I haven't figured out a way to convert a string to either a Function
or a Class.  Is there a way of doing this?  If I were working in
Javascript, I'd just call "eval", but that seems to be forbidden in AS3,
right?

Can I do this? Or do I have to put all the functions I might want to
call this way in an array, and look them up that way?  Or what?
Reply | Threaded
Open this post in threaded view
|

Re: Nested TabNabvigator/Repeater error

Alex Harui
In reply to this post by Tom McNeer
So if I understand correctly, clicking on some nested Tab changes some other ViewStack's selectedIndex.  If that's correct, try subclassing the ViewStack's selectedIndex setter so you can set a breakpoint and catch when only that ViewStack is changed.  Then the call stack should contain some good clues.

From: Tom McNeer <[hidden email]<mailto:[hidden email]>>
Reply-To: "[hidden email]<mailto:[hidden email]>" <[hidden email]<mailto:[hidden email]>>
Date: Monday, November 4, 2013 3:31 PM
To: "[hidden email]<mailto:[hidden email]>" <[hidden email]<mailto:[hidden email]>>
Subject: Re: [flexcoders] Nested TabNabvigator/Repeater error [4 Attachments]


[Attachment(s) from Tom McNeer included below]

I've finally had time to check this out a little further.

As a reminder, I'm creating nested TabNavigator elements dynamically. I avoided using a Repeater and attached a CollectionChange event listener to the ArrayCollection that is the main data provider. The function called by the listener walks through the structure, creating TabNavigators with VBox children, and at the bottom level, a custom component (DocDataGrid) that is a VBox which wraps a DataGrid.

The problem is that a click on a tab in the lowest-level TabNavigator doesn't display the selected child. Rather, it sends the user several levels back up the component tree.

I've followed the click through TabBars and NavBars and Buttons till there's a click event fired where I can't determine what's supposed to hear the click. The selectedIndex appears correct through each level in the inheritance, but then the process fails.

I've even added some hack-y invalidateDisplayList() calls in hopes that they might have an effect.

I'm including the code that creates the elements, along with some screen shots that I hope will better explain what's going on.

If you have time to look them over, and if you see where I'm going wrong, I would certainly appreciate any pointers.

Thanks very much in advance.

private function buildUI(e:CollectionEvent):
void{
                clearTabs();
                var vb:VBox;
                var tn:TabNavigator;
                var ddg:DocDataGrid;
                for(var i:int=0;i<acCaseDocuments.length;i++){
                    var arSubtypes:Array = acCaseDocuments[i].subtypes as Array;
                    vb = new VBox();
                    vb.id<http://vb.id>='docType' + i;
                    vb.setStyle('horizontalAlign','center');
                    vb.label = acCaseDocuments[i].friendlyName as String;
                    vb.percentWidth=95;
                    vb.percentHeight=95;
                    vb.styleName='contentWhite';
                    tn = new TabNavigator();
                    tn.id<http://tn.id>='docSubtab' + i;
                    tn.percentWidth=100;
                    tn.percentHeight=100;
                    tn.x=5;
                    tn.y=5;
                    tn.setStyle("backgroundAlpha",0);
                    tn.setStyle('borderThickness',1);
                    tn.setStyle('paddingTop',0);
                    tn.creationPolicy="all";
                    for(var j:int=0;j<arSubtypes.length;j++){
                        ddg = new DocDataGrid();
                        ddg.id<http://ddg.id>= 'docSubtype' + j;
                        ddg.label=arSubtypes[j].friendlyName as String;
                        ddg.gridData.source=arSubtypes[j].documents as Array;
                        ddg.gridData.refresh();
                        tn.addChild(ddg);
                    }
                    tn.invalidateDisplayList();
                    vb.addChild(tn);
                    docTabs.addChild(vb);
                }
                setFirstTab(e);
            }


On Thu, Oct 24, 2013 at 12:32 PM, Alex Harui <[hidden email]<mailto:[hidden email]>> wrote:


Never tried right clicking on the framework files before.  You're right that it doesn't work.  But double-clicking should set a breakpoint.  It does for me.

From: Tom McNeer <[hidden email]<mailto:[hidden email]>>
Reply-To: "[hidden email]<mailto:[hidden email]>" <[hidden email]<mailto:[hidden email]>>
Date: Thursday, October 24, 2013 7:44 AM

To: "[hidden email]<mailto:[hidden email]>" <[hidden email]<mailto:[hidden email]>>
Subject: Re: [flexcoders] Nested TabNabvigator/Repeater error



Alex,

Thanks again for your reply. Sorry I was unclear. I wasn't suggesting that the framework had code to switch the ViewStack on click.

I was responding to your comment about the concern being the logic that responds to the change in the TabNavigator and TabBar. And I simply meant that my code does not contain any handlers for any actions on the TabNavigators created in my AS code, nor on the underlying TabBars. But rather, the click on the visible Tab that _appears_ to be responsible for switching the ViewStack is being handled somehow by the framework, since I have not overridden it.

I realize that the proper course would be to follow the event into the framework files. However, in my initial post, I was hoping that someone might have experienced a similar problem and know a simple solution.

I am now trying to follow the event down into the framework. But I'm running into what seems like a dumb problem: I am unable to set breakpoints in the framework files. I can search for and open class files in the correct version of the framework; but a right-click in the left margin does not bring up a context menu at all.

The framework is being merged into the code at compile time.

I know this may be a silly question, but can you tell me why Flash Builder (4.6) might be acting this way?


On Wed, Oct 23, 2013 at 2:40 AM, Alex Harui <[hidden email]<mailto:[hidden email]>> wrote:


I'm not sure what you mean by "the framework".  AFAIK, the framework doesn't have any code that automatically switches ViewStack views based on mouse activity.

But you could put a breakpoint on the ViewStack code and see why it is changing.

-Alex

From: Tom McNeer <[hidden email]<mailto:[hidden email]>>
Reply-To: "[hidden email]<mailto:[hidden email]>" <[hidden email]<mailto:[hidden email]>>
Date: Tuesday, October 22, 2013 12:30 PM
To: "[hidden email]<mailto:[hidden email]>" <[hidden email]<mailto:[hidden email]>>
Subject: Re: [flexcoders] Nested TabNabvigator/Repeater error



Hi Alex,

Thanks very much for the reply.


On Tue, Oct 22, 2013 at 12:56 PM, Alex Harui <[hidden email]<mailto:[hidden email]>> wrote:
In the AS version, I would guess there are relatively few ways to "switch to a different screen".

Yeah, I would agree. The reason I used the vague "switch to a different screen" is that the resulting action is nothing that is called in the component or even its parent.

I'll lay this out as quickly as I can:

There's a view we'll call Cases which has a ViewStack that consists of "Case Results" and "Case Details." A search triggered from a parent of the Cases view results in a grid in Case Results being populated. A click on a row in the grid calls the server for data on an individual Case and switches to the Case Details view.

That view contains a TabNavigator for various aspects of the Case, including Documents. The nested TabNavigators I'm trying to create are within that Documents view.

When I say that a click on any second-level (Document subtype) tab goes "to a different screen," what happens is that everything is switched back to the Case Results view - taking you back to the first element in the Cases ViewStack. There's no action or event defined in any of the child views inside the Case Details TabNavigator that would switch the view that way.

That's why I find it confounding.

If you put a breakpoint on code that does that, does it get hit and will the stack info show you how it got there?

The code would be in the framework. It would just be the handler for a click on the TabBar.

The TabBar children should just be Tabs that dispatch events.  The logic that responds to the change event should be the main concern.

Thanks. I understand that. But I'm not writing any code to react to the click event. It's just the default action from the framework, which should be to make the box corresponding to the Tab the selectedChild of the TabNaviagator.

I have tried walking through my ActionScript, and the oddity I see (which I may not really understand) is that even after all the custom components are added as children to one of the second-level TabNavigators, the TabNavigator and its TabBar show in debugging as having a different number of children.



--
Thanks,

Tom

Tom McNeer
MediumCool
http://www.mediumcool.com
1735 Johnson Road NE
Atlanta, GA 30306
404.589.0560<tel:404.589.0560>



--
Thanks,

Tom

Tom McNeer
MediumCool
http://www.mediumcool.com
1735 Johnson Road NE
Atlanta, GA 30306
404.589.0560<tel:404.589.0560>



--
Thanks,

Tom

Tom McNeer
MediumCool
http://www.mediumcool.com
1735 Johnson Road NE
Atlanta, GA 30306
404.589.0560


Reply | Threaded
Open this post in threaded view
|

Re: Nested TabNabvigator/Repeater error

Tom McNeer
Hi Alex,

Thanks for your suggestion. It may be a couple of days before I can get
back to testing it; I'm reworking many backend routines and database
functions/procs for the same application.

But when I'm able to test it, I'll report back.

As always, thanks for your generous help.


On Tue, Nov 5, 2013 at 1:47 PM, Alex Harui <[hidden email]> wrote:

>
>
> So if I understand correctly, clicking on some nested Tab changes some
> other ViewStack's selectedIndex.  If that's correct, try subclassing the
> ViewStack's selectedIndex setter so you can set a breakpoint and catch when
> only that ViewStack is changed.  Then the call stack should contain some
> good clues.
>
> From: Tom McNeer <[hidden email]>
> Reply-To: "[hidden email]" <[hidden email]>
> Date: Monday, November 4, 2013 3:31 PM
> To: "[hidden email]" <[hidden email]>
> Subject: Re: [flexcoders] Nested TabNabvigator/Repeater error [4
> Attachments]
>
>
>
> I've finally had time to check this out a little further.
>
> As a reminder, I'm creating nested TabNavigator elements dynamically. I
> avoided using a Repeater and attached a CollectionChange event listener to
> the ArrayCollection that is the main data provider. The function called by
> the listener walks through the structure, creating TabNavigators with VBox
> children, and at the bottom level, a custom component (DocDataGrid) that is
> a VBox which wraps a DataGrid.
>
> The problem is that a click on a tab in the lowest-level TabNavigator
> doesn't display the selected child. Rather, it sends the user several
> levels back up the component tree.
>
> I've followed the click through TabBars and NavBars and Buttons till
> there's a click event fired where I can't determine what's supposed to hear
> the click. The selectedIndex appears correct through each level in the
> inheritance, but then the process fails.
>
> I've even added some hack-y invalidateDisplayList() calls in hopes that
> they might have an effect.
>
> I'm including the code that creates the elements, along with some screen
> shots that I hope will better explain what's going on.
>
> If you have time to look them over, and if you see where I'm going wrong,
> I would certainly appreciate any pointers.
>
> Thanks very much in advance.
>
> private function buildUI(e:CollectionEvent):
> void{
>                 clearTabs();
>                 var vb:VBox;
>                 var tn:TabNavigator;
>                 var ddg:DocDataGrid;
>                 for(var i:int=0;i<acCaseDocuments.length;i++){
>                     var arSubtypes:Array = acCaseDocuments[i].subtypes as
> Array;
>                     vb = new VBox();
>                     vb.id='docType' + i;
>                     vb.setStyle('horizontalAlign','center');
>                     vb.label = acCaseDocuments[i].friendlyName as String;
>                     vb.percentWidth=95;
>                     vb.percentHeight=95;
>                     vb.styleName='contentWhite';
>                     tn = new TabNavigator();
>                     tn.id='docSubtab' + i;
>                     tn.percentWidth=100;
>                     tn.percentHeight=100;
>                     tn.x=5;
>                     tn.y=5;
>                     tn.setStyle("backgroundAlpha",0);
>                     tn.setStyle('borderThickness',1);
>                     tn.setStyle('paddingTop',0);
>                     tn.creationPolicy="all";
>                     for(var j:int=0;j<arSubtypes.length;j++){
>                         ddg = new DocDataGrid();
>                         ddg.id= 'docSubtype' + j;
>                         ddg.label=arSubtypes[j].friendlyName as String;
>                         ddg.gridData.source=arSubtypes[j].documents as
> Array;
>                         ddg.gridData.refresh();
>                         tn.addChild(ddg);
>                     }
>                     tn.invalidateDisplayList();
>                     vb.addChild(tn);
>                     docTabs.addChild(vb);
>                 }
>                 setFirstTab(e);
>             }
>
>
> On Thu, Oct 24, 2013 at 12:32 PM, Alex Harui <[hidden email]> wrote:
>
>>
>>
>> Never tried right clicking on the framework files before.  You're right
>> that it doesn't work.  But double-clicking should set a breakpoint.  It
>> does for me.
>>
>> From: Tom McNeer <[hidden email]>
>> Reply-To: "[hidden email]" <[hidden email]>
>> Date: Thursday, October 24, 2013 7:44 AM
>>
>> To: "[hidden email]" <[hidden email]>
>> Subject: Re: [flexcoders] Nested TabNabvigator/Repeater error
>>
>>
>>
>> Alex,
>>
>> Thanks again for your reply. Sorry I was unclear. I wasn't suggesting
>> that the framework had code to switch the ViewStack on click.
>>
>> I was responding to your comment about the concern being the logic that
>> responds to the change in the TabNavigator and TabBar. And I simply meant
>> that my code does not contain any handlers for any actions on the
>> TabNavigators created in my AS code, nor on the underlying TabBars. But
>> rather, the click on the visible Tab that _appears_ to be responsible for
>> switching the ViewStack is being handled somehow by the framework, since I
>> have not overridden it.
>>
>> I realize that the proper course would be to follow the event into the
>> framework files. However, in my initial post, I was hoping that someone
>> might have experienced a similar problem and know a simple solution.
>>
>> I am now trying to follow the event down into the framework. But I'm
>> running into what seems like a dumb problem: I am unable to set breakpoints
>> in the framework files. I can search for and open class files in the
>> correct version of the framework; but a right-click in the left margin does
>> not bring up a context menu at all.
>>
>> The framework is being merged into the code at compile time.
>>
>> I know this may be a silly question, but can you tell me why Flash
>> Builder (4.6) might be acting this way?
>>
>>
>> On Wed, Oct 23, 2013 at 2:40 AM, Alex Harui <[hidden email]> wrote:
>>
>>>
>>>
>>> I'm not sure what you mean by "the framework".  AFAIK, the framework
>>> doesn't have any code that automatically switches ViewStack views based on
>>> mouse activity.
>>>
>>> But you could put a breakpoint on the ViewStack code and see why it is
>>> changing.
>>>
>>> -Alex
>>>
>>> From: Tom McNeer <[hidden email]>
>>> Reply-To: "[hidden email]" <[hidden email]>
>>> Date: Tuesday, October 22, 2013 12:30 PM
>>> To: "[hidden email]" <[hidden email]>
>>> Subject: Re: [flexcoders] Nested TabNabvigator/Repeater error
>>>
>>>
>>>
>>> Hi Alex,
>>>
>>> Thanks very much for the reply.
>>>
>>>
>>> On Tue, Oct 22, 2013 at 12:56 PM, Alex Harui <[hidden email]> wrote:
>>>
>>>> In the AS version, I would guess there are relatively few ways to
>>>> "switch to a different screen".
>>>>
>>>
>>> Yeah, I would agree. The reason I used the vague "switch to a different
>>> screen" is that the resulting action is nothing that is called in the
>>> component or even its parent.
>>>
>>> I'll lay this out as quickly as I can:
>>>
>>> There's a view we'll call Cases which has a ViewStack that consists of
>>> "Case Results" and "Case Details." A search triggered from a parent of the
>>> Cases view results in a grid in Case Results being populated. A click on a
>>> row in the grid calls the server for data on an individual Case and
>>> switches to the Case Details view.
>>>
>>> That view contains a TabNavigator for various aspects of the Case,
>>> including Documents. The nested TabNavigators I'm trying to create are
>>> within that Documents view.
>>>
>>> When I say that a click on any second-level (Document subtype) tab goes
>>> "to a different screen," what happens is that everything is switched back
>>> to the Case Results view - taking you back to the first element in the
>>> Cases ViewStack. There's no action or event defined in any of the child
>>> views inside the Case Details TabNavigator that would switch the view that
>>> way.
>>>
>>> That's why I find it confounding.
>>>
>>>
>>>> If you put a breakpoint on code that does that, does it get hit and
>>>> will the stack info show you how it got there?
>>>>
>>>
>>> The code would be in the framework. It would just be the handler for a
>>> click on the TabBar.
>>>
>>>
>>>> The TabBar children should just be Tabs that dispatch events.  The
>>>> logic that responds to the change event should be the main concern.
>>>>
>>>
>>> Thanks. I understand that. But I'm not writing any code to react to the
>>> click event. It's just the default action from the framework, which should
>>> be to make the box corresponding to the Tab the selectedChild of the
>>> TabNaviagator.
>>>
>>> I have tried walking through my ActionScript, and the oddity I see
>>> (which I may not really understand) is that even after all the custom
>>> components are added as children to one of the second-level TabNavigators,
>>> the TabNavigator and its TabBar show in debugging as having a different
>>> number of children.
>>>
>>>
>>>
>>> --
>>> Thanks,
>>>
>>> Tom
>>>
>>> Tom McNeer
>>> MediumCool
>>> http://www.mediumcool.com
>>> 1735 Johnson Road NE
>>> Atlanta, GA 30306
>>> 404.589.0560
>>>
>>>
>>
>>
>> --
>> Thanks,
>>
>> Tom
>>
>> Tom McNeer
>> MediumCool
>> http://www.mediumcool.com
>> 1735 Johnson Road NE
>> Atlanta, GA 30306
>> 404.589.0560
>>
>>
>
>
> --
> Thanks,
>
> Tom
>
> Tom McNeer
> MediumCool
> http://www.mediumcool.com
> 1735 Johnson Road NE
> Atlanta, GA 30306
> 404.589.0560
>
>  
>



--
Thanks,

Tom

Tom McNeer
MediumCool
http://www.mediumcool.com
1735 Johnson Road NE
Atlanta, GA 30306
404.589.0560
Reply | Threaded
Open this post in threaded view
|

Re: Function from string?

hamann.w
In reply to this post by A. P. Damien
>> I'm writing a game. Well, actually I guess it's more of a game engine. I
>> want the game logic to be in a script.  The script will take the form of
>> a series of rooms, each of which can contain:
>>
>>    . doors to other rooms
>>    . characters the player can interact with
>>    . things the player can pick up and use
>>
>> Any of these can have conditions on them. The condition can be expressed as:
>>    . Player must have (thing) in his inventory
>>    . Player must have at least X points
>>    . Player must have at least $Y money
>>    . Call function "f"
>>
>> That last seems to be a problem. I would like to be able to take a
>> function name I've read from the script and call the corresponding
>> function. Or, alternatively, the script can contain the name of a class
>> which must contain a method named (for example) conditionTest.
>>
>> But I haven't figured out a way to convert a string to either a Function
>> or a Class.  Is there a way of doing this?  If I were working in
>> Javascript, I'd just call "eval", but that seems to be forbidden in AS3,
>> right?
>>
>> Can I do this? Or do I have to put all the functions I might want to
>> call this way in an array, and look them up that way?  Or what?
>>
Hi,

you can call

this['funcname'] or similar if the class is known.
You can call getDefinition if you need to match the class name
It might make sense to have all the expected functions in an array, just to avoid
that a script error calls functions that should not

Regards
Wolfgang



Reply | Threaded
Open this post in threaded view
|

RE: Function from string?

Keith Reinfeld
In reply to this post by A. P. Damien
Perhaps the following syntax will help:

 

var func:String = "yourFunctionName";

this[func]();  

 

Regards,

 

Keith Reinfeld  

 

From: [hidden email] [mailto:[hidden email]] On
Behalf Of A. P. Damien
Sent: Tuesday, November 05, 2013 10:48 AM
To: [hidden email]
Subject: [flexcoders] Function from string?

 

 

I'm writing a game. Well, actually I guess it's more of a game engine. I
want the game logic to be in a script. The script will take the form of
a series of rooms, each of which can contain:

. doors to other rooms
. characters the player can interact with
. things the player can pick up and use

Any of these can have conditions on them. The condition can be expressed as:
. Player must have (thing) in his inventory
. Player must have at least X points
. Player must have at least $Y money
. Call function "f"

That last seems to be a problem. I would like to be able to take a
function name I've read from the script and call the corresponding
function. Or, alternatively, the script can contain the name of a class
which must contain a method named (for example) conditionTest.

But I haven't figured out a way to convert a string to either a Function
or a Class. Is there a way of doing this? If I were working in
Javascript, I'd just call "eval", but that seems to be forbidden in AS3,
right?

Can I do this? Or do I have to put all the functions I might want to
call this way in an array, and look them up that way? Or what?



Reply | Threaded
Open this post in threaded view
|

Re: Function from string?

A. P. Damien
On 11/6/2013 9:16 AM, Keith Reinfeld wrote:
> Perhaps the following syntax will help:
>
> var func:String = “yourFunctionName”;
>
> this[func]();

Thanks. I hadn't fully assimilated the fact that an object can also  be
treated as an array.  Do I have to declare the class 'dynamic' for this
trick to work? Or is it always legal to do this from inside the class?


------------------------------------

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Alternative FAQ location: https://share.acrobat.com/adc/document.do?docid=942dbdc8-e469-446f-b4cf-1e62079f6847
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/flexcoders/join
    (Yahoo! ID required)

<*> To change settings via email:
    [hidden email]
    [hidden email]

<*> To unsubscribe from this group, send an email to:
    [hidden email]

<*> Your use of Yahoo Groups is subject to:
    http://info.yahoo.com/legal/us/yahoo/utos/terms/

Reply | Threaded
Open this post in threaded view
|

Re: Function from string?

Alex Harui
Both Array and Object support [] property access.

Regarding converting a String to a Function:  AS is compiled, not
interpreted, so only strings that have been compiled into functions can be
run.  You can fill an object or array full of functions and choose one at
runtime, but that is not the same as constructing a string at runtime and
trying to run it.  Eval() will do that in JS, but there is no AS
equivalent.

Some options are:

1) There are some AS3 eval() functions in third-party libraries.  But they
are unlikely to be fast.
2) You can send the string to a server, compile it into a SWF and load
that SWF and run it.
3) If the function doesn't require much information from the rest of the
app, you could write the string to JS and call eval on it via
ExternalInterface

-Alex

On 11/6/13 2:02 PM, "A. P. Damien" <[hidden email]> wrote:

>On 11/6/2013 9:16 AM, Keith Reinfeld wrote:
>> Perhaps the following syntax will help:
>>
>> var func:String = ³yourFunctionName²;
>>
>> this[func]();
>
>Thanks. I hadn't fully assimilated the fact that an object can also  be
>treated as an array.  Do I have to declare the class 'dynamic' for this
>trick to work? Or is it always legal to do this from inside the class?
>
>
>------------------------------------
>
>--
>Flexcoders Mailing List
>FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
>Alternative FAQ location:
>https://share.acrobat.com/adc/document.do?docid=942dbdc8-e469-446f-b4cf-1e
>62079f6847
>Search Archives:
>http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo Groups Links
>
>
>

Reply | Threaded
Open this post in threaded view
|

RE: Function from string?

Keith Reinfeld
> I would like to be able to take a
>function name I've read from the script and call the corresponding
>function.  

 

Hi A. P. Damien,

As I understand it, you have existing functions which you want to call by
passing the name of a function as a string to a generic method.
By 'script' I take you to mean an external text source.

public function makeTheCall(s:String):void{
   //use try/catch to handle errors
   try {
         this[s]();
   }
   catch(e:ReferenceError) {
         //trace(s,e);
   }
}

>Do I have to declare the class 'dynamic' for this trick to work?
I don't think so.



> Or is it always legal to do this from inside the class?
'Always' is a tricky word. The functions you want to call need to be in the
same Class in order for the 'this' keyword to work. The function's name and
the  function name string must be an exact match for case and spelling.




Regards,

 

Keith Reinfeld