Copy link to clipboard
Copied
I have an xml loaded thumb scroller which stays on the screen when I exit the frames where it exists.
Here is the set up which I have tried to fix this issue. It was suggested that I put an mc on the frames with the image scroller and call it dummy_mc.
Then I put the code on the frames which are not supposed to have thumb scroller:
dummy_mc.visible = false;
function removeScrollerF2(e:Event=null):void{
if(scroller){//prevents a problem if you were to use the same navigation code after the scroller is removed
scroller.removeEventListener(Event.ENTER_FRAME, moveScrollerThumbs);
removeChild(scroller);
scroller=null; // if, when you want to re-create your scroller, it fails to be re-created, remove this line of code.
}
trace("dummy2_mc works on null");
}
dummy_mc.addEventListener(Event.REMOVED_FROM_STAGE,removeScrollerF2);
---------------------------------------------------------------------------------------------------------------------------
I have this argument error in the output panel:
ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
at flash.display::DisplayObjectContainer/removeChild()
at acolyte51c_AppsPopUpsThumbs_fla::mainsite_mc_2/removeScrollerF2()[acolyte51c_AppsPopUpsThumbs_fla.mainsite_mc_2::frame73:399]
at flash.display::MovieClip/gotoAndPlay()
at acolyte51c_AppsPopUpsThumbs_fla::mainsite_mc_2/gotoFrame2()[acolyte51c_AppsPopUpsThumbs_fla.mainsite_mc_2::frame73:372]
This is the frame73:399
removeChild(scroller);
on mainsite_mc frame 73:
replace line 38:
this.addChild(scroller);
with
dummy_mc.addChild(scroller);
and replace the code from 407+ with:
//dummy_mc.visible = false; <- remove the graphics from the stage of dummy_mc
dummy_mc.addEventListener(Event.REMOVED_FROM_STAGE,removeScrollerF2);
function removeScrollerF2(e:Event=null):void{
scroller.removeEventListener(Event.ENTER_FRAME, moveScrollerThumbs);
}
Copy link to clipboard
Copied
You need to reference scroller first, i.e.:
function removeScrollerF2(e:Event=null):void
{
//I'm guessing your scroller is on the root timeline, else, MovieClip(root) will need to be changed to the instance name of clip where your scroller is located
var scroller:Object = MovieClip(root).getChildByName("yourScroller'sInstanceName");
if(scroller){
hth,
~Chipleh
Copy link to clipboard
Copied
I implemented your code like this:
var scroller:Object = MovieClip(root).getChildByName("thisOne");
I get no more errors, but the scroller is still stays on the screen.
Maybe it helps - here is the code section where I construct the scroller:
//thumb scroller////////////////////////////////////////////////////////////////////////
//load xml
var xmlLoader:URLLoader = new URLLoader();
/////Parse XML
var xmlData:XML = new XML();
var xmlPath:String = "loadingAssets/appThumbnails/slideshow_image_scroller_ActiveTuts_mine/app_thmbs_imgs60x90.xml";
xmlLoader.load(new URLRequest(xmlPath));
xmlLoader.addEventListener(Event.COMPLETE, LoadXML);
function LoadXML(e:Event):void {
xmlData = new XML(e.target.data);
buildScroller(xmlData.image); //rather than trace the xmlList, we send it to our buildScroller function
}
/////Build Scroller MovieClip to Contain Each Image
var scroller:MovieClip = new MovieClip();
var padding:Number = 5;//creating a var for padding to be used later on in easier calculations
//making the mask+boundaries
scroller.mask = maskRctngl;
var maskBorders:Number = 93;// distance from stage borders 88 px + padding 5 px
this.addChild(scroller);
scroller.y = 645;
scroller.x = maskBorders;
var thumbSmall:Number = 1;//setting up scale Tween on rollover
var thumbLarge:Number = 1.05;//setting up scale Tween on rollover
/////
/////Parse XML
//build scroller from xml
function buildScroller(imageList:XMLList):void{
for (var item:uint = 0; item<imageList.length();item++) {
var thisOne:MovieClip = new MovieClip();
//outline
var thumbFadeOut:Number = .3;//setting Border Tweens//doesn't work with TweenMax transitions
var thumbFadeIn:Number = .7;//setting Border Tweens//doesn't work with TweenMax transitions
var blackBox:Sprite = new Sprite();
blackBox.graphics.beginFill(0xFFFFFF);
blackBox.graphics.drawRect(-1, -1, 62, 92);
blackBox.alpha = thumbFadeOut;//setting Border Tweens
thisOne.addChild(blackBox);
thisOne.blackBox = blackBox;//setting Border Tweens
thisOne.x = thisOne.myx = (60 + padding) *item;
thisOne.itemNum = item;
thisOne.title = imageList[item].attribute("title");
thisOne.link = imageList[item].attribute("url");
thisOne.src = imageList[item].attribute("src");
thisOne.alpha = 0;//makes all thumb images at alpha=0 before they are fully loaded
//Loading and Adding the Images
//image container
var thisThumb:MovieClip = new MovieClip();
//add image
var ldr:Loader = new Loader();
var urlReq:URLRequest = new URLRequest(thisOne.src);
ldr.load(urlReq);
//assign event listeners for Loader
ldr.contentLoaderInfo.addEventListener(Event.COMPLETE,completeHandler_AppPopUps);//tells us when the loading is complete
ldr.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, errorHandler_AppPopUps);//tells us if there are any typo errors when the loading is complete
thisThumb.addChild(ldr);
thisOne.addChild(thisThumb);
//create listeners for this thumb
thisOne.buttonMode = true;//makes boxes act as buttons
thisOne.addEventListener(MouseEvent.CLICK, clickScrollerItem_AppPopUps);//makes boxes act as buttons
thisOne.addEventListener(MouseEvent.MOUSE_OVER, overScrollerItem_AppPopUps);//traces the title when the mouse is over the bounding box in the Output Panel
thisOne.addEventListener(MouseEvent.MOUSE_OUT, outScrollerItem_AppPopUps);//traces the title when the mouse is out the bounding box in the Output Panel
//add item
scroller.addChild(thisOne);
}
scroller.addEventListener(Event.ENTER_FRAME, moveScrollerThumbs);//adding movement on mouse position
}
Copy link to clipboard
Copied
//This will add the scroller to the root timeline
addChild(scroller);
//This will give the scroller an instance name of 'theScroller'
scroller.name = "theScroller"
//This will remove the instance of scroller
var scroller:Object = MovieClip(root).getChildByName('theScroller");
if(scroller)
{
removeChild(scroller)
}
Copy link to clipboard
Copied
I get errors, Probably I did not apply the code as you intended. Here is the hole line of code:
dummy_mc.visible = false;
dummy_mc.addEventListener(Event.REMOVED_FROM_STAGE,removeScrollerF2);
function removeScrollerF2(e:Event=null):void{
//This will add the scroller to the root timeline
addChild(scroller);
//This will give the scroller an instance name of 'theScroller'
scroller.name = "theScroller"
//This will remove the instance of scroller
var scroller:Object = MovieClip(root).getChildByName("theScroller");
if(scroller){//prevents a problem if you were to use the same navigation code after the scroller is removed
scroller.removeEventListener(Event.ENTER_FRAME, moveScrollerThumbs);
removeChild(scroller);
scroller=null; // if, when you want to re-create your scroller, it fails to be re-created, remove this line of code.
}
trace("dummy2_mc works on null");
}
--------------------------------------------------------------------------------------------------
here is the errror message I get:
Symbol 'mainsite_mc', Layer 'AS3', Frame 73, Line 410 | 1118: Implicit coercion of a value with static type Object to a possibly unrelated type flash.display:DisplayObject. |
Line 410 refers to this: removeChild(scroller);
---------------------------------------------------------------------------------------------------
Please let me know if the lines:
//This will add the scroller to the root timeline
addChild(scroller);
//This will give the scroller an instance name of 'theScroller'
scroller.name = "theScroller"
are supposed to be in another location in the code"
----------------------------------------------------------------------------------------------------
In the code section which constructs the scrolle (I have posted before) i noticed these lines (perhaps it shows the way the scroller is constructed):
/////Build Scroller MovieClip to Contain Each Image
var scroller:MovieClip = new MovieClip();
this.addChild(scroller);
Copy link to clipboard
Copied
use:
dummy_mc.visible = false;
function removeScrollerF2(e:Event=null):void{
if(scroller){//prevents a problem if you were to use the same navigation code after the scroller is removed
scroller.removeEventListener(Event.ENTER_FRAME, moveScrollerThumbs);
scroller.parent.removeChild(scroller);
scroller=null; // if, when you want to re-create your scroller, it fails to be re-created, remove this line of code.
}
trace("dummy2_mc works on null");
}
dummy_mc.addEventListener(Event.REMOVED_FROM_STAGE,removeScrollerF2);
Copy link to clipboard
Copied
I still have the same error:
ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
at flash.display::DisplayObjectContainer/removeChild()
at acolyte51c_AppsPopUpsThumbs_fla::mainsite_mc_2/removeScrollerF2()[acolyte51c_AppsPopUpsThumbs_fla.mainsite_mc_2::frame73:404]
at flash.display::MovieClip/gotoAndPlay()
at acolyte51c_AppsPopUpsThumbs_fla::mainsite_mc_2/gotoFrame2()[acolyte51c_AppsPopUpsThumbs_fla.mainsite_mc_2::frame73:372]
Line refers to this:
scroller.parent.removeChild(scroller);
I tried adding .parent one at a time and retest but it did not work either. I added up to five instances (scroller.parent.parent.parent.parent.parent.removeChild(scroller);
Copy link to clipboard
Copied
then scroller is not added to the stage. use:
if(scroller){//prevents a problem if you were to use the same navigation code after the scroller is removed
if(scroller.stage){
scroller.removeEventListener(Event.ENTER_FRAME, moveScrollerThumbs);
scroller.parent.removeChild(scroller);
scroller=null; // if, when you want to re-create your scroller, it fails to be re-created, remove this line of code.
}
}
Copy link to clipboard
Copied
does not work.
My entire code is this:
dummy_mc.visible = false;
dummy_mc.addEventListener(Event.REMOVED_FROM_STAGE,removeScrollerF2);
function removeScrollerF2(e:Event=null):void{
//This will give the scroller an instance name of 'theScroller'
//scroller.name = "theScroller"
//This will remove the instance of scroller
var scroller:Object = MovieClip(root).getChildByName("theScroller");
if(scroller){//prevents a problem if you were to use the same navigation code after the scroller is removed
scroller.removeEventListener(Event.ENTER_FRAME, moveScrollerThumbs);
scroller.parent.removeChild(scroller);
scroller=null; // if, when you want to re-create your scroller, it fails to be re-created, remove this line of code.
}
}
I got rid of the line addChild(scroller);
With the line //scroller.name = "theScroller" I get no errors but the scroller is still on the pages when I navigate out.
If I uncomment the line scroller.name = "theScroller" then I get this error message:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at acolyte51c_AppsPopUpsThumbs_fla::mainsite_mc_2/removeScrollerF2()[acolyte51c_AppsPopUpsThumbs_fla.mainsite_mc_2::frame73:401]
at flash.display::MovieClip/gotoAndPlay()
at acolyte51c_AppsPopUpsThumbs_fla::mainsite_mc_2/gotoFrame2()[acolyte51c_AppsPopUpsThumbs_fla.mainsite_mc_2::frame73:372]
frame73:401 is this: scroller.name = "theScroller"
Copy link to clipboard
Copied
you didn't use the code i suggested. again, use:
if(scroller){//prevents a problem if you were to use the same navigation code after the scroller is removed
if(scroller.stage){
scroller.removeEventListener(Event.ENTER_FRAME, moveScrollerThumbs);
scroller.parent.removeChild(scroller);
scroller=null; // if, when you want to re-create your scroller, it fails to be re-created, remove this line of code.
}
}
Copy link to clipboard
Copied
Here is the entire code (which is located on the same frames as the xml image thumb scroller):
dummy_mc.visible = false;
dummy_mc.addEventListener(Event.REMOVED_FROM_STAGE,removeScrollerF2);
function removeScrollerF2(e:Event=null):void{
if(scroller){//prevents a problem if you were to use the same navigation code after the scroller is removed
if(scroller.stage){
scroller.removeEventListener(Event.ENTER_FRAME, moveScrollerThumbs);
scroller.parent.removeChild(scroller);
scroller=null; // if, when you want to re-create your scroller, it fails to be re-created, remove this line of code.
}
}
}
---------------------------------------------------------------------------------------------------
I got rid off:
//This will add the scroller to the root timeline
addChild(scroller);
//This will give the scroller an instance name of 'theScroller'
scroller.name = "theScroller"
//This will remove the instance of scroller
var scroller:Object = MovieClip(root).getChildByName("theScroller");
---------------------------------------------------------------------------------------------------
I still get the same error:
ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
at flash.display::DisplayObjectContainer/removeChild()
at acolyte51c_AppsPopUpsThumbs_fla::mainsite_mc_2/removeScrollerF2()[acolyte51c_AppsPopUpsThumbs_fla.mainsite_mc_2::frame73:400]
at flash.display::MovieClip/gotoAndPlay()
at acolyte51c_AppsPopUpsThumbs_fla::mainsite_mc_2/gotoFrame2()[acolyte51c_AppsPopUpsThumbs_fla.mainsite_mc_2::frame73:372]
frame73:400 is this line: scroller.parent.removeChild(scroller);
Copy link to clipboard
Copied
is all your code attached to the same timeline including your pageB code?
Copy link to clipboard
Copied
yes, all my code in on the same main timeline in the pageB section.
Copy link to clipboard
Copied
what do you mean by pageB section?
Copy link to clipboard
Copied
I segmented my time line into labeled sections separated by key frames. Each section is at about 10 frames so I can read what the label says and know where I am on the time line. The labeled section with the xml constructed image thumb scroller is located on frames 73 to 82. I refered to this section as pageB in my previous post about troubled "holderMovieClip" for SWF Loader you have helped me a day before.
All the code for the constructing an xml loaded image thumb scroller and the code we are working on right now is located on the main time line on the pageB section, i.e. on the section from frames 73 to 82. There are now individual key frames between 73-82.
(each section is assigned unique names. For example the labeled section I refer to as "pageB" is actually named "appPopUps". All those label names make sense to me, but I figured "pageB" would be easier to use to resolve this code issue)
Copy link to clipboard
Copied
actually, in this and all future posts in this and other flash threads, it will much less confusing to simply refer to frame numbers or you must make it clear you're using frame labels. using pageB sounds like a movieclip name.
what does the following trace reveal:
dummy_mc.visible = false;
dummy_mc.addEventListener(Event.REMOVED_FROM_STAGE,removeScrollerF2);
function removeScrollerF2(e:Event=null):void{
if(scroller){//prevents a problem if you were to use the same navigation code after the scroller is removed
if(scroller.stage){
trace(scroller.parent.name, scroller.name);
trace(scroller.parent.getChildByName(scroller.name).name);
scroller.removeEventListener(Event.ENTER_FRAME, moveScrollerThumbs);
scroller.parent.removeChild(scroller);
scroller=null; // if, when you want to re-create your scroller, it fails to be re-created, remove this line of code.
}
}
}
Copy link to clipboard
Copied
when I navigate out of frames 73-82 (where the xml scroller and trace code is located) then on the labeled section I havigate to I have the following:
instance2 instance579
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at acolyte51c_AppsPopUpsThumbs_fla::mainsite_mc_2/removeScrollerF2()[acolyte51c_AppsPopUpsThumbs_fla.mainsite_mc_2::frame73:423]
at flash.display::MovieClip/gotoAndPlay()
at acolyte51c_AppsPopUpsThumbs_fla::mainsite_mc_2/onClick_ContactUs_btn()[acolyte51c_AppsPopUpsThumbs_fla.mainsite_mc_2::frame1:1044]
line 73:423 refers to:
trace(scroller.parent.getChildByName(scroller.name).name);
Copy link to clipboard
Copied
what does the following trace reveal:
dummy_mc.visible = false;
dummy_mc.addEventListener(Event.REMOVED_FROM_STAGE,removeScrollerF2);
function removeScrollerF2(e:Event=null):void{
if(scroller){//prevents a problem if you were to use the same navigation code after the scroller is removed
if(scroller.stage){
trace(scroller.parent.name, scroller.name);
for(var i:int=0;i<scroller.parent.numChildren;i++){
trace(scroller.parent.getChildAt(i).name);
}
scroller.removeEventListener(Event.ENTER_FRAME, moveScrollerThumbs);
scroller.parent.removeChild(scroller);
scroller=null; // if, when you want to re-create your scroller, it fails to be re-created, remove this line of code.
}
}
}
Copy link to clipboard
Copied
instance2 instance579
instance3
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at acolyte51c_AppsPopUpsThumbs_fla::mainsite_mc_2/removeScrollerF2()[acolyte51c_AppsPopUpsThumbs_fla.mainsite_mc_2::frame73:425]
at flash.display::MovieClip/gotoAndPlay()
at acolyte51c_AppsPopUpsThumbs_fla::mainsite_mc_2/gotoFrame2()[acolyte51c_AppsPopUpsThumbs_fla.mainsite_mc_2::frame73:372]
frame73:425 refers to:
trace(scroller.parent.getChildAt(i).name);
Copy link to clipboard
Copied
what does the following trace reveal:
dummy_mc.visible = false;
dummy_mc.addEventListener(Event.REMOVED_FROM_STAGE,removeScrollerF2);
function removeScrollerF2(e:Event=null):void{
if(scroller){//prevents a problem if you were to use the same navigation code after the scroller is removed
if(scroller.stage){
trace(scroller.parent.name, scroller.name);
for(var i:int=0;i<scroller.parent.numChildren;i++){
trace(i, scroller.parent.getChildAt(i));
}
scroller.removeEventListener(Event.ENTER_FRAME, moveScrollerThumbs);
scroller.parent.removeChild(scroller);
scroller=null; // if, when you want to re-create your scroller, it fails to be re-created, remove this line of code.
}
}
}
Copy link to clipboard
Copied
instance2 instance579
0 [object Shape]
1 null
2 null
3 null
4 null
5 null
6 null
7 null
8 null
9 [object MovieClip]
10 [object Shape]
11 [object MovieClip]
12 [object MovieClip]
13 [object MovieClip]
ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
at flash.display::DisplayObjectContainer/removeChild()
at acolyte51c_AppsPopUpsThumbs_fla::mainsite_mc_2/removeScrollerF2()[acolyte51c_AppsPopUpsThumbs_fla.mainsite_mc_2::frame73:431]
at flash.display::MovieClip/gotoAndPlay()
at acolyte51c_AppsPopUpsThumbs_fla::mainsite_mc_2/onClick_ContactUs_btn()[acolyte51c_AppsPopUpsThumbs_fla.mainsite_mc_2::frame1:1044]
line 431 refers to :
scroller.parent.removeChild(scroller);
---------------------
I have to step out for a few hours, thank you. I will test the site again after I come back.
Best Regards
Copy link to clipboard
Copied
that is quite a mess you have there. i don't think i've ever seen anything like that.
upload your fla to a server and post a link.
Copy link to clipboard
Copied
Thanks for taking a look at my file. My flash site uses a lot of loaded swf files which are used in navigation as well. So I ended up compiling a folder with all depended files. It came down to be a 615MB file if I include all videos which are used on the site.
This file is called "stage three A.zip". Videos are not used for navigation, so perhaps it will be easier to download a version without them.
Then I made a smaller file without all the videos "stage three B.zip" which is at 118MB.
You can access it in two ways.
1. Go to http://ngrinchenko.com/flashFiles/
Name: flashHelp
Password: flashHelp2013
Please choose iether a complete version or a smaller version without the videos : "stage three B.zip"
2. Using an FTP application
Hostname: ngrinchenko.com
Username: kglad
Password: flashHelp2013
(if you will be promted for a folder use flashFiles, but it should not be requested)
Thank you for your help. I greatly welcome your critique. However I understand that most probably I have a lot of mistakes there and it will be impossible to address most of them. But I would appreciate if you could point out anything you can to make the site better. Perhaps I have some major messes which would be possible to address?
You will notice that the site is 90% animated with greensock tween engine. I am in the process of removing the last flash based tweens.
Once you download the file please click on "newTest.fla"
Once you download the file please let me know I would like to take it off the server.
Thank you.
Copy link to clipboard
Copied
you can take it off the server.
what needs to be done to trigger the error?
Copy link to clipboard
Copied
Forgot about it.
When the site opens and you see how the collage of images animates on the screen into place, please click on any of them. It will bring you to the screen whith the clicked image bigger version and an image thumb scroller at the bottom of the screen. If you click on any of the smaller thumb nails then you are still in the same labeled section and no error happens. If you click on any of the main navigation buttons on top or any of the small products pictures (which light up on roll over) on the right of the large image then you navigate out of this labeled section. This is when the error happens, when a user leaves the labeled section with the xml loaded image thumb scroller. The scroller still stays on the screeen and all the errrors happen.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now