Log in

View Full Version : Actionscript Help



Mark__G
06-19-2008, 07:39 PM
I just need help with the following code. I am trying to figure out how to move the "mc" instance to either be loaded in an empty movieclip at the exact coordinates i need it to be, or somehow give it a x and why coordinate setting to load the xml data and images.



function init()
{
if (xPath == undefined)
{
xPath = "slides.xml";
} // end if
if (fadeDur == undefined)
{
fadeDur = 1.600000E+000;
} // end if
if (slideDur == undefined)
{
slideDur = 6;
} // end if
if (wipeDur == undefined)
{
wipeDur = 1.500000E+000;
} // end if
timeOutInterval = slideDur * 1000;
msk._alpha = 0;
msk.swapDepths(100);
infoBar.swapDepths(200);
clips = [mc1, mc2];
lastClip = mc2;
currentClip = mc1;
mcl = new MovieClipLoader();
mcl.addListener(this);
loadXML();
} // End of the function
function loadXML()
{
var alias = this;
var _loc2 = new XML();
_loc2.ignoreWhite = true;
_loc2.onLoad = function (bool)
{
if (bool)
{
alias.onXMLLoaded(this);
}
else
{
trace ("error loading xml");
} // end else if
};
_loc2.load(xPath);
} // End of the function
function onXMLLoaded(_xml)
{
var _loc3 = _xml.firstChild.childNodes;
var _loc5 = _xml.firstChild;
if (_loc5.attributes.fadeDur != undefined)
{
fadeDur = Number(_loc5.attributes.fadeDur);
trace ("fadeDur = " + fadeDur);
} // end if
if (_loc5.attributes.slideDur != undefined)
{
slideDur = Number(_loc5.attributes.slideDur);
trace ("slideDur = " + slideDur);
timeOutInterval = slideDur * 1000;
trace ("timeOutInterval = " + timeOutInterval);
} // end if
if (_loc5.attributes.wipeDur != undefined)
{
wipeDur = Number(_loc5.attributes.wipeDur);
trace ("wipeDur = " + wipeDur);
} // end if
var _loc4 = _loc3.length;
pathData = new Array();
for (var _loc2 = 0; _loc2 < _loc4; ++_loc2)
{
var _loc1 = {};
_loc1.caption = _loc3[_loc2].childNodes[0].firstChild.nodeValue;
_loc1.path = _loc3[_loc2].childNodes[1].firstChild.nodeValue;
_loc1.foreColor = Number(_loc3[_loc2].childNodes[2].firstChild.nodeValue);
if (_loc1.foreColor == undefined || isNaN(_loc1.foreColor))
{
_loc1.foreColor = 16777215;
} // end if
pathData.push(_loc1);
} // end of for
loadClipNum(0);
} // End of the function
function loadNextClip()
{
clearInterval(intervalID);
if (_xmouse > 10 && _ymouse > 10 && _xmouse < targWidth - 10 && _ymouse < targHeight - 10)
{
intervalID = setInterval(this, "loadNextClip", timeOutInterval);
}
else
{
loadClipNum(clipIndex + 1);
} // end else if
} // End of the function
function loadClipNum(index)
{
clearInterval(intervalID);
msk._width = 1;
msk._x = targWidth;
clipIndex = index;
clipIndex = clipIndex % pathData.length;
mcl.loadClip(pathData[clipIndex].path, lastClip);
} // End of the function
function onFrameSelected(index)
{
loadClipNum(index);
} // End of the function
function onLoadStart(mc)
{
mc._visible = false;
if (mc.getDepth() < currentClip.getDepth())
{
mc.swapDepths(currentClip);
} // end if
lastClip = currentClip;
currentClip = mc;
} // End of the function
function onLoadInit(mc)
{
if (isFirstLoad)
{
load_mc.unloadMovie();
logo_mc.unloadMovie();
} // end if
mc._alpha = 0;
mc._width = targWidth;
mc._height = targHeight;
mc._visible = true;
mc.setMask(msk);
var _loc3 = new mx.transitions.Tween(msk, "_x", mx.transitions.easing.Strong.easeOut, targWidth, 0, wipeDur, true);
var _loc5 = new mx.transitions.Tween(msk, "_width", mx.transitions.easing.Strong.easeOut, 1, targWidth, wipeDur, true);
var _loc4 = new mx.transitions.Tween(mc, "_alpha", mx.transitions.easing.None.easeIn, 0, 100, fadeDur, true);
hideControls();
_loc3.addListener(this);
} // End of the function
function hideControls()
{
infoBar.onRollOver = function ()
{
};
var _loc1 = new mx.transitions.Tween(infoBar, "_y", mx.transitions.easing.Regular.easeOut, targHeight - 20, targHeight, 2.500000E-001, true);
} // End of the function
function showControls()
{
delete infoBar.onRollOver;
var _loc1 = new mx.transitions.Tween(infoBar, "_y", mx.transitions.easing.Regular.easeIn, targHeight, targHeight - 20, 2.500000E-001, true);
} // End of the function
function onMotionFinished()
{
var _loc2 = pathData[clipIndex];
currentClip.setMask(null);
infoBar.slideNav.setColor(_loc2.foreColor);
infoBar.slideNav.selectItem(clipIndex);
infoBar.label_mc.setText(_loc2.caption, _loc2.foreColor);
intervalID = setInterval(this, "loadNextClip", timeOutInterval);
showControls();
} // End of the function
var pathData;
var mc1 = createEmptyMovieClip("mc1", 1);
var mc2 = createEmptyMovieClip("mc2", 2);
var clips;
var msk;
var clipIndex = -1;
var mcl;
var lastClip;
var currentClip;
var infoBar;
var label_mc;
var slideNav;
var xPath;
var targWidth = 780;
var targHeight = 250;
var intervalID = -1;
var fadeDur;
var slideDur;
var wipeDur;
var timeOutInterval;
init();
var isFirstLoad = true;

Medyman
06-23-2008, 05:06 AM
Hey Mark,

Even though I don't condone the decompiling of others' code, I will answer your question (partially).

If you want to create an empty movie clip to load your data, simply use the createEmptyMovieClip() method (http://livedocs.adobe.com/flash/8/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00002447.html).

You can set the coordinates of any movieclip by manipulating it's _x and _y properties.

By the way, that code you're using is fairly bloated and inefficient. If you want to learn how to do things yourself, feel free to post back. I'll gladly walk you through it.

Mark__G
06-23-2008, 04:55 PM
I would love a walk through if it's not to much trouble...

Medyman
06-23-2008, 06:04 PM
Sure thing. Can you explain what exactly you're trying to accomplish?