flash q
- Started
- Last post
- 17 Responses
- method_c
can i call a function in a mc...
_root.but1.onRollOver = function() {
endX = 57;
};like that? or is the _root part wrong?
- ozhanlion0
yeah
on(rollOver) {
endX = 57;
}no ?
- method_c0
i dont think thats right ozhanlion
- ozhanlion0
what are you trying to achieve, invoke onRollOver from inside of an another movieclip ?
- method_c0
this script is put on an object inside a movie clip, and the buttons are also in the same movie clip. I had in working in the main stage but it won't work with the same script in a movie clip, so thats why i think the _root has to go? ... but without it aint working either
- ozhanlion0
first to first, you cannot put function literals on movieclips.
You can only put onClipEvents to mcs and button events to buttons. But it is not a good style of coding. put all of your code to frames and it is better to use function literals for memory, but there are some things to watch about the scope.
So about your problem;I can understand that but1 is a mc right ? So buttons are inside the but1 mc with the mc you are trying to put the script right ?
well put this script on the timeline where your buttons reside.
_root.but1.onRollOver = function() {
endX = 57
}hth
come back if you have more problems.
- method_c0
no this code is put on an ocject that has to move right... like this:
onClipEvent (load) {
_y = 1;
div = 5;
endX = 57;
}
onClipEvent (enterFrame) {
_x += (endX-_x)/div;
_root.but1.onRollOver = function() {
endX = 57;
};
_root.but2. ...... etc
etc...
..
..6 buttons in total.
so the buttons are all in the same mc as the object, in different layers
- ozhanlion0
oh man delete those actiosn on the object and the buttons whatever and put this on the frame that your buttons reside.
maybe it can help
obje._y = 1;
function mover(endX, div) {
obje.onEnterFrame = function() {
if (this._x>=endX) {
delete this.onEnterFrame;
}
this._x += (endX-_x)/div;
};
}
but1.onRollOver = function() {
mover(100, 11);
};
but2.onRollOver = function() {
mover(149, 10);
};if it doesn't we can fix it when I go to home. it is 7 pm right here and my head is burning..
- ozhanlion0
assuming you give your moving object instance name of obje
- method_c0
It aint working like that ozhanlion. and i'm afraid thats not what i wanna do (place script in a keyframe) i need some motion tweens in this mc so the script has to be on the objects 'mself. The script im using worked in the main scene but it doesn't in the mc, when i place the mc in the main scene and i delete the "obje"(that thing that has to move) from the main scene, but i keep the buttons that are in the main scene, these buttons use the "obje" from the mc but when i delete the buttons from the main scene and i try it with the "obje" and the buttons from the mc, it doesnt work so something has to change in the script.... it has to work.
- method_c0
onClipEvent (load) {
_y = 1;
div = 5;
endX = 57;
}
onClipEvent (enterFrame) {
_x += (endX_x)/div;_root.but1.onRollOver = function() {
endX = 57;
};
_root.but2.onRollOver = function() {
endX = 167;
};
_root.but3.onRollOver = function() {
endX = 273;
};
_root.but4.onRollOver = function() {
endX = 385;
};
_root.but5.onRollOver = function() {
endX = 491;
};
_root.but6.onRollOver = function() {
endX = 601;
};
}the script that im using in the mc, same script as i was using in the main scene
- ozhanlion0
ya you have absolute adressing on the buttons.
onClipEvent (load) {
_y = 1;
div = 5;
endX = 57;
}
onClipEvent (enterFrame) {
_x += (endX_x)/div;_root.mc.but1.onRollOver = function() {
endX = 57;
};
_root.mc.but2.onRollOver = function() {
endX = 167;
};
_root.mc._root.but3.onRollOver = function() {
endX = 273;
};
_root.mc.but4.onRollOver = function() {
endX = 385;
};
_root.mc.but5.onRollOver = function() {
endX = 491;
};
_root.mc.but6.onRollOver = function() {
endX = 601;
};
}see the point, change the instance name of your mc to mc or whatever
- ozhanlion0
there is two addressing style in flash. one is absolute. one is relative.
if you are using absolute addressing you gotta figure out whole mcs as a tree branch starting from _root. _root is your maintimeline. so if you have an mc in _root then you will address it like _root.mc. If you are calling this mc from a two depth inside mc you can still call it like _root.mc. The point is you need to address is absolutely.
The second way is relative addressing. You don't need to know which level does your mc absolute although you need to know how many levels up or down relative to your reference mc. So let's say we have mc in the maintimeline and another mc inside of it. So let's address the middle level one from the inside.
this._parent
this refers to the mc we are in. and _parent is the one up level.
So if we want to address _root from two levels down, we call it this._parent._parent
- ozhanlion0
also don't mix that with _levels in flash.
it is another story.
- method_c0
ozhanlion, thank u for helping me out man! and thanks for the scripting lesson :)
- ozhanlion0
anytime dood :)
- method_c0
im addicted to your casino games
- ozhanlion0
shit they are not mine. of course.
I think that hosting company in russia is dead. flashmaster.ru
Thanks for reminding...