Hi,
Hope I’m in the right place for this plea from yet another novice trying to learn AS3 in Flash with a couple of very good books but no one to talk to about it - and in danger of losing hair in the process.
My problem:
I have a web site containing 8 pages. Each page is a separate movie clip, and each is in a Labeled frame. My intention is to have an overlay for each of the buttons in the top left panel of the home page.
On the positive side I have managed to achieve the dynamic placement of an instance of a library movie clip called “sampleAR” via addChild to overlay on top of my home page.
But I can’t for the life of me get removeChild to rid me of the wretched thing again.
My home page is in frame 1 of the movie labeled “Home”. This contains a movie clip with the instance name “HomePage” on the stage.
Inside the “HomePage” movie clip is my script sitting at the end where the movie stops in frame 44.
The code sits here because this is the only place I’ve managed to get any kind of result with the following code:
stop();
import flash.display.MovieClip;
import flash.events.MouseEvent;
function AnRep() {
//Annual Report - Show fade in sample page
this.sampleAR_btn.addEventListener(MouseEvent.CLICK, displaySampleAR);
}
AnRep();
function displaySampleAR(event:MouseEvent):void {
var sampleAR1:sampleAR = new sampleAR();
this.addChild(sampleAR1);
}
//Annual Report - Remove sample page
this.MovieClip.sampleAR1.removeSampleAR_btn.addEventListener(MouseEvent.CLICK, removeSampleAR);
function removeSampleAR(event:MouseEvent):void {
removeChild(sampleAR1);
}
This generates the following error:
1120: Access of undefined property sampleAR1.
When I comment out the removeChild function the addChild function works ok.
What I would dearly like is for someone to tell me how to remove it from the screen, to reveal and leave the “HomePage” unmoved.
But more than that, I’d really like someone to explain what is wrong and why because I am really struggling with this.
Link to FLA file in case anyone wants a look.
http://www.scottpartnership.com/images/TestWebSite.fla.zip
Thanks very much for your help.
Keith