PDA

View Full Version : I need AS(action script) Help



silverneo188
September 14th, 2006, 04:41 AM
does anyone know the full action script for making a sequence where i select a object and it removes it from my money var.? i got the var(variable) and the money, and the object i want the flash to take the money from when i click on it. I just need help with the code! PLZ SOMEONE HELP!

I also want it to make a messege saying not enough cash if you dont have the right amount. it needs to update the dynamice text of the money when button is pressed.

LozT
September 14th, 2006, 07:05 AM
I don't if this going to help you but here it goes:




on(release) {
<var initial_money> = <var money>;
<var money> = <var money> - <var object price>;
if (<var money< 0) {
trace("Not Enough Cash"); //you can put this in a dynamic box
<var money> = <initial_money>
}



hope it helps you.

LozT
September 14th, 2006, 07:09 AM
I don't if this going to help you but here it goes:

hope it helps you.

I forgot a "}" at the end.

(this are stupid caracters fo fill the message lol)

silverneo188
September 14th, 2006, 12:57 PM
ill try hold on

silverneo188
September 14th, 2006, 01:04 PM
I tried it and it gave me this

**Error** Scene=Scene 1, layer=Graphic, frame=2:Line 2: Unexpected '<' encountered
<var initial_money> = <var money>;

**Error** Scene=Scene 1, layer=Graphic, frame=2:Line 3: Operator '<' must be followed by an operand
<var money> = <var money> - <var object price>;

**Error** Scene=Scene 1, layer=Graphic, frame=2:Line 4: Unexpected '<' encountered
if (<var money< 0) {

**Error** Scene=Scene 1, layer=Graphic, frame=2:Line 6: Unexpected '<' encountered
<var money> = <initial_money>

**Error** Scene=Scene 1, layer=Graphic, frame=2:Line 8: Unexpected '}' encountered
}

Total ActionScript Errors: 5 Reported Errors: 5



what is wrong this

silverneo188
September 14th, 2006, 01:24 PM
what do i put in the
the bolded areas

on(release) {
<var initial_money> = <var money>;
<var money> = <var money> - <var object price>;
if (<var money< 0) {
trace("Not Enough Cash"); //you can put this in a dynamic box
<var money> = <initial_money>
}

tell me if i leave it or replace it
and if I replace that what do I replace it with

JoshuaJonah
September 14th, 2006, 02:00 PM
the "<"s and ">"s are not valid characters for variables, you need to replace them too. More like this:

on(release) {
initialMoney = money
money = money - objectPrice
if (money <= 0) {
trace("Not Enough Cash"); //you can put this in a dynamic box
money = initialMoney
}

LittleFenris
September 14th, 2006, 03:44 PM
what do i put in the
the bolded areas

on(release) {
<var initial_money> = <var money>;
<var money> = <var money> - <var object price>;
if (<var money< 0) {
trace("Not Enough Cash"); //you can put this in a dynamic box
<var money> = <initial_money>
}

tell me if i leave it or replace it
and if I replace that what do I replace it with

They were giving you a general idea of how to setup your code so you had somewhere to start w/o just handing you the code. You will never learn if you are just handed all the code you want/need. JoshuaJonah has given you a great place to start now.

silverneo188
September 14th, 2006, 06:21 PM
it's confusing I dont get it

LittleFenris
September 14th, 2006, 06:50 PM
Can you post your .fla file or a swf so we can see what you have already. Without some more info from you its hard to help.

silverneo188
September 14th, 2006, 09:17 PM
the .fla file is bigger than 74kb so ill just post a pic of what i want done

http://img3.freeimagehosting.net/uploads/f854f263e0.png (http://www.freeimagehosting.net/)

if possible i want it to effect a blank box and puts the letters in there like so in image below

http://img3.freeimagehosting.net/uploads/3b5839c405.png (http://www.freeimagehosting.net/)
the screen shots were taken from dif. versions. i just "super Mode" to be added to a dynamic text box. The above images were edited with Fireworks MX

silverneo188
September 14th, 2006, 09:45 PM
I got yet another problem when i go to the shop then back to main game all the crystals are back and my value of my crystals is back to 0.
I need to keep it when you go to frame 2 then back to frame 1 everything is the way you left it.PLZ HELP.

evildrummer
September 17th, 2006, 04:48 PM
host your .fla somewhere so we can help, just sign up with freewebs for future if you dont have a host, www.freewebs.com

-Z-
September 19th, 2006, 11:18 PM
I suggest you divied the game into several workable sections... like movement.... map... and near the end work on stuff like shops....

Looks to me like you just posted a bunch of pictures and want them to work together.

Don't get me wrong, I'm a newbie as well... I'm still less than 20% done with my very first flash program... I learn working on big projects as well... However you should start with something 'simpler'... actually this is very simple, but if there is no structure for it... nothing will happen.

silverneo188
September 20th, 2006, 01:41 AM
ummm... im using a school isued laptop i cant access my freewebs site through my laptop. if u know a good proxy server that isn't blocked then please tell so i can edit my freewebs site.

KIERIOSHIMOTO
September 20th, 2006, 10:46 AM
ummm... im using a school isued laptop i cant access my freewebs site through my laptop. if u know a good proxy server that isn't blocked then please tell so i can edit my freewebs site.

Here's what I made for you..

silverneo188
September 20th, 2006, 09:31 PM
thks ill try it out now

silverneo188
September 20th, 2006, 10:00 PM
http://img2.freeimagehosting.net/uploads/de32e15a43.png (http://www.freeimagehosting.net/)
I get this popup when i try to open it.

KIERIOSHIMOTO
September 20th, 2006, 10:54 PM
What popup is it? Does it say something about "Invalid file type." or something?

silverneo188
September 21st, 2006, 01:26 AM
it's an flash error message and it says
"Failed to open document.Macintosh HD Users:benderj: Desktop:Shop-1.fla."

starting where it says macintosh is the file location.

KIERIOSHIMOTO
September 21st, 2006, 08:02 AM
Are you using MAC?

silverneo188
September 23rd, 2006, 02:06 AM
ya

KIERIOSHIMOTO
September 23rd, 2006, 09:44 AM
Oh, I use windows, I dont know if the two FLA's will conflict or anything. But basically all I did was make a shop type thing for you. It's pretty easy, consists mostly of variables..

silverneo188
September 23rd, 2006, 05:50 PM
um. i dont know those variables.
Can you just copy the code and paste here?

KIERIOSHIMOTO
September 24th, 2006, 12:01 AM
Variables..you know..like

health=100;

That's a variable. Making a shop is easy, it's just a matter of taking the value of the item away from your money:


money-=item_value;

silverneo188
September 24th, 2006, 09:57 PM
i get the code there but what do i put in for the item thing? or do i replace item_value with the number i want it to be?