Log in

View Full Version : movie file resizing problem



Chokito
07-09-2007, 06:51 AM
Hi guys, need urgent help on this if there anyone out there you'd be my hero.

I basically have this code and it makes a music player resize to the canvas. I just want it to stay relative to the canvas, no resizing.

Code below......
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

_global.playerMc = this;
Stage.scaleMode = "noScale";
_pc = 0;
_pcLoaded = 0;
_isLoaded = false;
_isPlaying = false;
_buffered = false;
loadingMc._visible = false;
if (autoPlay == undefined)
{

if (playlistPath == undefined)
{
playlistPath = "playlist.xml";
} // end if
if (playerWidth == undefined)
{
playerWidth = Stage.width;
} // end if
resizePlayer = function ()
{
if (playerSkin != 5)
{
btTrack.back._width = Stage.width - 20;
progressBar.back._width = Stage.width - 20;
backProgress._width = Stage.width - 20;
loadingBar.back._width = Stage.width - 20;
}
else
{
btTrack.back._width = Stage.width;
progressBar.back._width = Stage.width;
backProgress._width = Stage.width;
loadingBar.back._width = Stage.width;
} // end else if
strokes._width = Stage.width - 1;
_stroke._width = Stage.width - 1;
_scroll._x = Stage.width - 18;
slider._x = Stage.width - 95;
_vol._x = Stage.width - 13;
credit._x = Math.floor(Stage.width / 2) - credit._width / 2;
_scrollMask._width = Stage.width - 30;
displayMask.back._width = Stage.width - 44;
displayStroke._width = Stage.width - 13;
displayBack.c._width = Stage.width - 20;
displayBack.r._x = Stage.width - 15;
time_txt._x = Stage.width - 33;
};
resizePlayer();
_currSong = 0;
_xml = new XML();
_xml.ignoreWhite = true;
_xml.onLoad = function ()
{
initFirstSong(this.firstChild);
initList();
if (_listHolder._height < _scrollMask._height)
{
_scroll._visible = false;
}
else
{
_scroll._visible = true;
} // end else if
stageListener.onResize();
};
_xml.load(playlistPath);
initFirstSong = function ()
{
_nbSongs = _xml.firstChild.childNodes.length;
title_txt._txt.autoSize = "left";
time_txt._txt.autoSize = "left";
title_txt._x = 8;
var _loc1 = _xml.firstChild.childNodes[_currSong].childNodes[0].firstChild;
var _loc2 = _xml.firstChild.childNodes[_currSong].childNodes[1].firstChild.nodeValue;
soundPath = _loc1;
title_txt._txt.autoSize = "left";
title_txt._txt.text = _loc2;
if (autoPlay == "yes")
{
getSong(_currSong);
} // end if
};
btFF.onPress = function ()
{
_snd.stop();
getNext();
};
btRW.onPress = function ()
{
_snd.stop();
getPrev();
};
getNext = function ()
{
++_currSong;
if (_currSong > _nbSongs - 1)
{
_currSong = 0;
} // end if
getSong(_currSong);
};
getPrev = function ()
{
--_currSong;
if (_currSong < 0)
{
_currSong = 0;
} // end if
getSong(_currSong);
};
getSong = function (id)
{
_snd.stop();
_currSong = id;
if (id != _current)
{
_lastMc = _current;
_current = _listHolder["bt" + id];
_lastMc._alpha = 50;
} // end if
_current._alpha = 100;
trace (_current);
title_txt._x = 8;
var _loc2 = _xml.firstChild.childNodes[_currSong].childNodes[0].firstChild;
var _loc4 = _xml.firstChild.childNodes[_currSong].childNodes[1].firstChild.nodeValue;
soundPath = _loc2;
title_txt._txt.autoSize = "left";
title_txt._txt.text = _loc4;
delete title_txt.onEnterFrame;
if (title_txt._txt.textWidth > displayMask._width - 5)
{
title_txt.cnt = 0;
title_txt.onEnterFrame = function ()
{
++this.cnt;
if (this.cnt > 120)
{
--this._x;
if (this._x < title_txt._txt.textWidth * -1)
{
this._x = displayMask._width;
} // end if
} // end if
this._x = Math.floor(this._x);
};
} // end if
loadMp3(_loc2);
displayTimeProgress();
};
displayTimeProgress = function ()
{
time_txt.onEnterFrame = function ()
{
seconds = Math.floor(_snd.position / 1000 % 60);
minutes = Math.floor(_snd.position / 1000 / 60);
if (seconds < 10)
{
seconds = "0" + seconds;
} // end if
if (minutes < 10)
{
minutes = "0" + minutes;
} // end if
this._txt.text = minutes + ":" + seconds;
};
};
songIsFinished = function ()
{
getNext();
};
initList = function ()
{
var _loc4 = 0;
var _loc5 = _xml.firstChild.childNodes.length;
for (var _loc3 = 0; _loc3 < _loc5; ++_loc3)
{
var _loc2 = _listHolder.attachMovie("btTrack", "bt" + _loc3, _loc3 + 15);
_loc2._y = _loc4;
_loc2._txt.text = _xml.firstChild.childNodes[_loc3].childNodes[1].firstChild.nodeValue;
_loc2.id = _loc3;
_loc2._alpha = 50;
_loc2.onRollOver = function ()
{
this._alpha = 100;
};
_loc2.onRollOut = function ()
{
if (this != _current)
{
this._alpha = 50;
} // end if
};
_loc2.onPress = function ()
{
getSong(this.id);
};
_loc4 = _loc4 + 16;
} // end of for
resizePlayer();
};
var mouseListener = new Object();
mouseListener.onMouseWheel = function (delta)
{
_scroll._handle._y = _scroll._handle._y - delta * 2;
if (_scroll._handle._y < 0)
{
_scroll._handle._y = 0;
} // end if
if (_scroll._handle._y > _scroll._back._height - _scroll._handle._height)
{
_scroll._handle._y = _scroll._back._height - _scroll._handle._height;
} // end if
var _loc1 = _scroll._handle._y / (_scroll._back._height - _scroll._handle._height);
_scroll.scrollList(_loc1);
};
Mouse.addListener(mouseListener);
var stageListener = new Object();
stageListener.onResize = function ()
{
credit._y = Stage.height - 18;
_stroke._height = Stage.height - 2;
_scroll.initScroll();
if (_listHolder._height < _scrollMask._height)
{
_scroll._visible = false;
}
else
{
_scroll._visible = true;
} // end else if
var _loc1 = _scroll._handle._y / (_scroll._back._height - _scroll._handle._height);
_scroll.scrollList(_loc1);
};
Stage.align = "TL";
Stage.scaleMode = "noScale";
Stage.addListener(stageListener);
if (overColor.substr(0, 1) == "#")
{
overColor = overColor.substr(1, 10);
} // end if
if (overColor == undefined)
{
overColor = "2570BA";
} // end if
if (overColor.substr(0, 2) != "0x")
{
overColor = "0x" + overColor;
} // end if
if (playerSkin == undefined)
{
playerSkin = 1;
} // end if
stop ();
gotoAndStop(playerSkin);
resizePlayer();
this.createEmptyMovieClip("loopMc", 150);
loopMc.onEnterFrame = function ()
{
resizePlayer();
if (_stroke._width == Stage.width - 1)
{
delete this.onEnterFrame;
} // end if
};
stop ();



++++++++++++++++++++++++++++++++++++++++++++++


Cheers:)

Medyman
07-09-2007, 04:19 PM
Hi Chocito...

1) If you're posting so much code, it's probably best to use the
tags
2) Your resizePlayer(); function is the code that you have to change to get what you want.

[CODE]resizePlayer = function () {
if (playerSkin != 5) {
btTrack.back._width = Stage.width - 20;
progressBar.back._width = Stage.width - 20;
backProgress._width = Stage.width - 20;
loadingBar.back._width = Stage.width - 20;
}
else {
btTrack.back._width = Stage.width;
progressBar.back._width = Stage.width;
backProgress._width = Stage.width;
loadingBar.back._width = Stage.width;
} // end else if

strokes._width = Stage.width - 1;
_stroke._width = Stage.width - 1;
_scroll._x = Stage.width - 18;
slider._x = Stage.width - 95;
_vol._x = Stage.width - 13;
credit._x = Math.floor(Stage.width / 2) - credit._width / 2;
_scrollMask._width = Stage.width - 30;
displayMask.back._width = Stage.width - 44;
displayStroke._width = Stage.width - 13;
displayBack.c._width = Stage.width - 20;
displayBack.r._x = Stage.width - 15;
time_txt._x = Stage.width - 33;
};

Bascically all the manipulations of _width and _height change the width and height of your player. If you don't want your player to resize, just take out that peice of code.

To get the position to stay relative, you'll have to use some code mapipulating the _x and _y properties.

For example, to align a movieclip in the center of the stage with the registration point in the center, you would use:


movieClip._x = Stage.width/2
movieClip._y = Stage.height/2