|
-
Senior Member
How do functions work?
Im just learning how to use functions properly but i kinda got no were.
To me this script look fine but obviuosly not because it dont work.
Can any one give me some insight on why?
Code:
onClipEvent (enterFrame) {
r = function () {
if (this._rotation != 90) {
this._rotation += 5;
}
};
}
on (release) {
r;
}
92.7 Fresh FM for all your South Aussies - Doof Doof music FTW people!
-
M.D.
i don't have flash on this computer so i have no idea if this will work, never seen that done before. Hmmmm
maybe it's the calling of the function which is wrong.
you have:
on(release){
r
}
try this:
on(release){
r()
}
you could also try declaring the function differently, like:
"function r(){}" rather than "r = function(){}"
my impression of a function is that it can be run as long as it is continuously being called. Chuck a trace command in their to see if the function is actually being called.
Last edited by mr_malee; 12-11-2005 at 03:24 AM.
-
Senior Member
I will try that, is there another way of doing why i am trying?
92.7 Fresh FM for all your South Aussies - Doof Doof music FTW people!
-
Senior Member
I tryed it and it did exacly the same thing as
on(release){
if (this._rotation != 90) {
this._rotation += 5;
}
};
And that only rotated 5 degree. I would like i loop that function. Any ideas
92.7 Fresh FM for all your South Aussies - Doof Doof music FTW people!
-
First of all, it's probably not a good idea to keep registering the function r inside an onEnterFrame event. Put it in an onLoad event if need be so it's only made once.
Second, you are calling this inner function in an onRelease event, so it will only be called when you release the key/button/mouse ( whatever release is for, can't remember. )
So, if you want r() to be called every frame ( continuously ) then it needs to be called in an onEnterFrame event.
Hope that helped.
-
Senior Member
Yea i understand, but i want the function to run after i release my MC. My code only runs the function for 1 frame but it would usealy last about 30.
So what i need.
On release of my MC
run r function untill its complete.
92.7 Fresh FM for all your South Aussies - Doof Doof music FTW people!
-
skylogic.ca
Code:
on (release) {
this.onEnterFrame = function () {
if (this._rotation != 90) {
this._rotation += 5;
}
}
}
That's how I'd do it, but then you probably want it to stop eventually so you can use "delete this.onEnterFrame;" wherever you want it to stop.
~MD
-
Senior Member
92.7 Fresh FM for all your South Aussies - Doof Doof music FTW people!
-
Senior Member
code:
// define function
function r():Void {
if (this._rotation != 90) {
this._rotation += 5;
}
}
// define event
<btn name>.onRelease = function():Void {
r();
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|