FORUMS: list search recent posts

buttons lingering

COW Forums : Adobe Flash

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Terrence Dunlop
buttons lingering
on Jun 27, 2008 at 9:24:31 pm

I've been having this problem with a single button and its driving me crazy.

I have a button in a contact page that directs users to a map of our company's location. After users click the button, the map appears, but the button itself lingers there, sitting on top of it.

I have an "onClick" function that removes the children of the previous page on MOUSE_UPs. That looks like this:

function onClick(event:MouseEvent):void{
if ( numChildren > 0)
removeChildAt( 0 );
trace("prev. screen removed and now:");

but it won't remove buttons or movie clips. It's like they're on a different display list.

Scoping problem?

Any help anyone has would be greatly appreciated.

Return to posts index

Sher Ali
Re: buttons lingering
on Jun 27, 2008 at 10:08:45 pm

why not you just hide the button?

you can hide the button using:

function onClick(event:MouseEvent):void{
event.currentTarget.visible = false;

Sher Ali
Flash & Flex Developer
My FlashDen Portfolio

Return to posts index

Terrence Dunlop
Re: buttons lingering
on Sep 6, 2008 at 4:08:13 pm

I was going at this the completely wrong way, so I want to post a reply to my own post to direct learning designers away from AddChildAt and RemoveChildAt for changes in their flash site's graphical user interface.

Out of inexperience, I figured an elegant flash design includes all its elements in the same flash project, with add child and remove child functions happening whenever someone Mouse ups or clicks or whatever. It's not that complicated.

The solution is the Loader function. This entails creating a main page flash file, with all your GUI (your buttons), and then a number of discrete flash files that hold and position the content on the main page when a specific button is clicked. All these swfs are in the same site folder.

The advantage is the loader finds each swf on its own when a button is pushed, and then - and this is the great part - loads the content and removes the previous content without you worrying about the display list in the least. Problem solved.

I have time this morning, so here's the details:

On the first frame of my actions layer, I place a line importing URLRequest functions:


Then I create a loader using a variable command:

var myLoader:Loader = new Loader();

and I create a specific URLRequest using another var command:

var ContactRequest:URLRequest=new URLRequest("contact.swf");

In this instance, the ContactRequest variable, when called, will request the Contact swf from the site folder. But this could be a request for a map page, a request for a photo gallery page, whatever.

I add this event listener to my contact button on my main page:

contact_btn.addEventListener(MouseEvent.CLICK, ContactPage, false, 0, true);

followed by the ContactPage function. The ContactPage function does a couple things. It adds the loader to x and y coordinates on the screen, and it adds the swf from my completely separate Contact swf (or map or about or photo gallery swf) to the loader.

function ContactPage(event:Event):void{
trace("Contact Info loaded onto main page.");

My Contact Page flash file (and swf) is bare bones. It consists of my contact info for my site arrayed very simply on the stage. When my loader loads it onto the main page, if it's off center, I tweak the content's x and y location within the "contact" flash file. I then republish, creating a new contact swf, and take another look on the main page preview.

So try loader and get out of the add/remove child hassle.

If anyone has any comment about this technique, I welcome it.

Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 All Rights Reserved