PDA

View Full Version : function problem


Cigan
03-20-2003, 10:09 PM
Ok I have a very odd problem. I can't for the life of me figure out why it does this. I have a function which among other things tells a movie clip to go to a specific frame. When I call the function it doesn't do this. However when I cut the part of the code which has the gotoAndStop() action in it and paste it into the frame where the custom function is called it works perfectly. I don't understand. Here is the code.

tellTarget (_root.Equipment.panel) {
gotoAndStop("armor");
}

Here is the function it was taken out of.

function populateStatPlane() {
tellTarget (_root.Equipment.panel) {
gotoAndStop("armor");
}
_root.serial1 = serial;
_root.Equipment.panel.dmg = catalog[""+serial].dmg;
_root.Equipment.panel.sr = catalog[""+serial].sr;
_root.Equipment.panel.mr = catalog[""+serial].mr;
_root.Equipment.panel.lr = catalog[""+serial].lr;
_root.Equipment.panel.clip = catalog[""+serial].clip;
_root.Equipment.panel.ref = catalog[""+serial].ref;
_root.Equipment.panel.enc = catalog[""+serial].enc;
_root.Equipment.panel.con = catalog[""+serial].con;
_root.Equipment.panel.tol = catalog[""+serial].tol;
_root.Equipment.panel.price = catalog[""+serial].price;
}


Now if I call the function populateStatPlane(); shouldn't it have this effect?

bluegel
03-21-2003, 10:14 AM
Originally posted by Cigan
Now if I call the function populateStatPlane(); shouldn't it have this effect?

how are you calling the function up??

Ricod
03-22-2003, 10:19 PM
Also, why are you using tellTarget ?

tellTarget (_root.Equipment.panel) {
gotoAndStop("armor");
}
==

_root.Equipment.panel.gotoAndStop("armor");
Is it doing any of the other things ? If not, then the function isn't called properly. (could be a path problem or syntax error)

So, could you copy / paste your function calling here ? *and mention its relation / postion with the function ?*

Mortimer Jazz
03-23-2003, 06:51 PM
Yep, there's no reason why this shouldn't work other than an incorrect function call or a clashing function name.
Infact, just to make absolutely sure I duplicated it and it works perfectly.

The simplest way to check you're actually calling the function is to put a trace inside it: trace("Ricod stole my jelly");

I have to agree, the use of tellTarget is unecessary here (it's also been depreciated in favour of 'with' for flash5 and above).

Mortimer Jazz
03-23-2003, 08:44 PM
You could also save your fingers some typing by doing this...

myClip = _root.Equipment.panel; //set path
myClip.dmg = catalog[""+serial].dmg;
myClip.sr = catalog[""+serial].sr;
myClip.mr = catalog[""+serial].mr;
etc...

(thanks to pixelwit for helping me out during one of my blonde moments!)

I thought you could use

with(_root.Equipment.panel) {
dmg = catalog[""+serial].dmg;
} but I couldn't get it to work for some reason *scratches head* seems you can't set vars using with