[AS2] _lockroot not enough for loadMovie

Greetings,

using the search function i’ve found really many threads about the sound-not-playing issues involved with loadMovies methods, and some solutions as well…But they ain’t working in my case.

Architecture:

  • one Main Movieclip (mainmovie.swf);
  • one Music player (musicplayer.swf);

Music player is loaded into Main Movieclip through a loadMovie call;
absolute path to target would be _root.mp3cont (in Main Movieclip obviously);
the loadMovie call happens on the AS layer in the _root of Main Movieclip;

about the Music player:

  • there’s a movieclip on the main timeline that acts as container. Name is “sound_clips”;
  • the music player is INSIDE the mc “sound_clips”;
  • music player works with attachSound;

This is the code on the AS layer:


import gs.*;
import gs.easing.*;

OverwriteManager.init

TweenMax.to(btn_play, 0.5, {_alpha:50, ease:Strong.easeOut});

// Setup sound object
var s:Sound = new Sound();
s.setVolume(0);

var sa:Array = new Array("loop01", "loop02", "loop03");

// Currently playing song
var cps:Number = -1;

// Position of music
var pos:Number;

function souStop():Void {
    s.stop();
    this._parent.playSong();
}

function playSong():Void {
   s = new Sound();
   s.setVolume(0);
   if(cps == sa.length - 1) {
      cps = 0;
      s.attachSound(sa[cps])
      s.start(0, 99);
      } else {
      s.attachSound(sa[++cps])
      s.start(0, 99);
   }
   TweenMax.to(s, 0.5, {volume:75, ease:Regular.easeOut});
}

function playBack():Void {
    s = new Sound();
    s.setVolume(0);
    if(cps == sa.length - 3) {
      cps = 2;
      s.attachSound(sa[cps])
      s.start(0, 99);
      } else {
      s.attachSound(sa[--cps])
      s.start(0, 99);
    }
    TweenMax.to(s, 0.5, {volume:75, ease:Regular.easeOut});
}

playSong();

// Pauses the music
function pauseIt():Void {
   pos = s.position/1000;
   s.stop();
   }

// unPauses the music
function unPauseIt():Void {
   s.start(pos, 0);
   }

btn_fw.onRollOver = function() {
    TweenMax.to(btn_fw, 0.4, {colorMatrixFilter:{colorize:0xff0066, amount:0.6, contrast:3, brightness:1, saturation:1}});
}

btn_fw.onRollOut = function() {
    TweenMax.to(btn_fw, 0.4, {colorMatrixFilter:{colorize:0xff0066, amount:0, contrast:3, brightness:1, saturation:1}});
}

btn_fw.onRelease = function() {
    s.stop();
    this._parent.playSong();
    if (btn_mute._currentframe != "lauda"){
       btn_mute.gotoAndStop("lauda");
       }
    if (btn_play._alpha != 50) {
        TweenMax.to(btn_pause, 0.5, {_alpha:100, ease:Strong.easeOut});
        TweenMax.to(btn_play, 0.5, {_alpha:50, ease:Strong.easeOut});
        }
   }

btn_back.onRollOver = function() {
    TweenMax.to(btn_back, 0.4, {colorMatrixFilter:{colorize:0x0033ff, amount:0.6, contrast:3, brightness:1, saturation:1}});
}

btn_back.onRollOut = function() {
    TweenMax.to(btn_back, 0.4, {colorMatrixFilter:{colorize:0x0033ff, amount:0, contrast:3, brightness:1, saturation:1}});
}


btn_back.onRelease = function() {
    s.stop();
    this._parent.playBack();
    if (btn_mute._currentframe != "lauda"){
       btn_mute.gotoAndStop("lauda");
       }
    if (btn_play._alpha != 50) {
        TweenMax.to(btn_pause, 0.5, {_alpha:100, ease:Strong.easeOut});
        TweenMax.to(btn_play, 0.5, {_alpha:50, ease:Strong.easeOut});
        }
   }

btn_pause.onRollOver = function() {
    if (btn_pause._alpha == 100) {
        TweenMax.to(btn_pause, 0.4, {colorMatrixFilter:{colorize:0x33ff00, amount:0.6, contrast:3, brightness:1, saturation:1}});
        }
    }
    
btn_pause.onRollOut = function() {
    if (btn_pause._alpha == 100) {
        TweenMax.to(btn_pause, 0.4, {colorMatrixFilter:{colorize:0x33ff00, amount:0, contrast:3, brightness:1, saturation:1}});
        }
    }

btn_pause.onRelease = function() {
    if (btn_pause._alpha == 100) {
           TweenMax.to(btn_pause, 0.5, {_alpha:50, ease:Strong.easeOut});
        TweenMax.to(btn_play, 0.5, {_alpha:100, ease:Strong.easeOut});
        TweenMax.to(btn_pause, 0.4, {colorMatrixFilter:{colorize:0xffff00, amount:0, contrast:3, brightness:1, saturation:1}});
        pauseIt();
    }
}

btn_play.onRollOver = function() {
    if (btn_play._alpha == 100) {
        TweenMax.to(btn_play, 0.4, {colorMatrixFilter:{colorize:0xffff00, amount:0.6, contrast:3, brightness:1, saturation:1}});
        }
    }
    
btn_play.onRollOut = function() {
    if (btn_play._alpha == 100) {
        TweenMax.to(btn_play, 0.4, {colorMatrixFilter:{colorize:0xffff00, amount:0, contrast:3, brightness:1, saturation:1}});
        }
    }

btn_play.onRelease = function() {
    if (btn_play._alpha == 100) {
        TweenMax.to(btn_pause, 0.5, {_alpha:100, ease:Strong.easeOut});
        TweenMax.to(btn_play, 0.5, {_alpha:50, ease:Strong.easeOut});
        TweenMax.to(btn_play, 0.4, {colorMatrixFilter:{colorize:0xff0066, amount:0, contrast:3, brightness:1, saturation:1}});
        unPauseIt();
        s.onSoundComplete = function(){
            s.start(0, 99);
            }
        }
    }

btn_mute.onRollOver = function() {
        TweenMax.to(btn_mute, 0.4, {colorMatrixFilter:{colorize:0x9900ff, amount:0.6, contrast:3, brightness:1, saturation:1}});
        }
    
btn_mute.onRollOut = function() {
        TweenMax.to(btn_mute, 0.4, {colorMatrixFilter:{colorize:0x9900ff, amount:0, contrast:3, brightness:1, saturation:1}});
        }

btn_mute.onRelease = function() {
    btn_mute.nextFrame();
}

As you see there are a Back,Pause,Play,Next and Mute buttons.

There’s also a volume slider. Here goes the code (placed on the slider itself, NOT inside it):


onClipEvent(load) {
    import gs.*;
    import gs.easing.*;
    OverwriteManager.init
    this._x=_parent.hbase._x + _parent.hbase._width/2 - ((this._width/2)-7);
    // left=this._x - _parent.hbase._width/2;
    left=0;
    top=this._y;
    // right=this._x + _parent.hbase._width/2;
    right=84;
    bottom=this._y;
    volCalc=_parent.hslider._x - _parent.hbase._width/2
//
//End of Clip Event Load
}
onClipEvent(enterFrame) {
    this.onPress = function () {
        startDrag(this, false, left , top , right, bottom)
        }
    this.onRollOver = function(){
        TweenMax.to(_parent.hslider.slidebubble, 0.5, {_alpha:100, ease:Strong.easeOut});
        TweenMax.to(_parent.hslider.slidebubble, 0.5, {glowFilter:{color:0xffffcc, alpha:1, blurX:10, blurY:10, strength:2, quality:3, delay:0.5}});
        }
    this.onRelease = function () {
        this.stopDrag();
        }
    this.onReleaseOutside = function() {
        this.stopDrag();
    }
    this.onRollOut = function(){
        TweenMax.to(_parent.hslider.slidebubble, 0.5, {_alpha:0, ease:Strong.easeOut});
        TweenMax.to(_parent.hslider.slidebubble, 0.5, {glowFilter:{color:0xffffcc, alpha:0, strength:3, blurX:10, blurY:10, strength:2, quality:3, delay:0.5}});
    }
// This constantly sets the current a-axis position of
//the slider to "sliderx
    sliderx=_parent.hslider._x; //Sets sliderx as variable for a-axis of slider
    myMusicVolume=((sliderx-volCalc)*1.2); //The value of x-axis load value - n = 50
    _parent.s.setVolume(myMusicVolume);
    _parent.hslider.slidebubble.currentVolume = _parent.s.getVolume();
    if (myMusicVolume != "0") {
        _parent.btn_mute.gotoAndStop("lauda");
    } else {
        _parent.btn_mute.gotoAndStop("mute");
    }
    }

Needless to say, the musicplayer works perfectly…I even opened a thread 2 weeks ago for coding it, should be on page 3 of this forum, i even posted the final code in order to “help” others…

But now…

  1. I tried to insert
this._lockroot = true;

on the FIRST FRAME of the Music player root, that has, as said before, a movieclip named “sound_clips” that contains actually the music player (AS + slider AS); - Didn’t work.

  1. I tried to insert
mp3cont._lockroot = true;

on the FIRST FRAME of the Main Movieclip root, where i have mp3cont as container mc for that swf that is load through a loadMovie(“musicplayer.swf”, “mp3cont”); call. Didn’t work either.

  1. I created a new file (a blank .fla) with just the loadMovie call and the mp3cont._lockroot = true; (obviously on separated layers) method to see if it actually worked. Didn’t work.

Where could the problem be? Is the way i’m using to load sounds in the musicplayer a bit odd or either incorrect? Shall i remove that sound_clip movieclip container and place all the scripts and things directly in the root of musicplayer.swf?

Oh btw thanks for having read this huge wall of text :slight_smile: