Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > ActionScript Forums Group > ActionScript 1.0 (and below)

Reply
 
Thread Tools Rate Thread Display Modes
Old 07-22-2003, 02:40 AM   #1
shaoSTYL3
Registered User
 
Join Date: Jul 2003
Posts: 10
Send a message via AIM to shaoSTYL3
Default A Frustrated New User with some ?s

I started using Flash MX about 2 or 3 days ago.

I went through all the 'lessons' and have a good grasp of how to navigate with the program's GUI. After completing the puzzle piece tutorial, I decided to make a script of my own. I planned a simple script, just one with an animation in the background with music playing and a button that would start and stop said music. It turns out this simple sounding script is too much for me

here's what i wrote... the script for frame1
Quote:
status = true;
sound.attachSound(tranzy);
_root.tranzy.start
if (status=true) {
msg = "Stop Music";
} else {msg = "Start Music";
}
the script for my sole button
Quote:
on (release) {
if (status=true) {tranzy.stop();
} else {
tranzy.start();
status = false;
}
}
i'll try explaining what i was thinking if this looks like crap to all of you experts

the variable msg is for a dynamic text box that is on top of the button (so that it says either stop music or start music). status is a boolean for whether or not the music is playing. In my library, i have a wav that i named tranzy (in the linkage as well as in library), which is why i tried "_root.tranzy.start" (to play it from the very beginning).
Now as for the button's scripting... it should be pretty self-explanatory. Assuming that the music is already playing when the program starts (which it doesn't), clicking the button would turn it off if status were true and turn it off if status were false. That's what i planned for it to do, but it doesn't do anything at all.

Can someone help me at all? If you don't feel like taking the time to explain, could anyone at least upload a sample .fla with a button that starts/stops sound that i could look at?

lastly, if you need anymore information about my .fla that could help you help me, let me know.

Thanks...
shaoSTYL3 is offline   Reply With Quote
Old 07-22-2003, 03:00 AM   #2
patmanwb
Registered User
 
Join Date: Jul 2003
Location: California
Posts: 85
Default

shaeSTYL3,

I will do my best to show you a sound and an event handler that starts the sound...

ActionScript Code:
var tranzy = new Sound(); tranzy.attachSound("tranzy.mp3");

Do the above code in a new layer called 'sounds' in the first frame.

Then with the sound in the Library you need to set up the linkage propterty. So find your sound in the library and if it is not there you need to get it into the library . Right click it and go to linkage, then click the "Export for ActionScript" check box and close the window.

Then on the button this code should work...
ActionScript Code:
on (release){     if (playing){         _root.tranzy.stop();         playing = false;     }else{         _root.tranzy.start();         playing = true;     } }
patmanwb is offline   Reply With Quote
Old 07-22-2003, 02:17 PM   #3
shaoSTYL3
Registered User
 
Join Date: Jul 2003
Posts: 10
Send a message via AIM to shaoSTYL3
Default

Thank you very much for your help! after using some of your code, I got my button to alternate between turning on and off the sound! Afterwards, I spent some time trying to get the text box to display the correct text (i think my trouble was that i put the variable setting code in the layer 1 instead of the button), and i got that too!

again... thanks
shaoSTYL3 is offline   Reply With Quote
Old 07-22-2003, 02:28 PM   #4
senocular
six eyes
 
senocular's Avatar
 
Join Date: Jan 2003
Location: San Francisco, CA (USA)
Posts: 7,875
Send a message via ICQ to senocular Send a message via AIM to senocular Send a message via MSN to senocular Send a message via Yahoo to senocular
Default

just a little something quick about if statements...

before you had

if (status=true)

^ that uses the = sign or the assignment operator in the parenthesis. = sets a value to equal another value, like when you originally assigned status to be equal to true. Now, if you want to compare two values to see if they are equivalent, like for instance if you want to see if status is the same as true, then you use the equality operator which is a double equals or == ...

if (status == true)

What patmanwb did was just have a playing variable in the if statement. The if statement just checks if that value alone can be evaluated into true or false and then uses that as the if condition. If the playing variable is equal to true, then if (playing) will evaluate to if (true) which will run the if statements that follow.

If you wanted to see if the playing variable was false, you could check it for false

if (playing == false)

or you could use

if (playing != true)

which is saying if playing is not equal to true - ! being the 'not' symbol. It can also be used like so

if (!playing)

This says if not playing then... statements. What !, or not, does, is revereses an evaluated true or false value. So !true is false.

etc.
__________________
(6)
senocular is offline   Reply With Quote
Old 07-22-2003, 02:35 PM   #5
patmanwb
Registered User
 
Join Date: Jul 2003
Location: California
Posts: 85
Default

Thanks for doing the clean up senocular... I guess I should explain a bit more about what I am coding in my responses...


Thanks!
patmanwb is offline   Reply With Quote
Old 07-22-2003, 03:18 PM   #6
boyzdynasty
Senior Member
 
boyzdynasty's Avatar
 
Join Date: Aug 2002
Location: Philly
Posts: 2,583
Default

I'm learning VB for my internship this summer and the stupid assignment and conditional statement ment the same thing *erRRR

Took me forever to fig. that out.
__________________
I need a new signature!
boyzdynasty is offline   Reply With Quote
Old 07-22-2003, 04:14 PM   #7
shaoSTYL3
Registered User
 
Join Date: Jul 2003
Posts: 10
Send a message via AIM to shaoSTYL3
Thumbs up

hm.m.. that might have been why my dynamic text box didnt' work earlier... thanks for the info.
shaoSTYL3 is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT. The time now is 11:49 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.