Skip to main content
December 3, 2013
Answered

Cache on Timeline?

  • December 3, 2013
  • 1 reply
  • 796 views

Recently I created a function on a swf that basically hides some buttons until the audio playing on that frame is over. When this happen a function is called and the buttons became visible again.

The code is very simple. It's like this:

var my_sound:Sound = new Sound();

my_sound.loadSound("audio/som1_1.mp3",true);

my_sound.onLoad = function(sucess:Boolean){

    if( ( _root.temporizador == 1 || _root.temporizador == undefined ) && sucess ) {

        botao_avancar._alpha = 0;

        botao_avancar.enabled = false;

        my_sound.onSoundComplete = doSoundComplete;

    }

}

function doSoundComplete() {

    botao_avancar._alpha = 100;

    botao_avancar.enabled = true;

}

My problem is, whenever I change the frame, and the button is in a different place on the screen, it appears on the same position as the last frame, kind of a cache, I guess. Someone know a way to fix this? It's really weird.

I have a .fla sample of this in the link: http://ouromoderno.com.br/flashError/demo.fla
And I have an online sample, so you can see what happens: -> http://ouromoderno.com.br/flashError/

Appreciate any ideias.

(Sorry for the very bad horrible awful english )

This topic has been closed for replies.
Correct answer kglad

when your button appears in a new place you have a keyframe containing the button and therefore another button instance.  making a previous button instance not visibiel won't affect the visible property of the new button instance.

to remedy, use a boolean variable to record whether your button is visible or not.  use the boolean in other frames to assign the new instances visible property:

my_sound.onLoad = function(sucess:Boolean){

    if( ( _root.temporizador == 1 || _root.temporizador == undefined ) && sucess ) {

        botao_avancar._visible=false;

botao_visible=false;

        my_sound.onSoundComplete = doSoundComplete;

    }

}

function doSoundComplete() {

    botao_avancar._visible=true;

botao_visible=true;

}

// on your other frames:

whateverbotao._visible=botao_visible;

//p.s. use the _visible property and you don't have enable/disable your button.

1 reply

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
December 3, 2013

when your button appears in a new place you have a keyframe containing the button and therefore another button instance.  making a previous button instance not visibiel won't affect the visible property of the new button instance.

to remedy, use a boolean variable to record whether your button is visible or not.  use the boolean in other frames to assign the new instances visible property:

my_sound.onLoad = function(sucess:Boolean){

    if( ( _root.temporizador == 1 || _root.temporizador == undefined ) && sucess ) {

        botao_avancar._visible=false;

botao_visible=false;

        my_sound.onSoundComplete = doSoundComplete;

    }

}

function doSoundComplete() {

    botao_avancar._visible=true;

botao_visible=true;

}

// on your other frames:

whateverbotao._visible=botao_visible;

//p.s. use the _visible property and you don't have enable/disable your button.

December 3, 2013

Thanks for the reply. I didnt know about the _visible property, thanks!
About my doubt, I am thinking on doing something like that:

I will create an array of booleans and set everything to false in the begining. Everytime I call doSoundComplete it will set that frame to true. In essence, this is what you told me to do right?

kglad
Community Expert
Community Expert
December 3, 2013

how many buttons do you need to track?