Forum Topic: Really new to action script.

(138 views • 8 replies)

This topic is 1 page long.

<< < > >>
None

zypher82

Reply To Post Reply & Quote

Posted at: 11/2/09 10:52 PM

zypher82 NEUTRAL LEVEL 01

Sign-Up: 11/02/09

Posts: 8

Ok im pretty new to actionscript but im catching on fairly quickly (using AS2). Im good with javascript and apparently im too used to javascript and php because variables dont seem to work the way they are supposed to in AS. I have 3 buttons and they pop a menu below them (coming in from left or right depending on the last button that was moused over).

i simply have an if statement inside of an on(rollOver) to see which button was last highlighted and executing an exported movie clip from there.

on(rollOver){
if(which > 1){
insert.attachMovie("menuRight", "menuRight", 200);
insert2.attachMovie("empty","", 200);
insert3.attachMovie("empty","",200);
}
else {
insert.attachMovie("menuCenter", "menuCenter", 200);
insert2.attachMovie("empty","", 200);
insert3.attachMovie("empty","",200);
}
which = 1;
}

and have that for 3 buttons of course changing depending on the button. Well it doesnt work in any way. it almost seems like its not checking the value of "which" at any time, it doesnt even execute the else statement. BTW, i have var which = 0; on the first frame. Any help in understanding how AS reads, updates, and executes variables would be very helpful :)


None

Treerung

Reply To Post Reply & Quote

Posted at: 11/2/09 10:56 PM

Treerung DARK LEVEL 11

Sign-Up: 04/18/08

Posts: 568

To make the code check your variables on every frame simply put it in an onEnterFrame function like this:

onEnterFrame=function()
{
//Your code
}

:'(

BBS Signature

None

zypher82

Reply To Post Reply & Quote

Posted at: 11/3/09 08:33 AM

zypher82 NEUTRAL LEVEL 01

Sign-Up: 11/02/09

Posts: 8

just tried:
button1.onEnterFrame = function(){
if(which > 1){
insert.attachMovie("menuRight", "menuRight", 200);
insert2.attachMovie("empty","", 200);
insert3.attachMovie("empty","",200);
}
else {
insert.attachMovie("menuCenter", "menuCenter", 200);
insert2.attachMovie("empty","", 200);
insert3.attachMovie("empty","",200);
}
which = 1;
}
still no luck. for some reason it wont even execute the else statement, which means the actionscript isnt being run right because the else should always be run if nothing else is true. it just doesnt seem to make sense. im goin over the script over and over and it all makes 100% sense but the program has no clue what to do with it


None

Shadowii2

Reply To Post Reply & Quote

Posted at: 11/3/09 09:57 AM

Shadowii2 DARK LEVEL 29

Sign-Up: 09/30/06

Posts: 729

The only problem I see with your code is that you are using the same depth (200) for each attachMovie script.
Depth should ALWAYS be different for each attachMovie script.

Easiest way to fix the depth issue is to replace every but one "200" in your code. Like giving the rest the values of "201", "202" etc.
Or then again, you can use the following code to define the debth:

_root.getNextHighestDepth()

You may not need the "_root." part, but you can always try.
Hope that helps.

Links to my SheezyArt and deviantArt accounts

BBS Signature

None

Lifes-a-Bitch

Reply To Post Reply & Quote

Posted at: 11/3/09 10:07 AM

Lifes-a-Bitch DARK LEVEL 12

Sign-Up: 08/04/06

Posts: 77

I'm suprised nobody pointed this out:

You have a line saying

if(which > 1){

When it should be:

if(which ><strong>=</strong> 1){

-Lab

Funny isn't it... Curiosity killed the cat, but throwing it out of an airbourne plane doesn't.

Terminal velocity FTW!


None

Lifes-a-Bitch

Reply To Post Reply & Quote

Posted at: 11/3/09 10:08 AM

Lifes-a-Bitch DARK LEVEL 12

Sign-Up: 08/04/06

Posts: 77

if(which >= 1){

The equals if very important. For some reason Flash wont read it correctly unless you have 2 operators.
(Forgot the HTML doesn't work in the code thing.)

Funny isn't it... Curiosity killed the cat, but throwing it out of an airbourne plane doesn't.

Terminal velocity FTW!


None

hdxmike

Reply To Post Reply & Quote

Posted at: 11/3/09 10:12 AM

hdxmike LIGHT LEVEL 09

Sign-Up: 09/11/09

Posts: 1,760

At 11/3/09 10:08 AM, Lifes-a-Bitch wrote: if(which >= 1){

The equals if very important. For some reason Flash wont read it correctly unless you have 2 operators.
(Forgot the HTML doesn't work in the code thing.)

STFU lab , >= is greater than or equal to dumbass , its not required

OOP AS3 || Flash 8,CS3,CS4 || *sigh* || The new forum on the block : FLASH SEED !

BBS Signature

Happy

havegum

Reply To Post Reply & Quote

Posted at: 11/3/09 10:16 AM

havegum DARK LEVEL 11

Sign-Up: 10/20/08

Posts: 427

Check out AS: Main

You will find your answer there :D


None

zypher82

Reply To Post Reply & Quote

Posted at: 11/3/09 01:18 PM

zypher82 NEUTRAL LEVEL 01

Sign-Up: 11/02/09

Posts: 8

lol... i knew my logic was correct. after racking my brain for 4 hours i stumbled on a stop() method that was nested down about 7 movie clips which was causing my headache. gotta love that...... thx for the help guys


All times are Eastern Standard Time (GMT -5) | Current Time: 04:40 PM

<< Back

This topic is 1 page long.

<< < > >>
You need a Grounds Gold Account to post on the NG BBS! If you don't have one, click here to sign up now! It's fast, free, and easy — and opens up tons of great NG features!