flash actionscript:
Hey, I am currently in the middle of a school project in which I need to add interactivity to a presentation. I am using Flash MX 2004 and I am having difficulty in linking 2 scenes together via buttons and I need to find a solution very fast. I know this sounds stupid, but I am quite new to Flash and, therefore, ActionScript. I have tried using the sample code (and customising it) in the help file that comes with Flash MX 2004, but I believe that it is for a different version of ActionScript, because it doesn?t work. PLEASE HELP ME!!!
don't use scene information for navigation. give your frames labels and use those labels. for example:
**Error** Scene=Scene 1, layer=Layer 2, frame=1:Line 1: Statement must appear within on/onClipEvent handler man_btn.onRelease.gotoAndPlay("scene2_frame1") Total ActionScript Errors: 1 Reported Errors: 1 Ok, I am very very new to ActionScript, and I have no I dear of what that means lol, however, when I attach this code to the button; button_btn.onRelease.gotoAndPlay("scene2_frame1") where button_btn is the button instance. It comes up with this error message **Error** Scene=Scene 1, layer=layer , frame=1:Line 1: Statement must appear within on/onClipEvent handler button_btn.onRelease.gotoAndPlay("scene2_frame1") Total ActionScript Errors: 1 Reported Errors: 1 When I check the Syntax I have no idea what this means apart from the it isn?t working. Please help, Thanks anyway.
you need to define it as a function: myOtherBtn_btn.onRelease = function(){ gotoAndPlay("Scene 2", 1); }; But if you took kglad's advice and used frame labels use: myOtherBtn_btn.onRelease = function(){ gotoAndPlay("scene2_frame1"); };
ok, I typed this code into the button actions (is that right?); button_btn.onRelease = funtion(){ gotoAndPlay("scene2",1); }; where button_btn is the button and the following returned as I checked the syntax **Error** Scene=Scene 1, layer=layer , frame=1:Line 1: Syntax error. button_btn.onRelease = funtion(){ **Error** Scene=Scene 1, layer=layer , frame=1:Line 3: Statement must appear within on/onClipEvent handler }; Total ActionScript Errors: 2 Reported Errors: 2 which again, tells me that it isn't working! Also, tell me that i haven't gone mad - the command in ActionScript to cease the animation is stop (); correct? cause when i assign it to a keyframe with nothing in it, it doenst work. Thanks for replying
ok if you are putting it on a button action you would use: on(release){ gotoAndPlay("SceneName", frame#);
ok, I tried the code that .:}x-=V!P=-x{:. told me, that was on(release){ gotoAndPlay("Scene 2", 1); } This time, no syntax errors, but when i play it (ctrl+enter), it doesn't work?? THanks to all
oh, and i am trying to stop the timeline.
If you still have scenes and labels in the scenes you can use gotoAndPlay like this: gotoAndPlay("Scene 2", "scene2_11") scene2_11 is a lable I put on the eleventh frame in Scene 2. To stop playing put stop() in frame 11 of Scene 2.
let me repeat: don't use scene information for navigation. give your frames labels and use those labels. for example: _root.gotoAndPlay("scene2_frame1"); if you want a button trigger that code's execution upon release, attach to the button: on(release){ _root.gotoAndPlay("scene2_frame1"); } or if you want to stop on that frame use: on(release){ _root.gotoAndStop("scene2_frame1"); }
Ok, I have given the first frame in Scene 2 the label of 'Frame 1' and no attatached the following code to the button. on(release){ _root.gotoAndPlay("scene 2_frame 1"); } It comes up with no Syntax errors, and still doesn't work - Do I have to change the "_root." part of the code? If not, what am I doing wrong. I know almost nothing about ActionScript so the problem is probably blatantly obvious and I would like to thank everyone for responding. Cheers
After playing around with the code, I have found out that you do not have to tell Flash to go to go to the second scene IF you have labelled the frame. The final working code is as follows; on(release){ _root.gotoAndPlay("frame 1"); } when you attach it to the button. The ?frame 1? is the frame label. The frame that you label can be in any scene (theoretically) and will take you straight to it. I would like to thank kglad and .:}x-=V!P=-x{:. For their help in getting a quick result. CHEERS!
you're welcome. your discovery was exactly the info in my message. perhaps it was confusing that i used "scene2_frame1" as the frame label. it contains no scene info for flash to use. it contains only scene info so it's easy for humans to remember or find where that frame is located.
Don't see what you're looking for? Try a search.
|