Home  | Login  | Register  | Help  | Play 

2-way switches in Flash? All done! Lockage please.

 
Logged in as: Guest
  Printable Version
All Forums >> [Gaming Community] >> [Legends and Lore] >> Artists of Legend >> Art Academy >> 2-way switches in Flash? All done! Lockage please.
Forum Login
Message << Older Topic   Newer Topic >>
8/31/2008 13:03:28   
jiggibidy
Member

I am in in the process of making an Energy Sword in Flash CS3, and was wondering how I could incorporate a 2-way switch. So that on the first click, the sword appears, and on the second click, the blade retracts.

Thanks in advance.

~Peace Out,

~Jiggi.

< Message edited by jiggibidy -- 9/1/2008 13:44:48 >
AQ DF MQ  Post #: 1
8/31/2008 13:34:01   
biG frend
Member

Use an if statement and a variable.

So in the mainframe put this

sword = 0; (work in AS2 plzkthx)

Then give the button this actionscript.

on (release) {
	if (_root.sword=0) {
		//put your gotoandstop command for your animation here then add this to the bottom
		_root.sword = _root.sword+1;
	}
	if (root.sword=1) {
		//put your gotoandstop command for your animation here then add this to the bottom
		_root.sword = _root.sword-1;
	}
}
AQ DF MQ  Post #: 2
8/31/2008 14:03:51   
jiggibidy
Member

OK, I had a go, and this is my code, it said that it had some sort of error:

quote:

sword = 0;
on (release) {
if (_root.sword=0) {
//gotoandstop blade
_root.sword = _root.sword+1;
}
if (_root.sword=1) {
//gotoandstop blade
_root.sword = _root.sword-1;
}
}
AQ DF MQ  Post #: 3
8/31/2008 14:43:32   
Mo
Member

Are you sure you are using AS2? It may be because you can't put AS into graphics and such anymore in Flash CS3
AQ MQ  Post #: 4
8/31/2008 15:14:43   
jiggibidy
Member

yeah, I'm sure I'm using AS2, I thought it might have been because I didn't make the switch a button, but now, after turning it into a switch, I tried it again, but still to no avail, here is the screenshot of the error report:

Could you help get me on the right track please?
AQ DF MQ  Post #: 5
8/31/2008 15:44:57   
biG frend
Member

Its because your not using correct syntax. Remove the "//" all the "//" is, is basically commentary to explain the code. You should replace it with _root.mcnamehere.gotoAndPlay(frame);
AQ DF MQ  Post #: 6
8/31/2008 15:47:24   
jiggibidy
Member

ah, ok, thanks very much, i'll try it now and let you know how it goes.
AQ DF MQ  Post #: 7
8/31/2008 15:53:15   
biG frend
Member

Oh also put the sword = 0; in the FRAME actions not the button.
AQ DF MQ  Post #: 8
8/31/2008 16:06:04   
jiggibidy
Member

Ok, Flash seems to be heving a problem with the sword = 0;
It says "Statement must appear within on/onClipEvent handler"
AQ DF MQ  Post #: 9
8/31/2008 17:06:06   
jiggibidy
Member

What do you mean by "put it in the frame actions", where is the "frame actions"?
AQ DF MQ  Post #: 10
8/31/2008 17:11:13   
biG frend
Member

Right click the frame and hit actions.
AQ DF MQ  Post #: 11
8/31/2008 17:12:17   
Davosaur
Member
 

//just goto the first frame on the timeline and put the actions there that code is called "actions" hence ActionsScript
Post #: 12
8/31/2008 17:13:06   
The Illusive Man
Member

jiggi

Click the frame in the timeline. Then open the actions panel. Define the sword variable there.

Also, instead of just sword=0. Type this in the frame

var sword:Number = 0;

That tells flash that it is definitely a number and not a string. Just refer to it as sword later though.




Also, biG's code is wrong. Try this edited version:




#IN FRAME ACTIONS!
var sword:Number = 0;

#In your button actions

on (release) {
if (_root.sword==0) {
//DO YOUR gotoAndStop(); ACTION HERE!  THIS IS NOT LITERAL!  YOU MUST KNOW HOW TO DO A GOTOANDSTOP
_root.sword = _root.sword+1;
}
if (_root.sword==1) {
//DO YOUR gotoAndStop(); ACTION HERE!  THIS IS NOT LITERAL!  YOU MUST KNOW HOW TO DO A GOTOANDSTOP
_root.sword = _root.sword-1;
}
}


Try that
Post #: 13
8/31/2008 17:30:24   
jiggibidy
Member

Well, I tried that, but to no avail, here is my code: I think it may be my gotoAndStop's
quote:

on (release) {
if (_root.sword==0) {
gotoAndStop(1)
_root.sword = _root.sword+1;
}
if (_root.sword==1) {
gotoAndStop(5)
_root.sword = _root.sword+1;
}
}
AQ DF MQ  Post #: 14
8/31/2008 17:31:50   
Davosaur
Member
 

or if your really lazy and being cheap like me you can do this :

make one MC then inside tham MC you have 2 buttons both on different frames, make sure you have a stop acion though

on both frames :
stop();

on button 1:
on (release) {
swordblade.gotoAndPlay(
gotoAndStop(2);

}


on button 2
on (release) {
swordblade.gotoAndPlay(2)
gotoAndStop(2);
}

!comments! ya thats what i do though if your gonna add a button animation ist the same thing just with a tween[or FBF..]
Post #: 15
8/31/2008 18:33:20   
jiggibidy
Member

K, I have the variable set on the first frame, on the layer with the blade on it, and here is my code, which is set on the button:
quote:

on (release) {
if (_root.sword==0) {
gotoAndPlay(12)
_root.sword = _root.sword+1;
}
if (_root.sword = _root.sword==1) {
gotoAndPlay(24)
_root.sword = _root.sword-1;
}
}

Frame 12 and Frame 24 are the frames that the blade appearing and disappearing are set to.
AQ DF MQ  Post #: 16
8/31/2008 18:55:07   
ShadowSlash
Member

I know next to nothing about ActionScript, so punch me if this is wrong...
but maybe you're supposed to add the semicolon on the end of the gotoAndStop() ?
as in-
    on (release) {
    if (_root.sword==0) {
    gotoAndStop(1);
    _root.sword = _root.sword+1;
    }
    if (_root.sword==1) {
    gotoAndStop(5);
    _root.sword = _root.sword+1;
    }
    }


I just copy/pasted then added the semicolons :P
just wondering, ignore this if you know its wrong


quote:

Well, I tried that, but to no avail, here is my code: I think it may be my gotoAndStop's

quote:

on (release) {
if (_root.sword==0) {
gotoAndStop(1)
_root.sword = _root.sword+1;
}
if (_root.sword==1) {
gotoAndStop(5)
_root.sword = _root.sword+1;
}
}


Also make sure you have the code in the right place.

< Message edited by ShadowSlash -- 8/31/2008 19:46:20 >
AQ  Post #: 17
9/1/2008 3:45:01   
The Illusive Man
Member

You are right ShadowSlash. You do need semicolons. I thought I made that clear, but apparently not.

If you still can't get it, i'll make a sample fla I suppose.
Post #: 18
9/1/2008 7:41:53   
jiggibidy
Member

I tried adding semicolons, and it still didn't work.
I would very much appreciate it if you would make a sample .fla.
This is really starting ot annoy me.
AQ DF MQ  Post #: 19
9/1/2008 10:24:41   
The Illusive Man
Member

http://www.mediafire.com/download.php?adbaaa8wqaa

The script is different to biG's, but works the same.

I didn't comment it, but you can probably figure out what it does

-Al
Post #: 20
9/1/2008 12:11:44   
jiggibidy
Member

Bah, I still can't get it to work!
How about I send you the .fla and you could rectify it for me?
AQ DF MQ  Post #: 21
9/1/2008 12:21:32   
The Illusive Man
Member

Why not I suppose... Upload on mediafire and PM me the link
Post #: 22
9/1/2008 13:44:24   
jiggibidy
Member

All sorted now. Thanks Althorne, I owe you one.

~Peace Out,

~Jiggi.
AQ DF MQ  Post #: 23
Page:   [1]
All Forums >> [Gaming Community] >> [Legends and Lore] >> Artists of Legend >> Art Academy >> 2-way switches in Flash? All done! Lockage please.
Jump to:






Icon Legend
New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts




Forum Content Copyright © 2018 Artix Entertainment, LLC.

"AdventureQuest", "DragonFable", "MechQuest", "EpicDuel", "BattleOn.com", "AdventureQuest Worlds", "Artix Entertainment"
and all game character names are either trademarks or registered trademarks of Artix Entertainment, LLC. All rights are reserved.
PRIVACY POLICY


Forum Software © ASPPlayground.NET Advanced Edition