I have the same problem although I use mx.managers.FocusManager
Basically what I'm trying to do is a tab-loop in a container-Sprite.
When I click on one of the elements in the container-Sprite what I get is:
ArgumentError: Error #2025: The supplied DisplayObject must be a child of the
caller.
at flash.display::DisplayObjectContainer/getChildIndex()
at
mx.managers::SystemManager/getChildIndex()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\managers\SystemManager.as:1652]
at
mx.managers::SystemManager/mouseDownHandler()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\managers\SystemManager.as:3439]
It seems like the SystemManager is looking for the IFocusManagerContainer
responsible for the clicked DisplayObject directly in its own childList.
Do all FocusManagerContainers have to be top level elements?
Am I right when assuming that per application there should always be one
SystemManger and my IFocusManagerContainer should return that one (in
Application.application)?
Does anybody know how to do this, or where to get solid information about this
tabbing thing?
thanks a lot
This is my code:
package tests.controls
{
import flash.display.Sprite;
import mx.core.Application;
import mx.managers.FocusManager;
import mx.managers.IFocusManager;
import mx.managers.IFocusManagerContainer;
import mx.managers.ISystemManager;
public class FocusManagingContainer extends Sprite implements
IFocusManagerContainer
{
private var _focusManager:FocusManager = null;
public function FocusManagingContainer()
{
super();
new FocusManager(this);
}
public function get focusManager():IFocusManager
{
return _focusManager;
}
public function set focusManager(value:IFocusManager):void
{
_focusManager = FocusManager(value);
}
public function get systemManager():ISystemManager
{
var app:Application =
Application(Application.application);
return app.systemManager;
}
}
}
package tests.controls
{
import flash.display.Sprite;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
import flash.text.TextFieldType;
import mx.managers.IFocusManagerComponent;
public class FocusableControl extends Sprite implements
IFocusManagerComponent
{
private var _focusEnabled:Boolean = true;
private var _mouseFocusEnabled:Boolean = true;
private var _tabEnabled:Boolean = true;
private var _label:TextField = null;
private var _input:TextField = null;
public function FocusableControl()
{
super();
_label = new TextField();
_label.text = "Input:";
_label.autoSize = TextFieldAutoSize.LEFT;
_label.selectable = false;
_label.type = TextFieldType.DYNAMIC;
addChild(_label);
_input = new TextField();
_input.width = 100;
_input.height = 20;
_input.x = _label.width + 10;
_input.autoSize = TextFieldAutoSize.NONE;
_input.type = TextFieldType.INPUT;
_input.background = true;
_input.backgroundColor = 0xFFFFFF;
addChild(_input);
}
public function get focusEnabled():Boolean
{
return _focusEnabled;
}
public function set focusEnabled(value:Boolean):void
{
_focusEnabled = value;
}
public function get mouseFocusEnabled():Boolean
{
return _mouseFocusEnabled;
}
public function setFocus():void
{
stage.focus = _input;
}
public function drawFocus(isFocused:Boolean):void
{
//
}
}
}
I use them like that:
var fc: FocusManagingContainer = new FocusManagingContainer();
addChild(fc);
for (var i:int = 0; i < 10; i++)
{
var cnt:FocusableControl = new FocusableControl();
cnt.x = 10;
cnt.y = i*20;
cnt.tabEnabled = true;
fc.addChild(cnt);
}
--- In [email protected], Alex Harui <aha...@...> wrote:
>
> You can't use fl.*.* classes in Flex apps.
>
> Alex Harui
> Flex SDK Developer
> Adobe Systems Inc.<http://www.adobe.com/>
> Blog: http://blogs.adobe.com/aharui
>
> From: [email protected] [mailto:[email protected]] On
> Behalf Of aceoohay
> Sent: Tuesday, March 10, 2009 8:28 PM
> To: [email protected]
> Subject: [flexcoders] Re: FocusManager fun... Tab Loops redux
>
>
> After playing around a bit more I am leaning towards the fact that the mx and
> fl might be the same, and the 2025 error is caused by something I am doing
> (or not).
>
> If the panel has focus I can tab around it, and type, but as soon as I click
> a mouse anywhere in the application it dies in SystemManager on a
> getChildIndex fired by the mouseDownHandler.
>
> Any help is appreciated.
>
> Paul
>
> --- In [email protected]<mailto:flexcoders%40yahoogroups.com>,
> "aceoohay" <pauls@> wrote:
> >
> > In reading the page;
> >
> > http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/fl/managers/FocusManager.html
> >
> > It seems like just the right tool to handle a major deficiency in Flex.
> > Basically the inability to create tab loops for containers.
> >
> > I use a somewhat modified version of the SuperPanel component which is an
> > extension of the panel component for all of the data entry forms in my
> > application. I envisioned creating a FocusManager in the SuperPanel, and
> > viola I would have a custom tab loop for each of my data entry screens.
> >
> > Unfortunately, it isn't that simple (it seldom is). I added a private
> > variable to the component of the type FocusManager. Flex of course wants to
> > add mx.managers.FocusManager, and we probably want fl.managers.FocusManager
> > the flash version, since the mx version generates 2025 RT errors anytime
> > you click on any object in the container that is assigned to a
> > separate/custom focusmanager.
> >
> > The full error is;
> >
> > Error #2025: The supplied DisplayObject must be a child of the caller.
> >
> > So has anyone else tried to create a flex component with a separate tab
> > loop, if so how did you make it work?
> >
> > Has anyone worked with the fl.managers.FocusManager component? Is it the
> > same as the mx.managers.FocusManager? Is it possible to get either one to
> > do what I want? Which is to encapsulate a tab loop with in a container. How?
> >
> > Paul
> >
>