# OK, WHY does this not work in Flash 8?

**URL:** <https://forum.kirupa.com/t/ok-why-does-this-not-work-in-flash-8/203061>\
**Category:** Uncategorized\
**Created:** [October 7, 2006, 1:29am UTC](https://forum.kirupa.com/t/ok-why-does-this-not-work-in-flash-8/203061 "2006-10-07T01:29:36Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ciriaca](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/ciriaca/32/2869_2.png) [@Ciriaca](https://forum.kirupa.com/u/Ciriaca)\
**Post date:** [October 7, 2006, 1:29am UTC](https://forum.kirupa.com/t/ok-why-does-this-not-work-in-flash-8/203061/1 "2006-10-07T01:29:36Z")

</div>

I have a sound toggle button. Once the .swf starts, the music loop fades in and plays. Click on toggle button, it fades out and vice versa.

I have the initial code in the main scene, Frame 1. Within the toggle button, I have three frames and code for each frame to conduct the function accordingly.

**Linkage** has been activated for the sound file, **Identifier** “mysound” with both **Export for ActionScript** and **Export in first frame** selected.

The code works with Flash 6 selected in my Publish Settings, but not with **Flash 8**. I would prefer it to work with **Flash 8**.

**Main Scene, Frame 1 :**

```auto

// initiate sound
music = new Sound();
music.attachSound("mysound");
music.start(0, 999999);
// set the volume of the sound to zero
music.setVolume(0);
// set a variable named 'vol'
vol = 0;
// set another variable named 'fade', putting a setInterval function in it 
fade = setInterval(fadeIn, 100);
// set the initial fade in function
function fadeIn() {
 // fade the sound in with an increment of 3 in the variable 'vol' 
 vol += 3;
 music.setVolume(vol);
 // put an if condition to restrict the increment in volume after it reaches to 100 
 if (vol>=100) {
  clearInterval(fade);
  // create the 'step' variable 
  step = 1;
  // create the 'fade' variable 
  Fade = 0;
 }
}
// create the fade in and out function 
// function executed on onEnterFrame 
_root.onEnterFrame = function() {
 // set fade out 
 if (Fade == 1) {
  vol = vol-step;
  if (vol<0) {
   vol = 0;
  }
  music.setVolume(vol);
  // set fade in 
 } else {
  vol = vol+step;
  if (vol>100) {
   vol = 100;
  }
  music.setVolume(vol);
 }
};

```

**And in my toggle-button, I have :**

**Frame 1 :**

```auto
 
on (release) {
 // set the function for variable value toggle
 (_root.fade=!_root.fade) ? 0 : 1;
 // put an if condition to tell the playhead to goto
 // the frame from where the play control starts fading in
 // as we have pressed the button to stop the sound
 // we have already set the value of the variable s to 1
 // thus the playhead moves to frame 2 where it starts fading
 // the control play in
 if (_root.s == 1) {
  tellTarget (this) {
   gotoAndPlay(2);
   // now you aobviously have to set the variable's value
   // to 0, so that the next time you click the button
   // the playhead moves to the 46th frame where the stop
   // button starts fading in
   _root.s = 0;
  }
 } else {
  // else executes when the varianle s is equal to 0
  // when you click the button for the first time it sets the
  // value of this variable to 0
  // so the next time you click this button
  // this else block executes
  tellTarget (this) {
   gotoAndPlay(2);
   // now set the value of the var s to 1 again so that
   // the next time this button is clicked the block with
   // if condition can execute
   _root.s = 1;
  }
 }
}
 

```

**Frame 2 :**

```auto

on (release) {
 (_root.fade=!_root.fade) ? 0 : 1;
 if (_root.s == 1) {
  tellTarget (this) {
   gotoAndPlay(2);
   _root.s = 0;
   _root.pl = 1;
  }
 } else {
  tellTarget (this) {
   gotoAndPlay(3);
   _root.s = 1;
   _root.pl = 0;
  }
 }
}

```

**Frame 3 :**

```auto

on (release) {
 (_root.fade=!_root.fade) ? 0 : 1;
 if (_root.s == 1) {
  tellTarget (this) {
   gotoAndPlay(2);
   _root.s = 0;
   _root.pl = 1;
  }
 } else {
  tellTarget (this) {
   gotoAndPlay(2);
   _root.s = 1;
   _root.pl = 0;
  }
 }
}

```

Can anyone please help me get this active and compatible with **Flash 8**?
