PDA

View Full Version : Flash MX 2004 Action Script confusion!!



DTOXX
03-25-2004, 08:40 AM
First, I'll admit that I'm a complete noob when it comes to coding in Flash. Now, here's what's frustrating me - I recently purchased "Flash Advanced" from Peachpit Press so that I could just try to get my hands around Action Script. I just wanted to do something very simple: create a button with a getURL link. The book says that the code for the button should look like this:

button_name.onRelease = function() {
getURL("http://www.myurl.com");
};

But, that only gives me a syntax error which reads:

**Error** Scene=Scene 1, layer=Layer 2, frame=1:Line 1: Statement must appear within on handler

Now, if I use what I suppose would be considered obsolete syntax:

on(release) {
getgetURL("http://www.myurl.com")
}

it works just fine with no errors.

So, what's going on? What's all this "new" Action Script about if it doesn't work?

DTOXX
03-25-2004, 10:57 AM
OK, forget it. I discovered that the code in the book was a FRAME action. Applying it to the frame I wanted allowed it to work properly.

thebillionaire
04-09-2004, 01:00 PM
The first codes work but I think that the only problem is that you may have put the code

" button_name.onRelease = function() {
getURL("http://www.myurl.com");
}; "

inside the buttons action script. you must put it into a frame where the button is located. The other code you had was

"on(release){
getgetURL("http://www.myurl.com")
} "

this will not work because the there is no getgetURL function, but there is a getURL function, so the code should look something like this.

on(release){
getURL("http://www.myurl.com")
}

DTOXX
04-09-2004, 02:45 PM
Thanks, Crusader!

thebillionaire
04-09-2004, 03:26 PM
your Welcome. If you need any more help just ask me.

iKwak
04-16-2004, 11:01 PM
I recently bought Flash 2004 but not enough time to learn and play with it.
Seems to have a high learning curve.
Someday...I'll be able to do some neat stuff.

thebillionaire
04-17-2004, 08:40 AM
lol, yea someday

pars
04-30-2004, 01:09 PM
I'm sorry if this is a repeated post, but I had to disconnect in the middle of it.

I need help with Flash Mx 2004.

I learned how to apply action to buttons in Flash MX. I have the book telling me how, but now I am working in Flash MX 2004 and I don't know how to do it.

I need know how to apply back actions , go to and play, and go to and stop actions.

I need to finish my web page before Tuesday in order to graduate. I haven't yet figured out how to operate that part of the system and need help.

My web site starts with a movie clip then opens to the home page. They are on the timeline.

The scenes work differently in the 2004 version also. I have several scenes that are literally pages with thumbnail buttons (and a movie clip if I figure out the actions). These thumbnail buttons each open to display a page with a larger image of the thumbnail button. Should I have put them scenes on the timeline as well?

I noticed the billionaire checks the forum quite often. I hope he/she/somebody will take the time to help me.

Thanks a Lot
PARS

thebillionaire
04-30-2004, 01:56 PM
I donít understand what you're question is, what do you want to do with the button make it go to another position on the timeline? Just tell me the problem and if you can upload the flash part (.swf) on the web, this would help me.

If you want a page to load your flash swf then sign up with this free web host.

http://members.freewebs.com/

Or another you would like.

You can also add me to msn messenger and we can talk in more detail. my email is:

shamimsaad03@hotmail.com

reply as soon as possible because I want to help to graduate.

If you need more help with graphics action scripts ect. just ask I have won the goldenweb award and other awards for my flash sites.
P.S Iím a boy.

thebillionaire
04-30-2004, 07:35 PM
The easiest way to do action scripts is copy the script from flash mx and paste it into mx 2004, but there are no quick action scripts for 2004. If you want to go to the previous scene type this into the "back button", covert the back button to a button not a movie clip:

on (release) {
gotoAndStop("Scene 1", 1);
}

replace scene 1 to what ever you named your scenes, and the 1 after Scene 1 is the frame where the button links to. gotoAndStop will make the script stop at the frame or if you donít want to freeze at Scene 1 and frame 1 then change "Stop" to Play , so it would look something like this:

on (release) {
gotoAndPlay("Scene 1", 1);
}

Or to just go to the previous scene type this in:

on (release) {
prevScene();
}

For the buttons that are linked to pages use:

on(release){
getURL("http://www.myurl.com")
}

replace myurl to any page, but donít delete the "" marks.

Finally for hidden buttons that are triggered on roll over type this in:

on (rollOver) {
gotoAndPlay(1);
}

assuming that your movie clip starts at frame one.

It doesnít matter much if you make you site on scene's or frame's, it depends on what you find easier. To copy frame's you have to select all the frame's you want copied, right click on any frame and clip copy (Ctrl+C wont work), then right click on a blank frame and click paste.

Hope that help's, if there is anything you need help in just ask.

I have posted this on website publisher just incase you lose this copy.

thebillionaire
05-02-2004, 12:41 PM
any one else need help?

Jaffro
05-05-2004, 06:20 AM
me :) But i'll put it in a new thread because, erm, dunno really :)

thebillionaire
05-12-2004, 01:18 PM
Ok Guys alot of people are emailing me for help, which is perfectly fine but if my inbox is full try emailing me again.

iKwak
05-23-2004, 09:47 AM
How long did it take you to be where you at now thebillionaire?

flashflood
05-23-2004, 03:24 PM
Hey I need some help thebillionaire!

I'm new to Flash also and can't seem to figure out this gotoAndPlay/gotoAndStop actions.

I'm trying to make a condition in the first frame of the main timeline to go to the end of the flash movie and stop playing. This is so that the movie only plays once upon loading, but doesn't play again between web page changes. I'm using this as a header/menu type flash movie. The problem is when I use the gotoAndStop function to move to the end, it would stop the movie completely instead of moving the playhead to the end. The movie would stop at the beginning and would not play at all. If I use the gotoAndPlay, then it wouldn't move to the end but instead plays the whole movie as if this command wasn't there.

I've tested the code by just using gotoAndPlay/gotoAndStop by itself in the first frame with no other code and it still wouldn't work as expected. Funny thing is, if I run the test withing Flash MX, it would work fine. If I run the flash by itself outside of Flash MX in the player, or run it within a web page, it wouldn't work.

Any ideas? I'm stumped. Thanks in advance for your help.

thebillionaire
05-24-2004, 11:47 AM
How long did it take you to be where you at now thebillionaire?

In terms of flash info 8 months. You can learn most of what I have learned by reading a book, but I just experimented.

So you want the flash movie to go to the end of the movie and stop right? Well itís easy using the flash explorer, but in a webpage you have to send a variable to an external file, and retrieve it, for this you have to use PHP.
Show me an example of what u have done so far.

But I think that since your new you should make 2 flash movies, on the main page (where the movie is sapposed to be played) and the other movie on the rest of the pages. The second movie you make have a control bar on it with play and stop. on play it will play the movie and on stop it will go to the beginning.

If you don't want to make the movie all over again put in this code in the play button.

on(release){
_root.loadMovie("http://www.yoursite.com/yourmainmoviethatplays.swf");
}

and on the stop button put this in:

on(release){
root.loadMovie("http://www.yoursite.com/secondmoviethatdoesntplay.swf");
}

If you need more help just tell me. Hope that helps

thebillionaire
05-26-2004, 04:56 PM
Did that help?

Spyder
11-07-2004, 11:41 AM
I am trying to use simple actionScripting and having NO luck :(

I have a movie with 3 scenes(Home, OEM, Supplier).
Problem 1:
I have two buttons on the Home scene, OEMbutn directs the playhead to the OEM scene and Supplierbutn directs the playhead to the Supplier scene (well, they're supposed to anyway).

I have this code attached to the OEMbutn:
on(release){
gotoAndPlay("OEM",1);
}

I have also tried this code (label reference):
on(release){
gotoAndPlay("myOEMlabel");
}

Neither of these work.

Problem 2:
when the animation is finished in the OEM scene, it is supposed to go back to the 'Home' scene. I have a very simple line of code attached to the last frame of the OEM scene.
Code:
gotoAndPlay("Home",1);

Again, I have also tried the Label reference:
gotoAndPlay("myHomeLabel");

And again, neither work. I'm frustrated!

Can someone please explain to me why Flash seems to have a serious problem navigating between scenes?

TIA,
Spyder

thebillionaire
11-07-2004, 12:11 PM
They all work for me, make sure you put in the stop(); action on the first frame of home. other than that everything seems fine.

Spyder
11-07-2004, 12:35 PM
Then I don't know what to do at this point. They still are not working.

:( :( :(

Spyder
11-07-2004, 01:00 PM
Well, rebooting the comp didn't help either. So I uninstalled and re-installed Flash. Buttons seem to be working now...yeah.

But I also have an intro animation scene that has the 'gotoAndPlay("Home",1); attached to the last frame. This script does not work. When I preview the scene, it just simply loops over and over, never acting on the script. When I change the script to simply go back to a label in the same scene, it does so. So obviously it's getting to that script, it just doesn't act on the gotoAndPlay('a different scene'). Any ideas or thoughts?

Again, TIA
Spyder

thebillionaire
11-07-2004, 08:52 PM
Try extending the key frame where the gotoAndPlay("Home",1); is at. Or you can create a movie clip and position it outside the scene, so it is not viewable by the visitor. In the movie clip but this action in:

onClipEvent(enterFrame){
gotoAndPlay("Home",1);
}

thebillionaire
11-07-2004, 08:53 PM
Though, I would recommend just flash mx, its the best flash version, atleast that what I think, Its not as easy as mx 2004 but it makes sense and works.

Spyder
11-10-2004, 09:30 PM
That's ok, I kinda HAVE TO make this stuff work, seeing as how my company bought the software for me off of my recomendation :D

Anyway, here's a new delimna for you (now that my Flash 'seems' to be working).

Whole new concept: one movie clip consists of one blue circle that animates in 5 different ways.
-Layer 1 is a 'Label' layer that simply labels each different animation on the timeline as a number (1 through 5).
-Layer 2 is the frameScript layer. Frame 1 includes a frameScript that includes the following code:
--> myVariable = random(5 +1); <-- the "+1" omits the default "0" as you already know.
--> gotoAndPlay(myVariable);

OK, when I trace 'myVariable', the output window shows the variable equaling anywhere from 1 thru 5 ...GREAT! BUT, the playback plays the 1st animation only, hhhmmpphh.

At the end of each animation, I have another frameScript that directs the playhead to go back to the 'start' of the timeline and rerun the above script.

Any ideas as to why the random() is working but the playhead refuses to jump to the value of the variable? Again, the value of the variable is equal to the corresponding name of the label ...hhhmmm, could it be a problem with the variable being a number and the label (although numerical) is actually represented as text?

TIA,
Spyder