Topic: disable button on active SVmovie

Hi,

I am finishing my SV 1.9 integration in my Flash as2 website. I have embedded it in Flash, like the example given in the software I bought.

One thing. I would like to disable the button1 that loaded the active gallery1. So that it (button1) is not selectable while viewing gallery1, and reloading is not possible.

To do so I add a function to the onrelease code: button1.enabled = false, so it disables itself after the loadGallery(1) is executed. Works fine. Switching to gallery2 requires the 'disabled' button1 to be enabled and the new button2 to be disabled. Now I thought enabling any button could be done with adding the following code to every button:

Button.prototype.enabled = true;

But that does not work. I thought that maybe the code was misplaced, so I tried changing it to

Button.prototype.enabled = false;, which DOES immediately disable all buttons

Can this prototype never be "true" (and should always be false?) or am I missing something.

I use the following code, (fat code is what I have added to the standard SV code):

----------------------------------------------------------------------
Stage.align = "TL";
Stage.scaleMode = "noScale";

_global.SVStageWidth = 860;
_global.SVStageHeight = 590;

var galleryId:Number;
var mLoader_mcl = new MovieClipLoader();
mLoader_mcl.addListener(this);

bt_gallery1.onRelease = function(){
    loadGallery(1);
    Button.prototype.enabled = true;
    bt_gallery1.enabled = false;

}

bt_gallery2.onRelease = function(){
    loadGallery(2);
    Button.prototype.enabled = true;
    bt_gallery2.enabled = false;

}

function loadGallery(galId){
    galleryId = galId
    mLoader_mcl.loadClip("viewer.swf",mc_svloader);
}

function onLoadInit(){
    _root.xmlDataPath = "gallery"+galleryId + ".xml";
}

loadGallery(1);
bt_gallery1.enabled = false;
----------------------------------------------------------------------

Hope someone can help me out,
Cheers, Pete

Re: disable button on active SVmovie

Have you tried setting bt_gallery1.enabled or bt_gallery2.enabled  to true instead?

Mike Richards
SimpleViewer Support Team.

Re: disable button on active SVmovie

Yes, that works. The option is to include all the other buttons (and enabling them) in the onrelease. The first example is two buttons only, I would like to add many more and regularly updating them. It would be much easier to use a general term as the prototype code. But if that does not work I stick to this solution which also does the trick:

----------------------------------------------------------------------
Stage.align = "TL";
Stage.scaleMode = "noScale";

_global.SVStageWidth = 860;
_global.SVStageHeight = 590;

var galleryId:Number;
var mLoader_mcl = new MovieClipLoader();
mLoader_mcl.addListener(this);

bt_gallery1.onRelease = function(){
    loadGallery(1);
    bt_gallery1.enabled = false;
    bt_gallery2.enabled = true;
    bt_gallery3.enabled = true;
    bt_project.enabled = true;
    bt_experiment.enabled = true;

}

bt_gallery2.onRelease = function(){
    loadGallery(2);
    bt_gallery1.enabled = true;
    bt_gallery2.enabled = false;
    bt_gallery3.enabled = true;
    bt_project.enabled = true;
    bt_experiment.enabled = true;

}

bt_gallery3.onRelease = function(){
    loadGallery(3);
    bt_gallery1.enabled = true;
    bt_gallery2.enabled = true;
    bt_gallery3.enabled = false;
    bt_project.enabled = true;
    bt_experiment.enabled = true;

}

bt_project.onRelease = function(){
    loadGallery(4);
    bt_gallery1.enabled = true;
    bt_gallery2.enabled = true;
    bt_gallery3.enabled = true;
    bt_project.enabled = false;
    bt_experiment.enabled = true;

}

bt_experiment.onRelease = function(){
    loadGallery(5);
    bt_gallery1.enabled = true;
    bt_gallery2.enabled = true;
    bt_gallery3.enabled = true;
    bt_project.enabled = true;
    bt_experiment.enabled = false;

}

function loadGallery(galId){
    galleryId = galId
    mLoader_mcl.loadClip("viewer.swf",mc_svloader);
}

function onLoadInit(){
    _root.xmlDataPath = "gallery"+galleryId + ".xml";
}

loadGallery(1);
bt_gallery1.enabled = false;
----------------------------------------------------------------------

I am happy with this, but still would like to know why the prototype script does not work. If someone here does not know, I'll post this question in a general Flash forum.

Thanks for your reaction. Pete

Re: disable button on active SVmovie

Are your buttons buttons or movie clips? I believe Button.prototype.enabled will only work on buttons, if you are working off the included example it uses movie clips as buttons.

You could make one function that enables all of the buttons and just call that when you want to enable the buttons.

function enableButtons(){
    bt_gallery1.enabled = true;
    bt_gallery2.enabled = true;
    bt_gallery3.enabled = true;
    bt_project.enabled = true;
    bt_experiment.enabled = true;
}

bt_gallery1.onRelease = function(){
    loadGallery(1);
    enableButtons();
    bt_gallery1.enabled = false;
}

etc.

Mike Richards
SimpleViewer Support Team.

Re: disable button on active SVmovie

I use buttons, not mc, so the prototype function should work. Still don't know why it does not...

But your solution is the best alternative so far. I'll stick to it. Many thanks.