PDA

View Full Version : attachMovie function


radioxromance
03-05-2004, 06:49 AM
I have a function I made which is not seeming to load correctly. I am very new with AS. Here is what I am trying to do:

set some variables that are used in a attachMovie function. here it is:


/* declare character stats. This sets already set variables to some generic variables to be used with attachMovie. I use a different depth for each declaration of generic variables.*/

_root.statsName = "charStatsMC";
_root.objName = _root.playerName;
_root.objHP = _root.HP;
_root.objMP = _root.MP;
_root.setObjX = setCharX;
_root.setObjY = setCharY;
_root.statsDepth = 70;
displayStats();

/*then it uses the code in the displayStats function...*/
//display stats function()
displayStats = function () {
thisStatsDepth = _root.statsDepth;
statsNameMC = _root.statsName;
objX = _root.setObjX+100;
objY = _root.setObjY-100;
_root.attachMovie("stats_mc", statsNameMC, thisStatsDepth);
statsNameMC._x = objX;
statsNameMC._y = objY;
statsNameMC._width = 150;
statsNameMC._height = 100;
};
I have traced this, but can't figure out the problem. Tracing reveals that objX (and objY) are working fine, as is statsNameMC, but statsNameMC._x (and ._y) are giving me nothing, along with the width and height. Why? I can't figure this out! Any help, greatly appreciated. And forgive any newbie mistakes!

also did I format that code right? it's not displaying any differently in my browser...

divarch
03-05-2004, 07:59 AM
Well, since you attached it to the root, it would be '_root.statsNameMC._x' and so on.
Try that, if it doesn't work, try to set attached movie's properties with init object... Is it FMX or later you are using?

Welcome to the forums

radioxromance
03-05-2004, 12:55 PM
thank you for the quick reply. But... I don't know what init is. I tried searching the forums, and actually found a post last night that used it in the code and was going to study it, try to jsut pick it apart, but now I can't find it. Do you know of something that can explain it, or would you explain it? Like I said I am VERY new to AS, I just found out how to attachMovie yesterday and am basically just fooling around trying to get things to work, and finding out why...
Whoa guess that's a bit long...
but yes, I am using flash MX.
thanks again!

radioxromance
03-05-2004, 06:29 PM
oh forgot to tell you that the _root. fix didn't work, which is why I asked about the init. But I'm looking into it now, shouldn't be long before I can find something about this!

radioxromance
03-07-2004, 02:50 AM
okay I figured out the initObject in attachMovie, it was so very easy, why did it take me so long to find it... had to look at macromedia.com, that place is also very helpful. But thanks for setting my on the right track, init is MUCH easier and works well!