-
some weird code errors i've been having
so uhhhh i'm trying to make a Riddle School esque flash game and my code won't work for some reason, i have no idea what went wrong because flash says there's no compiler errors. any help?
on(release){
if (_root.cursor.currentFrame == 1){
_root.dialogue.gotoAndStop(9)
}
if (_root.cursor.currentFrame == 2){
_root.dialogue.gotoAndStop(12)
_root.cursor.gotoAndStop(1)
_root.inventory.inv1.gotoAndStop(1)
}
}
-
first, it's not a good way to write code directly on buttons/movieclips.
it should be written on a main Timeline and reformatted like this:
Code:
button1.onRelease = function() {
////your code....
}
same goes for "_root" addressing (called absolute), it's better to be substituted with (relative addressing) like "this", "_parent", "this._parent", etc...
second, you need to make sure the condition you're looking for in your "if" construction is correct.
have you tried tracing your "currentFrame" property?
add trace statement before "ifs":
Code:
trace(currentFrame);
if it's undefined, you'll know that something's wrong.
And finally.
What's "currentFrame"?
If you're looking for the frame number of certain movieclip or main timeline, it's spelled _currentframe.
You're simply spelled the property name wrong.
_currentframe (MovieClip._currentframe property)
public _currentframe : Number [read-only]
Returns the number of the frame in which the playhead is located in the movie clip's timeline.
Availability: ActionScript 1.0; Flash Player 4
Example
The following example uses the _currentframe property to direct the playhead of the actionClip_mc movie clip to advance five frames ahead of its current location:
actionClip_mc.gotoAndStop(actionClip_mc._currentfr ame + 5);
so it's better to do like this.
place your new code on the frame where you have your button.
and don't forget to specify instance name for the button.
Code:
this.button_name_goes_here.onRelease = function() {
if (this.cursor._currentframe == 1){
this.dialogue.gotoAndStop(9);
}
if (this.cursor._currentframe == 2){
this.dialogue.gotoAndStop(12);
this.cursor.gotoAndStop(1);
this.inventory.inv1.gotoAndStop(1);
}
}
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
|