A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Loading External SWF Problems

  1. #1
    Junior Member
    Join Date
    May 2007
    Posts
    4

    Loading External SWF Problems

    Hi. I'm working on my first website in Flash, and I'm running into a bit of a problem early on. I've created my own MP3 player in flash in a separate file called musicplayer.fla. It works fine when I test the movie independently. However, when I set it up to load into my index.fla file the volume slider gets quirky. Instead of moving volume from 100% to 0% across 100 px (like it did inside the musicplayer file) it now moves from 100% to 0% (around where it should be 30%) then the volume goes back up as you approach what should be a volume of 0%.

    I've uploaded the two swf on my site.
    www.controversemedia.com/epk/index.html
    www.controversemedia.com/epk/musicplayer.html

    Here's the actionscript I used for the music player:
    //Setup sound object
    var musiclist:Sound = new Sound(this);
    musiclist.onSoundComplete = playSong;
    musiclist.setVolume(100)

    // Array of songs
    var sa:Array = new Array();

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

    //Position of Music
    var pos:Number;

    //Load the songs XML
    var xml:XML = new XML();
    xml.ignoreWhite = true;
    xml.onLoad = function()
    {
    var nodes:Array = this.firstChild.childNodes;
    for(var i=0;i<nodes.length;i++)
    {
    sa.push(new Song(nodes[i].attributes.url, nodes[i].attributes.artist, nodes[i].attributes.track));
    }
    playSong();
    }

    xml.load("songs.xml");

    //Volume Slider
    slidervol.onRollOver = function()
    {
    this.gotoAndStop("volpush");
    }

    slidervol.onRollOut = next.onReleaseOutside = function()
    {
    this.gotoAndStop("volrel");
    }
    slidervol.onPress = function()
    {
    this.startDrag(true, barvol._x, barvol._y, barvol._x+100, barvol._y);
    }
    slidervol.onRelease = slidervol.onReleaseOutside = function()
    {
    this.stopDrag();
    }
    slidervol.onMouseMove = function()
    {
    newPoint = new Object();
    newPoint.x = this._x;
    newPoint.y = this._y;
    barvol.globalToLocal(newPoint);
    musiclist.setVolume(-1*newPoint.x);
    }


    // Play the MP3 file
    function playSong():Void
    {
    musiclist = new Sound(this);
    musiclist.onSoundComplete = playSong;
    musiclist.setVolume(100);
    if(cps == sa.length -1)
    {
    cps = 0;
    musiclist.loadSound(sa[cps].earl, true);
    }
    else
    {
    musiclist.loadSound(sa[++cps].earl, true);
    }
    textMC.textMC2.trackInfo.text = sa[cps].artist + " - " + sa[cps].track;
    playPause.gotoAndStop("pause");
    }

    //Pauses the Music
    function pauseIt():Void
    {
    pos = musiclist.position;
    musiclist.stop();
    }

    function unPauseIt():Void
    {
    musiclist.start(pos/1000);
    }

    //Music Controls

    //Play/Pause Toggle
    playPause.onRollOver = function()
    {
    if(this._currentframe == 1) this.gotoAndStop("pauseOver");
    else this.gotoAndStop("playOver")
    }

    playPause.onRollOut = playPause.onReleaseOutside = function ()
    {
    if(this._currentframe == 10) this.gotoAndStop("pause");
    else this.gotoAndStop("play")
    }

    playPause.onRelease = function()
    {
    if(this._currentframe == 10)
    {
    this.gotoAndStop("playOver");
    this._parent.pauseIt();
    }
    else
    {
    this.gotoAndStop("pauseOver");
    this._parent.unPauseIt();
    }
    }

    //Next Button
    next.onRollOver = function()
    {
    this.gotoAndStop("nextOver");
    }

    next.onRollOut = next.onReleaseOutside = function()
    {
    this.gotoAndStop("next");
    }

    next.onRelease = function()
    {
    this._parent.playSong();
    }

  2. #2
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    Are you using a movieclip to load your external movie, if so use _lockroot:

    mc._lockroot = true;
    mc.loadMovie("mymovie.swf");
    - The right of the People to create Flash movies shall not be infringed. -

  3. #3
    Junior Member
    Join Date
    May 2007
    Posts
    11
    I had no problems with the volume slider.
    PM me for some tips on making the buttons look a little better.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center