I fixed the problem by changing the way I was using the Image control
(calling load() instead of changing the reference in the container).

callLater() would solve the issue if it were caused by event timings,
and I tried using that, so I don't think my problem is related. After
much tinkering around I've reduced what's going wrong to a few lines.

I've got a feeling it's more fundamental to the behaviour of
addChild() and the arguments supplied. Intuitively (in my twisted
brain), this should work - all I'm doing is using a reference to a
control twice (in different containers). Remove the comment slashes to
make it balk.

package testspace
{
        import mx.controls.*;
        import mx.containers.*;

        public class TestImage extends VBox
        {
                private var mainImage:Image = new Image();
                public function TestImage()
                {
                        mainImage.load("images/dvd_1.jpg");
                }
                
                override protected function createChildren():void
                {
                        super.createChildren(); 
                        var tileDisplay:Tile = new Tile();
                        tileDisplay.addChild(mainImage);
                        //addChild(mainImage);
                        addChild(tileDisplay);
                }
        }       
}

The documentation doesn't seem to indicate what behaviour would make
this throw an exception (or am I being blind here?). If anyone can
point me to whatever explains it, I'd be most appreciative.

Many Thanks,
Ciarán

On 11/2/06, Jason Hawryluk <[EMAIL PROTECTED]> wrote:
> I'm having the exact same type of problem swapping containers in a
> TabNavigator using this type of command
>
> main.setChildIndex(main.getChildAt(2),1);
>
> The behind code seems to choke on the getChildAt of the container.
>
>
> I had the some index problems on other things with this component and for
> that one found that using callLater solved part of it. Perhaps you could
> give that a try, failing that if you find a simple answer to your problem I'
> d be interested in hearing about your solution. I'll do likewise if I find a
> solution to the current index problem.
>
> Anyway Frustrating to say the least.
>
> jason
>
>
>
>
>
> -----Message d'origine-----
> De : [email protected] [mailto:[EMAIL PROTECTED] la
> part de Ciarán
> Envoyé : jeudi 2 novembre 2006 14:29
> À : [email protected]
> Objet : [flexcoders] AddChild() Exceptions
>
>
> Hi All,
>
> I'm having a slight problem building a custom component. The basic
> idea is a combination of a primary image container, and a Tile()
> container providing a selection of images. When selected, each image
> would appear as a primary image.
>
> This sounds tediously simple. I'm implementing it upon the principle
> that a change event is broadcast when a setter is called, which has a
> registered listener that updates the component. It attempts to replace
> the at index 0.
>
> The annoying thing is that if I implement this from a vanilla
> perspective (blank text file), it works fine (making things much
> harder to debug since I can't reproduce the behaviour) - however in
> the context of the application I'm developing, it throws an exception:
>
> RangeError: Error #2006: The supplied index is out of bounds.
> at flash.display::DisplayObjectContainer/getChildAt()
> at
> mx.core::Container/getChildAt()[C:\dev\GMC\sdk\frameworks\mx\core\Container.
> as:2384]
> at
> mx.core::UIComponent/notifyStyleChangeInChildren()[C:\dev\GMC\sdk\frameworks
> \mx\core\UIComponent.as:7099]
> at
> mx.core::Container/mx.core:Container::commitProperties()[C:\dev\GMC\sdk\fram
> eworks\mx\core\Container.as:2680]
> at
> mx.core::UIComponent/validateProperties()[C:\dev\GMC\sdk\frameworks\mx\core\
> UIComponent.as:5218]
> at
> mx.managers::LayoutManager/mx.managers:LayoutManager::validateProperties()[C
> :\dev\GMC\sdk\frameworks\mx\managers\LayoutManager.as:517]
> at
> mx.managers::LayoutManager/mx.managers:LayoutManager::doPhasedInstantiation(
> )[C:\dev\GMC\sdk\frameworks\mx\managers\LayoutManager.as:628]
> at Function/http://adobe.com/AS3/2006/builtin::apply()
> at
> mx.core::UIComponent/mx.core:UIComponent::callLaterDispatcher2()[C:\dev\GMC\
> sdk\frameworks\mx\core\UIComponent.as:7789]
> at
> mx.core::UIComponent/mx.core:UIComponent::callLaterDispatcher()[C:\dev\GMC\s
> dk\frameworks\mx\core\UIComponent.as:7732]
>
> This happens when the addChildAt() method gets called. Without
> divulging context, is there any obvious reason why I'm getting this
> exception? I've been battling this for hours now and it won't yield.
> If I'm not doing something incredibly stupid that would cause this,
> please let me know.
>
> Intuitively, it seems like the addChild() is triggering something at
> the wrong moment in time, giving something similar to an "Array out
> of bounds" as it looks for stuff to render. I understand most of the
> trace atomically speaking, but on the whole I have no idea how to
> remedy it.
>
> Also, I have an annoying problem with Flexbuilder. Breakpoints dont
> seem to work for me at all. I can't find any setting that implies this
> might've been turned off, so I'm not sure what to do about it. Perhaps
> find the checkbox that says "Don't work properly" and untick it.
>
> Any clues would be much appreciated =)
>
> Kind Regards,
>
> Ciarán
>
>
>
>
>
>
> --
> Flexcoders Mailing List
> FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
> Yahoo! Groups Links
>
>
>
>
>


--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! 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:
    mailto:[EMAIL PROTECTED] 
    mailto:[EMAIL PROTECTED]

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

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 

Reply via email to