Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

function not directing to named keyframe 1

Status
Not open for further replies.

markdmac

MIS
Dec 20, 2003
12,340
US
Hope someone can help me. I am fairly new to flash. My experience thus far has been editing template FLA files. I am now int he process of creating a text based adventure game from scratch. I am following examples in the Beginning Flash Game Programming book by Andy Harris.

I have a keyframe in Layer 1 Frame 1. There is text and a button that I have named "btnStart". 10 frames later I have another keyframe, that one is labeled "start".

I am using Adobe Flash CS. I have set the publish settings to use ActionScript 2.0.

In my Actions panel under Actions-Frame I have selected Layer 1 Frame 1 and entered the following code.

Code:
stop();
btnStart.onRelease = function(){
  _root.gotoAndStop("start");
} // end onRelease

I publish or use Ctrl+Enter to test. My button changes color as it should when I hover or click on it, but I am not directed to the "start" frame as expected when I click and release. There are no "compile errors" listed in the IDE. Can anyone see anything wrong with what I am doing? Any help is greatly appreciated.
 
It does work... Hit the specter or one character in the text...
The problem is that you have a button, btnPlay, within another button, and that won't work...

If you set the startButton as being a movie clip (with only one frame rather than the 3 you now have) and use the following after giving the instance name of btnPlay to your play button...

stop();
btnStart.btnPlay.onRelease = function(){
_root.gotoAndStop("start");
} // end onRelease

Then that works... But I would do it as you have done it with the other buttons on the start frame...

Regards. FLASH HELP - OPENED FOR BUSINESS!
TO GET YOUR OWN FREE WEBSITE HOSTING
 
Thank you! This was driving me crazy. I honestly don't fully understand everything you were saying about having a button inside another button, but I deleted the button on the first frame, removed the frames in between it and the next named frame and after adding back in my button, sure enough it works like a charm. Thank you for your help. Now I can move on with the project.

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
For anyone interested in seeing the work in progress:




I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top