Search  
Search Options

CLEARING A FUNCTION?

HomeForumsFlash Discussionclearing a function?
35024 lifwanian
164 posts
Exclusive author Sold between 100 and 1 000 dollars

Hey guys. I have a scrollbar for a movie clip (the full site) that appears and resizes according to the height of the mc and stage height.

I have it set to where if the height of the mc is smaller than the stage height, then center the mc on the x and y axis… So its centered on the stage… But if the stage.height is smaller than the mc height, the scroll bar appears, and the mc_y is set to 0.

Everything so far works great, but if I start the site normally (stage.height > mc._height), then resize the browser so stage.height is smaller (the scrollbar appears), and then resize again to its normal position (stage.height > mc._height, no scrollbar), the scrollbar function still exists, and I can still scroll up and down with the click wheel and mc._y is set to 0… instead of stage.height/2….

Heres my function…

sizeListe = new Object(); sizeListe.onResize = initStage; function initStage() { //center the container on the stage if (Stage.height>=680) { site_mc._x = Stage.width/2; site_mc._y = (Stage.height/2)-352.6; scroller_mc._visible = false; } else { var w = Stage.width; var h = Stage.height; site_mc.init(20); site_mc._y = 0; site_mc._x = Stage.width/2; scroller_mc._x = w; scroller_mc._y = 0; scroller_mc.updateScroll(site_mc._height+70); } } //init the stageListe Stage.addListener(sizeListe); initStage();

this obviously does not work, because the scroll is still active from before, but I just wanted to know how I can fix this… Do I somehow clear the function?

Thanks! Justin

Posted about 1 month ago
12794 coupdegrace
63 posts
Referred at least one person Sold between 100 and 1 000 dollars

Try adding an ‘if’ statement within your ‘else’ to make it more strict.

function initStage() { 
    //center the container on the stage 

    var w = Stage.width;
    var h = Stage.height; 

    if (h > 680) { 
        site_mc._x = w / 2; 
        site_mc._y = (h / 2) - 352.6; 
        scroller_mc._visible = false; 
    }     else { 
        if (h < 680){
        site_mc.init(20); 
        site_mc._y = 0; 
        site_mc._x = w / 2; 
        scroller_mc._x = w; 
        scroller_mc._y = 0; 
        scroller_mc.updateScroll(site_mc._height + 70); 
        }
    }
}

This may not work, but it’s just a generalization.

Posted about 1 month ago
35024 lifwanian
164 posts
Exclusive author Sold between 100 and 1 000 dollars

thanks for the help, but unfortunately this still does not work… The site_mc._y is still at 0, and I can still scroll up and down, much more than I need to…

I wonder what could be causing this….

Also, how did you write all that code so neatly? When I pasted it, it looked just like yours, but came out all munched together…

Posted about 1 month ago
Default-profile bhad
15 posts
Sold between 1 and 100 dollars

Inside “if (h < 680)” you’ll need to delete the listener (I assume that’s how you’re listening for mousewheel scroll) using “delete listenerName;”. Then add the listener back when the scrollbar appears again.

Posted about 1 month ago