|
Post by Kulock on Dec 11, 2006 0:41:31 GMT -5
Just dinking around with a bit of Flash work, and I decided to try to make a music object, so it's self-contained. I had some luck up until trying to make the Start/Stop actual buttonage included with the object. (I could work it fine seperately, but it'd be better to include it all together.) When I try to use the same "Action Script on Button instances" approach in the Graphic, Flash complains that only Button objects can have Mouse actions. But these are button objects. I did some brief searching online, and will do more, but they seem to describe right-clicking on the instance, hitting Properties, and adding the action there, except I see no way to do that. (Perhaps they're describing how it works in an old version of Flash.)
This seems strange. Is there anyway to have a working button object inside of a graphic object or movie clip, or do I absolutely have to have it on the actual main timeline?
|
|
|
Post by Kulock on Dec 11, 2006 4:10:16 GMT -5
Anyway, so I separated out a button and two bits of text to try to do the job. Currently it all looks like this:
Main Stage: Frame 1 (Does not loop back to, starts looping at Frame 2):
var musicstate = 1;
Music On/Off Button:
on (release) { if (musicstate = 1) { MusicBox.gotoAndStop(2470); NowPlaying.gotoAndPlay(122); set (musicstate, 0); } else { MusicBox.gotoAndPlay(1); NowPlaying.gotoAndPlay(1); set (musicstate, 1); } }
Basically, musicstate is "Is something playing or not?" 1 is yes, the the main song, and anything else not listed should be "No." If something was playing, it sets the MusicBox to after the song and stops it there, and the Now Playing to the "Music Stopped" text before stopping. (Where it just normally displays the song name scrolling across.) This works in the Flash. It's also supposed to set the variable to 0.
But if you try clicking on the "Play" options, it just performs the first function again, instead of the "Else" statement. I'd rather not say "Else If = 0" as a catch-all, and even if I did, I'm not sure that'd fix it. Is musicstate not being set somehow, or is the setting being lost once the event is over?
|
|
Oni Lukos
Behind The Logo Team
Still spinning, for some reason...
Posts: 6,060
|
Post by Oni Lukos on Dec 11, 2006 7:16:40 GMT -5
I think you need Mouse.release instead of release.
|
|
|
Post by Kulock on Dec 11, 2006 16:30:06 GMT -5
But as I said, it works right the first time...
|
|
|
Post by Blues on Dec 11, 2006 18:29:25 GMT -5
I'm not sure, but it looks like you are using the assignment operator where you should be using the equality operator. Instead of checking if musicstate is 1 its setting music state to 1. Try changing the = into a double = sign like so.
|
|
Oni Lukos
Behind The Logo Team
Still spinning, for some reason...
Posts: 6,060
|
Post by Oni Lukos on Dec 11, 2006 18:53:45 GMT -5
I didn't catch that at first (I KNEW something looked off), but Blues is 100% accurate. That is a bug.
|
|
|
Post by Kulock on Dec 11, 2006 23:05:16 GMT -5
You know, I thought of that, but I checked someone else's code examples and they were like that.
...Nope, that didn't fix it.
|
|
|
Post by Kulock on Dec 12, 2006 18:39:07 GMT -5
One thing that might've helped: I added _root. to the beginning of the variable names specified on the button. Still doesn't do the trick, though, can't figure out why.
Also saw something that really did confuse me: A working button embedded in a movie clip/sprite. So they are doable. All well, my way should work too, once I can just figure out what I'm messing up.
|
|
diablohead
Active Member
Sequential Illustrator ಠ_ಠ
Posts: 249
|
Post by diablohead on Dec 12, 2006 23:27:38 GMT -5
This happens a lot in coding, try loading a new page and type it all again, magicly it will work half the time.
|
|