• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

removeChild issue

Engaged ,
Oct 08, 2008 Oct 08, 2008

Copy link to clipboard

Copied

Hi All,

Got this code loading thumbs, and when their clicked loads a bigger image etc...

function xmlLoaded (e:Event):void {

xml = XML(e.target.data);
images = xml.image;

for(var i:uint=0; i<images.length();i++){
var thumb:MovieClip = new MovieClip();
var thumbLoader:Loader = new Loader();
thumb.x = 65*i + spacing;
thumb.y = 370;
thumb.src = images[counter].@url;
thumb.mouseChildren = false;
thumb.buttonMode = true;
thumbLoader.load(new URLRequest(images[counter].@thumb));
addChild(thumb);
thumb.alpha = 0;
TweenMax.to(thumb, 1, {alpha:1, ease:Sine.easeIn});
thumb.addChild(thumbLoader);
thumbLoader.x = 24;
thumbLoader.y = -14;
thumb.addEventListener(MouseEvent.CLICK, clickedThumb);
counter++;

}
loader.load(new URLRequest(images[0].@url));

}

Problem happens with the following code - I go into fullScreen and want to either hide the thumb etc... or remove it:

masker.addEventListener(MouseEvent.CLICK, fullScreen);

function fullScreen(MouseEvent):void
{
thumb.visible = false; // do not work
removeChild(thumb); // do not work
stage.displayState = StageDisplayState.FULL_SCREEN;
masker.x=0;
masker.y=0;
masker.width=stage.stageWidth;
masker.height=stage.stageHeight;
StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;

}

masker.buttonMode = true;

Hope someone can provide an answer to this, as it's driving me BONKERS 😉 It's got to be down to how I am referring to it, the path.

Kind Regards,

Boxing Boom
TOPICS
ActionScript

Views

298

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 08, 2008 Oct 08, 2008

Copy link to clipboard

Copied

There are a few things that seem wrong with the script, for example, you may have created a 100 "thumb" movieclips, which of them is the one you want to remove? What is "masker"? Will the thumb you removed need to come back after you leave full screen mode?


Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Oct 08, 2008 Oct 08, 2008

Copy link to clipboard

Copied

Hi Colin,

Yes thumb will need to come back as normal. Masker is an mc. It's just used for a click platform. The thumb is a display for the 3 images thats loaded via xml - image thumbs.

Kind Regards,

Boxing Boom

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 08, 2008 Oct 08, 2008

Copy link to clipboard

Copied

I can see a few possible problems. One is that if you want to reference a variable you create from multiple functions it needs to be declared outside both functions. Such as reference 1 below.

Another is if you are creating many objects creating the same variable you should add them to an array to be able to access them later as below in reference 2.

Note sure if these may help, but thought I would throw them out there.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Oct 08, 2008 Oct 08, 2008

Copy link to clipboard

Copied

LATEST
Hi All,

I have started a new thread: removeChild(getChildByName("whatEverName1"));

Boy this is tiring work ;)

Kind Regards,

Boxing Boom

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines