Error #2025: addChaild and removeChild
hello all
I have the app but I got a problem
ArgumentError: Error # 2025: The supplied DisplayObject must be a child of the caller.
at flash.display :: DisplayObjectContainer / removeChild ()
at xxxxx_fla :: MainTimeline / hitPoint ()
my code
import flash.events.Event;
import flash.events.MouseEvent;
var pencilta:Shape = new Shape();
var activeColor:uint = 0x000000;
var aaa:a = new a();
aaa.x = 0;
aaa.y = 0;
addChild(aaa);
var bbb:c1 = new c1();
bbb.x = 308;
bbb.y = 108;
addChild(bbb);
var ccc:c2 =new c2();
ccc.x = 265;
ccc.y = 175;
addChild(ccc);
var ddd:c2 = new c2();
ddd.x = 235;
ddd.y = 260;
var eee:c2 =new c2();
eee.x = 200;
eee.y = 355;
bbb.addEventListener(MouseEvent.MOUSE_DOWN, hta1drag);
bbb.addEventListener(MouseEvent.MOUSE_UP, hta1drop);
bbb.addEventListener(Event.ENTER_FRAME, hitPoint);
function drawingta()
addChild(pencilta);
pencilta.graphics.lineStyle(10, activeColor);
function drawPencilta(e:MouseEvent):void
pencilta.graphics.lineTo(bbb.x, bbb.y);
e.updateAfterEvent();
function hta1drag(e:MouseEvent):void
e.target.startDrag();
pencilta.graphics.moveTo(bbb.x, bbb.y);
stage.addEventListener(MouseEvent.MOUSE_MOVE, drawPencilta);
drawingta();
function hta1drop(e:MouseEvent):void
stopDrag();
stage.removeEventListener(MouseEvent.MOUSE_MOVE, drawPencilta);
function hitPoint(e:Event)
if(bbb.hitTestPoint(ccc.x,ccc.y, true))
removeChild(ccc);
addChild(ddd);
else if (bbb.hitTestPoint(ddd.x,ddd.y,true))
removeChild(ddd);
addChild(eee);
else
trace ('mbuh lah');
thank's
use:
import flash.events.Event;
import flash.events.MouseEvent;
var pencilta:Shape = new Shape();
var activeColor:uint = 0x000000;
var aaa:a = new a();
aaa.x = 0;
aaa.y = 0;
addChild(aaa);
var bbb:c1 = new c1();
bbb.x = 308;
bbb.y = 108;
addChild(bbb);
var ccc:c2 =new c2();
ccc.x = 265;
ccc.y = 175;
addChild(ccc);
var ddd:c2 = new c2();
ddd.x = 235;
ddd.y = 260;
var eee:c2 =new c2();
eee.x = 200;
eee.y = 355;
bbb.addEventListener(MouseEvent.MOUSE_DOWN, hta1drag);
bbb.addEventListener(MouseEvent.MOUSE_UP, hta1drop);
bbb.addEventListener(Event.ENTER_FRAME, hitPoint);
function drawingta()
addChild(pencilta);
pencilta.graphics.lineStyle(10, activeColor);
function drawPencilta(e:MouseEvent):void
pencilta.graphics.lineTo(bbb.x, bbb.y);
e.updateAfterEvent();
function hta1drag(e:MouseEvent):void
e.target.startDrag();
pencilta.graphics.moveTo(bbb.x, bbb.y);
stage.addEventListener(MouseEvent.MOUSE_MOVE, drawPencilta);
drawingta();
function hta1drop(e:MouseEvent):void
stopDrag();
stage.removeEventListener(MouseEvent.MOUSE_MOVE, drawPencilta);
function hitPoint(e:Event)
if(bbb.hitTestPoint(ccc.x,ccc.y, true))
if(ccc.stage){
ccc.parent.removeChild(ccc);
// ccc=null; ??
addChild(ddd);
else if (bbb.hitTestPoint(ddd.x,ddd.y,true))
if(ddd.stage){
ddd.parent.removeChild(ddd);
// ddd = null; ??
addChild(eee);
else
trace ('mbuh lah');
thank's
Similar Messages
-
Error 2025/ trying to removeChild()
Hi,
I have tried to solve ths problem but without success. I have permit Debugging on so I know it s related to the removeChild().
I currently have four buttons that each call a different addChild() function. Everything works great. However, if I skim across the buttons the way someone would in eal life the error appears. I have tried different references to the stage or this or parent.removeChild(), but no luck.
Here is the output:
ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
at flash.display::DisplayObjectContainer/removeChild()
at flutePlayer_main_fla::MainTimeline/removeGraphicD()[flutePlayer_main_fla.MainTimeline::fr ame1:79]
ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
at flash.display::DisplayObjectContainer/removeChild()
at flutePlayer_main_fla::MainTimeline/removeGraphicC()[flutePlayer_main_fla.MainTimeline::fr ame1:61]
ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
at flash.display::DisplayObjectContainer/removeChild()
at flutePlayer_main_fla::MainTimeline/removeGraphic()[flutePlayer_main_fla.MainTimeline::fra me1:26]
ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
at flash.display::DisplayObjectContainer/removeChild()
at flutePlayer_main_fla::MainTimeline/removeGraphicB()[flutePlayer_main_fla.MainTimeline::fr ame1:43]
Here is the code:
stop();
var aGraphics:MovieClip = new GraphicsA();
var lowC1:MovieClip = new LowC1();
var graphicA2:MovieClip = new GraphicsA2();
var graphA3:MovieClip = new GraphicsA3();
lowA_btn.addEventListener(MouseEvent.MOUSE_DOWN, playLowA);
lowA_btn.addEventListener(MouseEvent.MOUSE_OUT, removeGraphic);
function playLowA(evt:MouseEvent):void {
play();
addChild(aGraphics);
aGraphics.x=400;
aGraphics.y=180;
function removeGraphic(evt:MouseEvent):void {
removeChild(aGraphics);
removeEventListener(MouseEvent.MOUSE_OUT, playLowA);
lowC1_btn.addEventListener(MouseEvent.MOUSE_DOWN, playLowC1);
lowC1_btn.addEventListener(MouseEvent.MOUSE_OUT, removeGraphicB);
function playLowC1(evt:MouseEvent):void {
play();
addChild(lowC1);
lowC1.x=400;
lowC1.y=170;
function removeGraphicB(evt:MouseEvent):void {
removeChild(lowC1);
removeEventListener(MouseEvent.MOUSE_OUT, playLowC1);
A2_btn.addEventListener(MouseEvent.MOUSE_DOWN, playA2);
A2_btn.addEventListener(MouseEvent.MOUSE_OUT, removeGraphicC);
function playA2(evt:MouseEvent):void {
play();
addChild(graphicA2);
graphicA2.x=400;
graphicA2.y=165;
function removeGraphicC(evt:MouseEvent):void {
removeChild(graphicA2);
removeEventListener(MouseEvent.MOUSE_OUT, playA2);
A3_btn.addEventListener(MouseEvent.MOUSE_DOWN, playA3);
A3_btn.addEventListener(MouseEvent.MOUSE_OUT, removeGraphicD);
function playA3(evt:MouseEvent):void {
play();
addChild(graphA3);
graphA3.x=400;
graphA3.y=165;
function removeGraphicD(evt:MouseEvent):void {
removeChild(graphA3);
removeEventListener(MouseEvent.MOUSE_OUT, playA3);
Thanks for your help.Ok, After trying different approaches I changed my MOUSE_ DOWN to MOUSE_OVER which made the difference.
I think I get it. When skimming the mouse activates the button for a slit second. Since there was no code for the over state it throws an error and the remeoveChild() is probably just a ruse.
I'm sure there is someone who knows the real answer.
Thanks again.
The new code:
stop();
import flash.media.SoundMixer;
var aGraphics:MovieClip = new GraphicsA();
var lowC1:MovieClip = new LowC1();
var graphicA2:MovieClip = new GraphicsA2();
var graphA3:MovieClip = new GraphicsA3();
lowA_btn.addEventListener(MouseEvent.MOUSE_OVER, playLowA);
lowA_btn.addEventListener(MouseEvent.MOUSE_UP, noSound);
lowA_btn.addEventListener(MouseEvent.MOUSE_OUT, removeGraphic);
function playLowA(evt:MouseEvent):void {
play();
addChild(aGraphics);
aGraphics.x=400;
aGraphics.y=180;
function noSound(evt:MouseEvent):void{
SoundMixer.stopAll();
function removeGraphic(evt:MouseEvent):void {
removeChild(aGraphics);
removeEventListener(MouseEvent.MOUSE_OUT, playLowA);
lowC1_btn.addEventListener(MouseEvent.MOUSE_OVER, playLowC1);
lowC1_btn.addEventListener(MouseEvent.MOUSE_UP, noSoundB);
lowC1_btn.addEventListener(MouseEvent.MOUSE_OUT, removeGraphicB);
function playLowC1(evt:MouseEvent):void {
play();
addChild(lowC1);
lowC1.x=400;
lowC1.y=170;
function noSoundB(evt:MouseEvent):void{
SoundMixer.stopAll();
function removeGraphicB(evt:MouseEvent):void {
removeChild(lowC1);
removeEventListener(MouseEvent.MOUSE_OUT, playLowC1);
A2_btn.addEventListener(MouseEvent.MOUSE_OVER, playA2);
A2_btn.addEventListener(MouseEvent.MOUSE_UP, noSoundC);
A2_btn.addEventListener(MouseEvent.MOUSE_OUT, removeGraphicC);
function playA2(evt:MouseEvent):void {
play();
addChild(graphicA2);
graphicA2.x=400;
graphicA2.y=165;
function noSoundC(evt:MouseEvent):void{
SoundMixer.stopAll();
function removeGraphicC(evt:MouseEvent):void {
removeChild(graphicA2);
removeEventListener(MouseEvent.MOUSE_OUT, playA2);
A3_btn.addEventListener(MouseEvent.MOUSE_OVER, playA3);
A3_btn.addEventListener(MouseEvent.MOUSE_UP, noSoundD);
A3_btn.addEventListener(MouseEvent.MOUSE_OUT, removeGraphicD);
function playA3(evt:MouseEvent):void {
play();
addChild(graphA3);
graphA3.x=400;
graphA3.y=165;
function noSoundD(evt:MouseEvent):void{
SoundMixer.stopAll();
function removeGraphicD(evt:MouseEvent):void {
removeChild(graphA3);
removeEventListener(MouseEvent.MOUSE_OUT, playA3); -
[flexcoders] Error #2025 - UIMovieclip and Focus Manager
Hello Everybody,
I'm getting a runtime Error #2025 when I try to use an UIMovieclip into a Flex Application.
The issue happens when the key tab is pressed and It seems has being caused by the Focus Manager.
I found some threads over the internet but nothing really concret that could give me some idea about how to solve it.
ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
at flash.display::DisplayObjectContainer/getChildIndex()
at mx.core::Container/getChildIndex()
at mx.containers::Panel/getChildIndex()
at fl.managers::FocusManager/::getChildIndex()
at fl.managers::FocusManager/::sortByDepth()
at fl.managers::FocusManager/::sortByTabIndex()
at Array$/Array::_sort()
at Array/http://adobe.com/AS3/2006/builtin::sort()
at fl.managers::FocusManager/::sortFocusableObjectsTabIndex()
at fl.managers::FocusManager/::sortFocusableObjects()
at fl.managers::FocusManager/::keyDownHandler()
Any help will be welcome
Best Regards,
Eduardo DiasI don't know if we've figured this out yet. If you can come up with a simple test case, file a bug so we can take a look.
Alex Harui
Flex SDK Developer
Adobe Systems Inc.
Blog: http://blogs.adobe.com/aharui -
ArgumentError: Error #2025 - I can not removeChild?
function urunlergelsin (e:MouseEvent):void {
var urunlermenum:urunlermenu = new urunlermenu();
bg.solurunmenusu.addChild(urunlermenum); // Added new one
var geridonbuton:geridon = new geridon();
bg.geridonus_mc.addChild(geridonbuton);
bg.geridonus_mc.addEventListener(MouseEvent.MOUSE_DOWN, geridon_f);
function geridon_f(e:MouseEvent):void {
bg.urunbtn.removeEventListener(MouseEvent.MOUSE_DOWN, urunlergelsin);
bg.geridonus_mc.removeEventListener(MouseEvent.MOUSE_DOWN, geridon_f);
var urunlermenum:urunlermenu = new urunlermenu();
bg.solurunmenusu.removeChild(urunlermenum); // But when i try ro remove it doesnt work
Hello,
When i try to removeChild i am getting this error message, How can i solve this problem?
ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
at flash.display::DisplayObjectContainer/removeChild()
at avas_fla::MainTimeline/geridon_f()Your problem likely lies in declaring the object inside a function. It will only have scope within that function when you do that. I see where you create a new instance of the object in the function where I assume you are trying to remove the first one... the second one is the only one seen at that point, and it has not been added. Try the following:
var urunlermenum:urunlermenu; // declare it outside any function
function urunlergelsin (e:MouseEvent):void {
urunlermenum = new urunlermenu();
bg.solurunmenusu.addChild(urunlermenum); // Added new one
var geridonbuton:geridon = new geridon();
bg.geridonus_mc.addChild(geridonbuton);
bg.geridonus_mc.addEventListener(MouseEvent.MOUSE_DOWN, geridon_f);
function geridon_f(e:MouseEvent):void {
bg.urunbtn.removeEventListener(MouseEvent.MOUSE_DOWN, urunlergelsin);
bg.geridonus_mc.removeEventListener(MouseEvent.MOUSE_DOWN, geridon_f);
var urunlermenum:urunlermenu = new urunlermenu(); // remove this
bg.solurunmenusu.removeChild(urunlermenum); -
Evenin' all.
I'm creating a Flash application split up into scenes. One of the scenes is divided into sections of ten frames with keyframes at 1 (home, 10, 20, 30, 40, 50, 60, 70, 80 and 90. Frame #1 is the menu and contains the buttons to skip to each section using the gotoAndStop(); command.
However, I want to be able to skip to #1 from any point using Next/Previous buttons. I have declared the buttons in frame 1 of scene 1 as follows:
I have declared the buttons in frame 1 of scene 1 as follows:
Code:
var nextButton:Button = new Button();
var prevButton:Button = new Button();
var homeButton:Button = new Button();
At each point, I use addChild(nextButton) to add the buttons to the stage, and when the buttons are clicked it removes them as follows:
Code:
nextButton.addEventListener(MouseEvent.CLICK, goNext);
function goNext(e:Event):void
removeChild(videoPlayer);
removeChild(prevButton);
removeChild(nextButton);
removeChild(homeButton);
gotoAndStop(20);
Now, all the 'Next' buttons work but none of the 'Previous' buttons work, when all they do is gotoAndStop() ten frames backwards rather than ten frames forwards, I keep getting this error message:
Code:
ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
at flash.display::DisplayObjectContainer/removeChild()
at Prototype_fla::MainTimeline/goBack()
The same is happening with the Home buttons, which skip from whichever frame the user is on to the menu. The Next buttons are the only ones working consistently.
Please help, this is really stressing me out, I'm on Flash CS4.
CheersYou can`t remove the target of your event while it is "active"
you wrote....
nextButton.addEventListener(MouseEvent.CLICK, goNext);
function goNext(e:Event):void
removeChild(videoPlayer);
removeChild(prevButton);
removeChild(nextButton);
removeChild(homeButton);
gotoAndStop(20);
instead you should write sth. like:
nextButton.addEventListener(MouseEvent.CLICK, goNext);
function goNext(e:Event):void
// to be sure that there`s actualloy sth. to remove
if(videoPlayer!=null){
removeChild(videoPlayer);
//similar
removeChild(prevButton);
removeChild(homeButton);
e.currentTarget.removeEventListener(MouseEvent.CLICK, goNext)
removeChild(e.currentTarget);
gotoAndStop(20);
this is probably similar in your other function, too -
Error #2025: The supplied DisplayObject must be a child of the caller.
Hi All,
I would very much appreciate any help with this.
I am working on a flash piece that will play 4 videos, depending on the button pressed. First button will launch first video, 2nd - 2nd video and so on. Once the Video is done playing, close_btn, learn_more_btn and replay_btn appear, in addition to an ending image that is different for each of the videos( BoxLivePic, BoxSleepPic and BoxFeelPic). So - actually 4 things appear once the movie stops playing and the last image depends on which buttons was clicked...
My issue is, when I click the close button( andI'm sure same will apply for the other 2 buttons), I get the error below:
ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
at flash.display::DisplayObjectContainer/removeChild()
at AER1_r5_fla::MainTimeline/closeVideo()
I understand is that it's because each Picture is not actually added to the display list, unless the proper button was clicked.. however, I don't know how to fix that! I hope this makes some sence - Below is all of my Code... Thanks a bunch in advance:
import com.greensock.*;
import com.greensock.easing.*;
import com.greensock.easing.CustomEase;
import com.greensock.loading.VideoLoader;
import flash.display.Sprite;
import com.greensock.events.LoaderEvent;
import flash.display.MovieClip;
import flash.display.SimpleButton;
import flash.events.MouseEvent;
//Last Buttons Variables
var close_btn:Button_close = new Button_close();
var learn_more_btn:Button_learn_more = new Button_learn_more();
var replay_btn:Button_replay = new Button_replay();
//Last Pic Variables
var BoxLivePic:Box_Live_Pic = new Box_Live_Pic();
var BoxFeelPic:Box_Feel_Pic = new Box_Feel_Pic();
var BoxSleepPic:Box_Sleep_Pic = new Box_Sleep_Pic();
// Video Variables
var Video_Breathe:VideoLoader = new VideoLoader("Breathe_Video.f4v",{container:this,
x:0, y:0});
var Video_Live:VideoLoader = new VideoLoader("Live_Video.f4v",{conainer:this,
x:0, y:0});
var Video_Sleep:VideoLoader = new VideoLoader("Sleep_Video.f4v",{conainer:this,
x:0, y:0});
var Video_Feel:VideoLoader = new VideoLoader("Feel_Video.f4v",{conainer:this,
x:0, y:0});
// Video complete Event Listeners
Video_Breathe.addEventListener(VideoLoader.VIDEO_COMPLETE, donePlaying_breathe);
Video_Live.addEventListener(VideoLoader.VIDEO_COMPLETE, donePlaying_live);
Video_Sleep.addEventListener(VideoLoader.VIDEO_COMPLETE, donePlaying_sleep);
Video_Feel.addEventListener(VideoLoader.VIDEO_COMPLETE, donePlaying_feel);
OverwriteManager.init(OverwriteManager.AUTO);
//Buttons Invisible
breathe_mc.learn_btn.visible = false;
breathe_mc.video_btn.visible = false;
live_mc.learn_btn.visible = false;
live_mc.video_btn.visible = false;
sleep_mc.learn_btn.visible = false;
sleep_mc.video_btn.visible = false;
feel_mc.learn_btn.visible = false;
feel_mc.video_btn.visible = false;
//Custom Eases
CustomEase.create("myCustomEase", [{s:0,cp:1.14999,e:1.4},{s:1.4,cp:1.65,e:1}]);
CustomEase.create("myCustomEase2",[{s:0,cp:0.97,e:1.22},{s:1.22,cp:1.47,e:1}]);
var timeline:TimelineLite = new TimelineLite({onComplete:showBreathe});
addChild(removeChild(better_mc));
TweenLite.to(better_mc,2,{alpha:1, y:186.6,ease:Bounce.easeOut});
timeline.appendMultiple([
TweenLite.to(breathe_mc, 1, {alpha:1,y:117,ease:CustomEase.byName("myCustomEase2")}),
TweenLite.to(live_mc, 1, {alpha:1,y:117, y:37, ease:CustomEase.byName("myCustomEase2")}),
TweenLite.to(sleep_mc, 1, {alpha:1,y:77, ease:CustomEase.byName("myCustomEase2")}),
TweenLite.to(feel_mc, 1, {alpha:1,y:77, ease:CustomEase.byName("myCustomEase2")})],1,TweenAlign.START, .2);
function showBreathe():void
breathe_mc.learn_btn.visible = true;
breathe_mc.video_btn.visible = true;
TweenLite.to(breathe_mc.learn_btn, .5, {alpha:1});
TweenLite.to(breathe_mc.video_btn, .5, {alpha:1});
TweenLite.to(breathe_mc, 1, {y:77, ease:CustomEase.byName("myCustomEase")});
//Show Text
TweenLite.to(breathe_txt_mc, 1,{alpha:1});
//Event Listeners
breathe_mc.addEventListener(MouseEvent.MOUSE_OVER, breatheOpen);
live_mc.addEventListener(MouseEvent.MOUSE_OVER, liveOpen);
sleep_mc.addEventListener(MouseEvent.MOUSE_OVER, sleepOpen);
feel_mc.addEventListener(MouseEvent.MOUSE_OVER, feelOpen);
//Event Listeners for Playing Video
breathe_mc.video_btn.addEventListener(MouseEvent.MOUSE_DOWN, breathe_play_video);
live_mc.video_btn.addEventListener(MouseEvent.MOUSE_DOWN, live_play_video);
sleep_mc.video_btn.addEventListener(MouseEvent.MOUSE_DOWN, sleep_play_video);
feel_mc.video_btn.addEventListener(MouseEvent.MOUSE_DOWN, feel_play_video);
// Event Listener for Close Video
close_btn.addEventListener(MouseEvent.MOUSE_DOWN, closeVideo);
//Functions for VIDEO and LEARN MORE buttons
function breathe_play_video(event:MouseEvent):void {
Video_Breathe.load();
this.addChild(Video_Breathe.content);
function live_play_video(event:MouseEvent):void {
Video_Live.load();
this.addChild(Video_Live.content);
function sleep_play_video(event:MouseEvent):void {
Video_Sleep.load();
this.addChild(Video_Sleep.content);
function feel_play_video(event:MouseEvent):void {
Video_Feel.load();
this.addChild(Video_Feel.content);
function closeVideo(event:MouseEvent):void {
Video_Breathe.unload();
Video_Sleep.unload();
Video_Feel.unload();
Video_Live.unload();
removeChild(close_btn);
removeChild(learn_more_btn);
removeChild(replay_btn);
removeChild(BoxLivePic);
removeChild(BoxSleepPic);
//removeChild(BoxFeelPic);
// Last Breathe Buttons Added to Stage
function donePlaying_breathe(e:Event):void {
addChild(close_btn);
addChild(learn_more_btn);
addChild(replay_btn)
close_btn.x = 313;
close_btn.y = 183;
learn_more_btn.x = 434;
learn_more_btn.y = 183;
replay_btn.x = 554;
replay_btn.y = 183;
// Last Live Buttons
function donePlaying_live(e:Event):void {
addChild(BoxLivePic);
addChild(close_btn);
addChild(learn_more_btn);
addChild(replay_btn)
close_btn.x = 43;
close_btn.y = 183;
learn_more_btn.x = 164;
learn_more_btn.y = 183;
replay_btn.x = 284;
replay_btn.y = 183;
// Last Sleep Buttons
function donePlaying_sleep(e:Event):void {
addChild(BoxSleepPic);
addChild(close_btn);
addChild(learn_more_btn);
addChild(replay_btn)
close_btn.x = 313;
close_btn.y = 183;
learn_more_btn.x = 434;
learn_more_btn.y = 183;
replay_btn.x = 554;
replay_btn.y = 183;
//Last Feel Buttons
function donePlaying_feel(e:Event):void {
addChild(BoxFeelPic);
addChild(close_btn);
addChild(learn_more_btn);
addChild(replay_btn)
close_btn.x = 313;
close_btn.y = 183;
learn_more_btn.x = 434;
learn_more_btn.y = 183;
replay_btn.x = 554;
replay_btn.y = 183;
// Functions Breathe
function breatheOpen(event:MouseEvent):void
TweenLite.to(breathe_mc, 1, {y:77, ease:Elastic.easeOut});
TweenLite.to(breathe_mc.learn_btn, .5, {alpha:1});
TweenLite.to(breathe_mc.video_btn, .5, {alpha:1});
//Close Live
TweenLite.to(live_mc, 1, {y:117, ease:Elastic.easeOut});
TweenLite.to(live_mc.learn_btn, .5, {alpha:0});
TweenLite.to(live_mc.video_btn, .5, {alpha:0});
//Close Sleep
TweenLite.to(sleep_mc, 1, {y:77, ease:Elastic.easeOut});
TweenLite.to(sleep_mc.learn_btn, .5, {alpha:0});
TweenLite.to(sleep_mc.video_btn, .5, {alpha:0});
//Close Feel
TweenLite.to(feel_mc, 1, {y:77, ease:Elastic.easeOut});
TweenLite.to(feel_mc.learn_btn, .5, {alpha:0});
TweenLite.to(feel_mc.video_btn, .5, {alpha:0});
//Show Pic
TweenLite.to(pic_breathe_mc, .5, {alpha:1});
//Hide Other Pics
TweenLite.to(pic_live_mc, .5, {alpha:0});
TweenLite.to(pic_sleep_mc, .5, {alpha:0});
TweenLite.to(pic_feel_mc, .5, {alpha:0});
//Show Text
TweenLite.to(breathe_txt_mc, 1,{alpha:1});
//Hide Other Text
TweenLite.to(live_txt_mc, 1,{alpha:0});
TweenLite.to(sleep_txt_mc, 1,{alpha:0});
TweenLite.to(feel_txt_mc, 1,{alpha:0});
// Functions live
function liveOpen(event:MouseEvent):void
TweenLite.to(live_mc, 1, {y:77, ease:Elastic.easeOut});
live_mc.learn_btn.visible = true;
live_mc.video_btn.visible = true;
TweenLite.to(live_mc.learn_btn, .5, {alpha:1});
TweenLite.to(live_mc.video_btn, .5, {alpha:1});
//Close Breathe
TweenLite.to(breathe_mc, 1, {y:117, ease:Elastic.easeOut});
TweenLite.to(breathe_mc.learn_btn, .5, {alpha:0});
TweenLite.to(breathe_mc.video_btn, .5, {alpha:0});
//Close Sleep
TweenLite.to(sleep_mc, 1, {y:77, ease:Elastic.easeOut});
TweenLite.to(sleep_mc.learn_btn, .5, {alpha:0});
TweenLite.to(sleep_mc.video_btn, .5, {alpha:0});
//Close Feel
TweenLite.to(feel_mc, 1, {y:77, ease:Elastic.easeOut});
TweenLite.to(feel_mc.learn_btn, .5, {alpha:0});
TweenLite.to(feel_mc.video_btn, .5, {alpha:0});
//Show Pic
TweenLite.to(pic_live_mc, .5, {alpha:1});
//Hide Other Pics
TweenLite.to(pic_sleep_mc, .5, {alpha:0});
TweenLite.to(pic_feel_mc, .5, {alpha:0});
//Show Text
TweenLite.to(live_txt_mc, 1,{alpha:1});
//Hide Other Text
TweenLite.to(breathe_txt_mc, 1,{alpha:0});
TweenLite.to(sleep_txt_mc, 1,{alpha:0});
TweenLite.to(feel_txt_mc, 1,{alpha:0});
// Functions sleep
function sleepOpen(event:MouseEvent):void
TweenLite.to(sleep_mc, 1, {y:37, ease:Elastic.easeOut});
sleep_mc.learn_btn.visible = true;
sleep_mc.video_btn.visible = true;
TweenLite.to(sleep_mc.learn_btn, .5, {alpha:1});
TweenLite.to(sleep_mc.video_btn, .5, {alpha:1});
//Close Breathe
TweenLite.to(breathe_mc, 1, {y:117, ease:Elastic.easeOut});
TweenLite.to(breathe_mc.learn_btn, .5, {alpha:0});
TweenLite.to(breathe_mc.video_btn, .5, {alpha:0});
//Close Live
TweenLite.to(live_mc, 1, {y:117, ease:Elastic.easeOut});
TweenLite.to(live_mc.learn_btn, .5, {alpha:0});
TweenLite.to(live_mc.video_btn, .5, {alpha:0});
//Close Feel
TweenLite.to(feel_mc, 1, {y:77, ease:Elastic.easeOut});
TweenLite.to(feel_mc.learn_btn, .5, {alpha:0});
TweenLite.to(feel_mc.video_btn, .5, {alpha:0});
//Show Pic
TweenLite.to(pic_sleep_mc, .5, {alpha:1});
//Hide Other Pics
TweenLite.to(pic_feel_mc, .5, {alpha:0});
//Show Text
TweenLite.to(sleep_txt_mc, 1,{alpha:1});
//Hide Other Text
TweenLite.to(live_txt_mc, 1,{alpha:0});
TweenLite.to(breathe_txt_mc, 1,{alpha:0});
TweenLite.to(feel_txt_mc, 1,{alpha:0});
// Functions feel
function feelOpen(event:MouseEvent):void
TweenLite.to(feel_mc, 1, {y:37, ease:Elastic.easeOut});
feel_mc.learn_btn.visible = true;
feel_mc.video_btn.visible = true;
TweenLite.to(feel_mc.learn_btn, .5, {alpha:1});
TweenLite.to(feel_mc.video_btn, .5, {alpha:1});
//Close Breathe
TweenLite.to(breathe_mc, 1, {y:117, ease:Elastic.easeOut});
TweenLite.to(breathe_mc.learn_btn, .5, {alpha:0});
TweenLite.to(breathe_mc.video_btn, .5, {alpha:0});
//Close Live
TweenLite.to(live_mc, 1, {y:117, ease:Elastic.easeOut});
TweenLite.to(live_mc.learn_btn, .5, {alpha:0});
TweenLite.to(live_mc.video_btn, .5, {alpha:0});
//Close Sleep
TweenLite.to(sleep_mc, 1, {y:77, ease:Elastic.easeOut});
TweenLite.to(sleep_mc.learn_btn, .5, {alpha:0});
TweenLite.to(sleep_mc.video_btn, .5, {alpha:0});
//Show Pic
TweenLite.to(pic_feel_mc, .5, {alpha:1});
//Show Text
TweenLite.to(feel_txt_mc, 1,{alpha:1});
//Hide Other Text
TweenLite.to(live_txt_mc, 1,{alpha:0});
TweenLite.to(sleep_txt_mc, 1,{alpha:0});
TweenLite.to(breathe_txt_mc, 1,{alpha:0});This error means that you are trying to access an object on display list that (object) is not there.
For example, if close_btn instance is not added as child, the following line will throw this error:
removeChild(close_btn);
One of the ways to remedy this is to confirm that the object is added:
if(contains(close_btn)) removeChild(close_btn); -
Action script 3 question: addChild and removeChild on same button??
I'm trying to make a button that when u click once, the movieclip will be removed and second time back on stage and so forth....
somehow i get this error
==================================
ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
at flash.display:DisplayObjectContainer/removeChild()
at sample_fla::MainTimeline/btnClick()
==================================
Anyone can help me with this, since I'm doing an interactive web for client and the deadline is near..... thanks in advance.
these are my code:
stop();
var swf:MovieClip;
var loader:Loader= new Loader();
var defaultswf:URLRequest= new URLRequest("./newSwfImport.swf");
//default swf when loaded
loader.load(defaultswf);
//add to stage
allSwfLoadHere.addChild(loader);
var boolean:Boolean = true ;
function btnClick(event:MouseEvent):void {
if(boolean == true){
allSwfLoadHere.removeChild(loader);
boolean == false
if(boolean ==false){
allSwfLoadHere.addChild(loader);
boolean == true
newSwfImport.addEventListener(MouseEvent.CLICK,btnClick);you have, at least, two errors:
1. you failed to use an if-else and
2. when trying to re-assign your boolean, you tested. ie, you used == when you should use =. so, your boolean remains true. then when you execute the 2nd time, you try and remove something that's already been removed.
use:
var swf:MovieClip;
var loader:Loader= new Loader();
var defaultswf:URLRequest= new URLRequest("./newSwfImport.swf");
//default swf when loaded
loader.load(defaultswf);
//add to stage
allSwfLoadHere.addChild(loader);
var boolean:Boolean = true ;
function btnClick(event:MouseEvent):void {
if(boolean){
allSwfLoadHere.removeChild(loader);
} else {
allSwfLoadHere.addChild(loader);
boolean=!boolean;
newSwfImport.addEventListener(MouseEvent.CLICK,btnClick); -
Image Gallery - ArgumentError: Error #2025
Hi Guys,
I am new to flash cs3 and action script 3.0. I have made 3
image galleries, that all work fine by themselves, however i have
recently tried to link them to a central flash file and I am
getting the error:
ArgumentError: Error #2025: The supplied DisplayObject must
be a child of the caller.
at flash.display::DisplayObjectContainer/removeChild()
at home_fla::MainTimeline/gotoHome()
I have attached the code for the central/home flash file
below.
Basically, all I am trying to achieve is to add the
client_images.swf as a child when the client images button is
clicked and then listen for a mouse click on the client_images home
button and remove the child. This works if I click the home button
straight away. If i don't click the home button with in 3 seconds,
i get the error.
I have had a good look for a solution to this problem and
haven't had much luck. Any help would be greatly appreciated. I can
send the .fla's if you need more information.
Cheers,
Paul.what's happening in client_images.swf? ie, btn_home is on the
main timeline. and that timeline has more than 1 frame, correct?
if yes, when 3 seconds expires the playhead is on a frame
where btn_home does not exist. ie, make sure it's the same instance
in frame 1 and frame whatever by clearing keyframes and re-creating
them on btn_home's layer. -
Loading .swf, addChild, and removeChild
Hello all,
I'm trying load an swf when you click a button, and load another in it's place when you click a different button. I'm using addChild to insert the swf onto the stage. Problem is that every time I click a new button, the new swf is loaded on top of the previous one, and I need the previous one to disappear. I tried using the removeChild method before the new swf is loaded to no effect.
Here's the function I'm using for the loader with my removeChild attempt in bold:
function newPage():void {
trace("load activated");
trace(""+target+".swf");
var req:URLRequest=new URLRequest(""+target+""+".swf");
var loader:Loader = new Loader();
if (loaderState==true){
top_mc.removeChild(loader);
loader.load(req);
loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, preLoad);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, fileLoaded);
function preLoad(event:ProgressEvent):void {
var percent:Number=Math.round(event.bytesLoaded/event.bytesTotal*100);
top_mc.preload_txt.text=String(""+percent+"");
function fileLoaded(event:Event):void {
trace("file loaded");
top_mc.addChild(loader);
loaderState=true;
The error I get is as follows:
ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
at flash.display::DisplayObjectContainer/removeChild()
at main_fla::MainTimeline/newPage()
at main_fla::MainTimeline/workLoaderEnter()
at main_fla::MainTimeline/clickF()
Perhaps there is a way to give the addChild an instance name so that I can remove it later?
Any ideas?
Thanks!Part of the problem is your trying to remove the loader just after you define it... it is not a child of anything at that point. Try the following instead of what you have. Another problem you can avoid is to not nest functions...
var loader:Loader
var loaderState:Boolean = false;
function newPage():void {
if (loaderState){
top_mc.removeChild(loader);
var req:URLRequest=new URLRequest(""+target+""+".swf");
loader = new Loader();
loader.load(req);
loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, preLoad);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, fileLoaded);
function preLoad(event:ProgressEvent):void {
var percent:Number=Math.round(event.bytesLoaded/event.bytesTotal*100);
top_mc.preload_txt.text=String(""+percent+"");
function fileLoaded(event:Event):void {
top_mc.addChild(loader);
loaderState=true; -
Custom Combo Box. Error # 2025
package files{
import flash.display.MovieClip;
import fl.data.DataProvider;
import fl.controls.ComboBox;
import flash.text.*;
import flash.display.Sprite;
import flash.filters.*
public class CustomComboBox extends MovieClip {
public var xLoca:Number;
public var yLoca:Number;
public var dataProvider:DataProvider;
public var cboClip:MovieClip;
public function CustomComboBox(xLoca:Number, yLoca:Number, dataProvider:DataProvider, prompt:String = "Select") {
cboClip = new MovieClip;
this.xLoca = xLoca
this.yLoca = yLoca
this.dataProvider = dataProvider;
var typeTextFormat:TextFormat = new TextFormat();
typeTextFormat.color = 0x333333;
typeTextFormat.size = 11;
typeTextFormat.font = "Verdana";
var menu1:ComboBox = new ComboBox();
cboClip.addChild(menu1);
var typeButton:Sprite = new Sprite();
menu1.addChild(typeButton);
typeButton.graphics.beginFill(0xCCCCCC);
typeButton.graphics.drawRect(0, 0, 109, 34);
typeButton.graphics.endFill();
typeButton.alpha = 0.75;
typeButton.filters = [new DropShadowFilter(3,120,0x000000,0.5,0,0,1,1,false,false,false)];
var dropButton:Sprite = new Sprite();
dropButton.graphics.beginFill(0x99CCFF);
dropButton.graphics.drawRect(0, 0, 109, 34);
dropButton.graphics.endFill();
dropButton.alpha = 0.75;
dropButton.filters = [new DropShadowFilter(3,120,0x000000,0.5,0,0,1,1,false,false,false)];
menu1.dropdown.addChild(dropButton);
menu1.setStyle("upSkin", typeButton);
menu1.setStyle("overSkin", typeButton);
menu1.setStyle("downSkin", typeButton);
menu1.setSize(109, 34);
menu1.dropdown.setRendererStyle("upSkin", dropButton);
menu1.dropdown.setRendererStyle("overSkin", dropButton);
menu1.dropdown.setRendererStyle("downSkin", dropButton);
menu1.dropdown.setSize(109, 34);
menu1.textField.setStyle("textFormat", typeTextFormat);
menu1.dropdown.setRendererStyle("textFormat", typeTextFormat);
menu1.move(xLoca, yLoca);
menu1.prompt = prompt;
menu1.dataProvider = dataProvider;// constructor code
addChild(cboClip);
Running the class above with the code below. At first everything works fine, but when you select something and then make a change you get
ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
at flash.display::DisplayObjectContainer/removeChild()
Does anyone have any ideas why?
var dp:DataProvider = new DataProvider();
dp.addItem( { label: "Some Data", data: "Some" } );
dp.addItem( { label: "More Data", data: "More" } );
dp.addItem( { label: "Way More Data", data: "Way More" } );
dp.addItem( { label: "No Data", data: "None" } );
var c:CustomComboBox = new CustomComboBox(50, 50, dp, "How Much Data?");
addChild(c)The error is indicating a problem with a removeChild() method call, and none of the code you show has that as far as I can see. So you probably need to look elsewhere for the problemed code.
-
Stupid error #2025 - How can I solve it?
Hi! How Are you guys! I'm having a problem while I'm trying to remove a Child. I have a button that loads the loader and a next and back button that let you navigate through the images in it. And last the MENU button that brings into the stage the menu bar. I would like that when you click the menu an action to remove the images from the loader. I can do that, but only if there were some images there in the loader, otherwise I get this error:
ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller. at flash.display:
:DisplayObjectContainer/removeChild()
It seems that the IF STATEMENT doesn't work properly. I guess that it must have an error, but I can't figure it out which.
Thanks in advance!!
Here is my code:
menuBra.addEventListener (MouseEvent.CLICK, onClickBra);
function onClickBra (event:MouseEvent):void {
if(contains(loaderBrand)) {
removeChild(loaderBrand);
var TweenPrint1:Tween = new Tween(menu_mc,"x", Strong.easeOut, -4000, 0, 1, true);
else {
var TweenPrint2:Tween = new Tween(menu_mc,"x", Strong.easeOut, -4000, 0, 1, true);
trace ("menu was clicked"); }It worked with this:
if(loaderBrand.parent != null && loaderBrand.parent == this) {
removeChild(loaderBrand);
var TweenPrint1:Tween = new Tween(menu_mc,"x", Strong.easeOut, -4000, 0, 1, true); }
Thanks!! -
PeerToPeerRtmfp.mxml sample Error #2025
Hi,
I'm trying out the PeerToPeerRtmfp.mxml sample of the LCCS SDK.
Environement:
Windows 7
Flash Builder 4.5
SDK 4.5
LCCS 10.3
Player 10.3
Scenario:
enter all requie room parameters and try to login
Problem:
After login I'm gettign an error:
ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
This is a more full log:
20:11:10 GMT+0300 RECEIVENODES UserManager
20:11:10 GMT+0300 receiveAllSynchData UserManager
20:11:10 GMT+0300 RECEIVENODES FileManager
20:11:10 GMT+0300 receiveAllSynchData FileManager
20:11:10 GMT+0300 checkManagerSync:[object FileManager]
20:11:10 GMT+0300 RECEIVENODES AVManager
20:11:10 GMT+0300 receiveAllSynchData AVManager
20:11:10 GMT+0300 checkManagerSync:[object StreamManager]
20:11:12 GMT+0300 RECEIVENODES RoomManager
20:11:12 GMT+0300 receiveAllSynchData RoomManager
20:11:12 GMT+0300 checkManagerSync:[object RoomManager]
20:11:12 GMT+0300 checkManagerSync:[object UserManager]
ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
at flash.display::DisplayObjectContainer/getChildIndex()
at mx.core::Container/getChildIndex()[E:\dev\hero_private\frameworks\projects\mx\src\mx\core \Container.as:2835]
at mx.containers::Panel/getChildIndex()[E:\dev\hero_private\frameworks\projects\mx\src\mx\co ntainers\Panel.as:1179]
at mx.controls::RadioButtonGroup/breadthOrderCompare()[E:\dev\hero_private\frameworks\projec ts\mx\src\mx\controls\RadioButtonGroup.as:611]
at mx.controls::RadioButtonGroup/breadthOrderCompare()[E:\dev\hero_private\frameworks\projec ts\mx\src\mx\controls\RadioButtonGroup.as:622]
at mx.controls::RadioButtonGroup/breadthOrderCompare()[E:\dev\hero_private\frameworks\projec ts\mx\src\mx\controls\RadioButtonGroup.as:622]
at mx.controls::RadioButtonGroup/breadthOrderCompare()[E:\dev\hero_private\frameworks\projec ts\mx\src\mx\controls\RadioButtonGroup.as:622]
at Array$/_sort()
at Array/http://adobe.com/AS3/2006/builtin::sort()
at mx.controls::RadioButtonGroup/http://www.adobe.com/2006/flex/mx/internal::addInstance()[E:\dev\hero_private\frameworks\p rojects\mx\src\mx\controls\RadioButtonGroup.as:473]
at mx.controls::RadioButton/addToGroup()[E:\dev\hero_private\frameworks\projects\mx\src\mx\c ontrols\RadioButton.as:574]
at mx.controls::RadioButton/commitProperties()[E:\dev\hero_private\frameworks\projects\mx\sr c\mx\controls\RadioButton.as:514]
at mx.core::UIComponent/validateProperties()[E:\dev\hero_private\frameworks\projects\framewo rk\src\mx\core\UIComponent.as:8209]
at mx.managers::LayoutManager/validateProperties()[E:\dev\hero_private\frameworks\projects\f ramework\src\mx\managers\LayoutManager.as:597]
at mx.managers::LayoutManager/doPhasedInstantiation()[E:\dev\hero_private\frameworks\project s\framework\src\mx\managers\LayoutManager.as:813]
at mx.managers::LayoutManager/validateNow()[E:\dev\hero_private\frameworks\projects\framewor k\src\mx\managers\LayoutManager.as:878]
at mx.core::Application/resizeHandler()[E:\dev\hero_private\frameworks\projects\mx\src\mx\co re\Application.as:1721]
at mx.core::Application/commitProperties()[E:\dev\hero_private\frameworks\projects\mx\src\mx \core\Application.as:1073]
at mx.core::UIComponent/validateProperties()[E:\dev\hero_private\frameworks\projects\framewo rk\src\mx\core\UIComponent.as:8209]
at mx.managers::LayoutManager/validateProperties()[E:\dev\hero_private\frameworks\projects\f ramework\src\mx\managers\LayoutManager.as:597]
at mx.managers::LayoutManager/doPhasedInstantiation()[E:\dev\hero_private\frameworks\project s\framework\src\mx\managers\LayoutManager.as:813]
at mx.managers::LayoutManager/doPhasedInstantiationCallback()[E:\dev\hero_private\frameworks \projects\framework\src\mx\managers\LayoutManager.as:1180]
Thanks,
OferHi Ofer,
Thanks for reporting this bug to us. I would assume It’s a weird Flex SDK bug. We would be fixing this issue in the next SDK Drop.
So for the fix,
Modify line 174-176 from
<mx:RadioButtonGroup id="radioGroup" />
<mx:RadioButton id="nellymoser" group="{radioGroup}" selected="false" label="{SoundCodec.NELLYMOSER}" click="changeCodec(event)" />
<mx:RadioButton id="speex" group="{radioGroup}" selected="true" label="{SoundCodec.SPEEX}" click="changeCodec(event)" />
To
<mx:RadioButtonGroup id="radioGroup1" />
<mx:RadioButton id="nellymoser" group="{radioGroup1}" selected="false" label="{SoundCodec.NELLYMOSER}" click="changeCodec(event)" />
<mx:RadioButton id="speex" group="{radioGroup1}" selected="true" label="{SoundCodec.SPEEX}" click="changeCodec(event)" />
As you see changing the id of the RadioGroup we were using fixes this issue.
Thanks
Arun -
Good Afternoon. I was attempting to merge a text box with an image box to get the mouse over effect to activate on both simultaneously. I grouped them, and this didn't do the trick. I've since realized the easiest fix is to merge the layers in photoshop so that they are the same layer, but I saved after doing it and prior to that realization. I'm now receiving an Error 2025 The supplied display object must be a child of the caller. This happened after I tried to ungroup or delete the group, but is now happening every time I open the site. I'll be saving a in progress file if I can recover from this, but until then I can no longer access my site in muse for more than 30 seconds without this error message and forced close-out.
Thank you.Please send us the .muse file at [email protected] along with a link to this thread so we can attempt to reproduce the error and either repair and return the file or explain how you can get past it. If the file is larger than 20Mb you can use a service like Adobe SendNow, Dropbox, WeTransfer, etc. (If you use a service, please include your return e-mail address in the body of the message, since not all services include it in the sharing invite they send.) Thanks.
-
ArgumentError: Error #2025
This is ridiculous, why do I keep getting this error. I can't
even find any information on the internet about it... i searched
Google for 'flash cs3 error 2025' and it pulls 149 English pages.
What does this error mean, how do I fix it and how do i prevent it.
Also, I was wondering what are some best practices for using the
debug console in Flash.
PS - I am using Adobe Flash CS3 Professional...
the error comes after i enter frame 40. there is nothing in
there except a single text input component. I have tried to remove
all code, and it still pops up. I deleted all other frames except
this one and it fixed it but i don't know why it was there. hmmm,
the error message is...haha i am sorry Trevor McCauley, i took it down becuase i did
not anticipate any further assistance however i will be more than
happy to put it back up. i have updated it since my last post
however the error is still there... this includes the flash project
file, all as files and the flash document. it is very thorough and
i hope the layout is easy to understand... man i hope that helps
thank you in advance for anything you could offer and i am very
greatful for the help.
the link has been updated (well i just put the rar file back
online)
http://network.isaacewing.com/rar/network.rar
ps - for anybody that downloads my files... when you look
through them... could you ***** the validity of my code, the
organization and the overall layout in the back of your mind...
meaning could you be as brutally honest as possible about what you
think about how i program... is it structured, clean, organized,
robust, and so on... any feedback on that would be ... meaningful
and i would like to know what you guys think! -
Hello
I am having some trouble adding UI controls dynamically. Mostly with radio buttons.
Here is an example that demonstrates my problem:
<s:Application
xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
creationPolicy="all"
>
<fx:Script>
<![CDATA[
import mx.containers.Form;
import mx.containers.Panel;
import mx.controls.Label;
import mx.controls.NumericStepper;
import mx.controls.RadioButton;
private var theChar:String = "B";
protected function btnAdd_clickHandler(event:MouseEvent):void
var theForm:Form = new Form();
theForm.label = theChar;
//1. Label
var myLabel:Label = new Label();
myLabel.text = "My Label";
myLabel.width=120;
theForm.addChild(myLabel);
//2. Numeric Stepper
var myNumStepper:NumericStepper = new NumericStepper();
myNumStepper.id = "numPointHigh" + theChar;
myNumStepper.name = "numPointHigh" + theChar;
myNumStepper.minimum = 0;
myNumStepper.maximum = 120;
myNumStepper.width = 50;
myNumStepper.height = 30;
theForm.addChild(myNumStepper);
//3. radio button
var myRadioButton:RadioButton = new RadioButton;
myRadioButton.id = "myRadioButton" + theChar;
myRadioButton.name = "myRadioButton" + theChar;
myRadioButton.label = "my radio button";
myRadioButton.selected = true;
theForm.addChild(myRadioButton);
//4. Panel
var thePanel:Panel = new Panel();
thePanel.width = 300;
thePanel.height = 475;
thePanel.name=theChar;
thePanel.title = "My Profile Panel";
thePanel.setStyle("backgroundColor", "blue");
//add the form to the panel
thePanel.addChild(theForm);
//add the Panel to the list control
myList.addChild(thePanel);
protected function btnClear_clickHandler(event:MouseEvent):void
var numChildren:Number = myList.numChildren;
for(var i:Number=numChildren - 1; i > -1; i--){
myList.removeChildAt(i);
]]>
</fx:Script>
<mx:VBox width="100%">
<mx:List id="myList" />
<mx:Button id="btnAdd" label="Add a panel" click="btnAdd_clickHandler(event)" color="black"/>
<mx:Button id="btnClear" label="Clear" click="btnClear_clickHandler(event)" color="black" />
</mx:VBox>
</s:Application>
^ Run that. Click the "Add a panel" button. Then click "Clear". Then click the "Add a panel" button again. You will see the error:
ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
at flash.display::DisplayObjectContainer/getChildIndex()
at mx.core::Container/getChildIndex()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\core \Container.as:2833]
at mx.containers::Panel/getChildIndex()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\co ntainers\Panel.as:1174]
at mx.controls::RadioButtonGroup/breadthOrderCompare()[E:\dev\4.0.0\frameworks\projects\fram ework\src\mx\controls\RadioButtonGroup.as:600]
at mx.controls::RadioButtonGroup/breadthOrderCompare()[E:\dev\4.0.0\frameworks\projects\fram ework\src\mx\controls\RadioButtonGroup.as:611]
at mx.controls::RadioButtonGroup/breadthOrderCompare()[E:\dev\4.0.0\frameworks\projects\fram ework\src\mx\controls\RadioButtonGroup.as:611]
at Array$/_sort()
at Array/http://adobe.com/AS3/2006/builtin::sort()
at mx.controls::RadioButtonGroup/http://www.adobe.com/2006/flex/mx/internal::addInstance()[E:\dev\4.0.0\frameworks\projects \framework\src\mx\controls\RadioButtonGroup.as:465]
at mx.controls::RadioButton/addToGroup()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\c ontrols\RadioButton.as:574]
at mx.controls::RadioButton/commitProperties()[E:\dev\4.0.0\frameworks\projects\framework\sr c\mx\controls\RadioButton.as:514]
at mx.core::UIComponent/validateProperties()[E:\dev\4.0.0\frameworks\projects\framework\src\ mx\core\UIComponent.as:7772]
at mx.managers::LayoutManager/validateProperties()[E:\dev\4.0.0\frameworks\projects\framewor k\src\mx\managers\LayoutManager.as:572]
at mx.managers::LayoutManager/doPhasedInstantiation()[E:\dev\4.0.0\frameworks\projects\frame work\src\mx\managers\LayoutManager.as:730]
at mx.managers::LayoutManager/doPhasedInstantiationCallback()[E:\dev\4.0.0\frameworks\projec ts\framework\src\mx\managers\LayoutManager.as:1072]
I do not understand why I cannot re-add the radio button? If you comment out the code for the radio button (comment section #3.) you can re-add the panels easily. It is only happening when I have radio buttons being added to the form/panel.
Why is this happening and how do I fix it? Why is this only happening to radio buttons? I thought I had this fixed^ well, okay, but that's not the problem.
here, i removed list and replaced with Panel. same problem on the radio buttons.
<s:Application
xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:containers="com.dougmccune.containers.*"
xmlns:mx="library://ns.adobe.com/flex/mx"
creationPolicy="all"
>
<fx:Script>
<![CDATA[
import mx.containers.Form;
import mx.containers.Panel;
import mx.controls.Label;
import mx.controls.NumericStepper;
import mx.controls.RadioButton;
private var theChar:String = "B";
protected function btnAdd_clickHandler(event:MouseEvent):void
var theForm:Form = new Form();
theForm.label = theChar;
//1. Label
var myLabel:Label = new Label();
myLabel.text = "My Label";
myLabel.width=120;
theForm.addChild(myLabel);
//2. Numeric Stepper
var myNumStepper:NumericStepper = new NumericStepper();
myNumStepper.id = "numPointHigh" + theChar;
myNumStepper.name = "numPointHigh" + theChar;
myNumStepper.minimum = 0;
myNumStepper.maximum = 120;
myNumStepper.width = 50;
myNumStepper.height = 30;
theForm.addChild(myNumStepper);
//3. radio button
var myRadioButton:RadioButton = new RadioButton;
myRadioButton.id = "myRadioButton" + theChar;
myRadioButton.name = "myRadioButton" + theChar;
myRadioButton.label = "my radio button";
myRadioButton.selected = true;
theForm.addChild(myRadioButton);
//4. Panel
var thePanel:Panel = new Panel();
thePanel.width = 300;
thePanel.height = 475;
thePanel.name=theChar;
thePanel.title = "My Profile Panel";
thePanel.setStyle("backgroundColor", "blue");
//add the form to the panel
thePanel.addChild(theForm);
//add the Panel to the list control
myContainer.addChild(thePanel);
protected function btnClear_clickHandler(event:MouseEvent):void
var numChildren:Number = myContainer.numChildren;
for(var i:Number=numChildren - 1; i > -1; i--){
myContainer.removeChildAt(i);
]]>
</fx:Script>
<mx:VBox width="100%">
<mx:Panel id="myContainer" />
<mx:Button id="btnAdd" label="Add a panel" click="btnAdd_clickHandler(event)" color="black"/>
<mx:Button id="btnClear" label="Clear" click="btnClear_clickHandler(event)" color="black" />
</mx:VBox>
</s:Application>
Any idea why radio buttons causing this to happen? If I comment out the radio button, this works fine. This is really baffling me.
The exception is thrown when the dynamically created panel (thePanel) is added to the main Panel (myContainer):
myContainer.addChild(thePanel); <--- causes the exception!
^ Why would radio buttons make a difference on "thePanel"?? How can I enforce parent-child relationship, explicitly? .parent is read-only
Maybe you are looking for
-
Can't uninstall/update Can't find iTunes.msi file
Something happened to my itunes. Could have been my daughter's creative genius or any one of a thousand other things.... All I know is (and I don't use iTunes a lot) I can't get iTunes to load. When I click on my desktop icon or try to run it from my
-
How to create own site template in sharepoint 2013?
Hi All, How to create a new site template in SharePoint 2013? Any suggestion please.
-
Creating 'print this page' button using AS3
Hi all, I need to create a button, or at least a movie clip that functions like a button that will print a page when clicked. Ideally I would like to have the button as part of the flash application, which will be online embedded into a web page as a
-
Unknown caller/Unknown - special ring/photo?
how can i sent up my iPhone to have a "special" ring & photo when it comes up with "Unknown" caller? please help.
-
New to DVD 4 and struggling to understand the scripts functions and despite reading as much info as poss in manual and on the web I still cannot figure out how to programme a script to get the resume button to bring the viewer back to where the main