Forum Topic: Switching mouses in Flash Game

(157 views • 11 replies)

This topic is 1 page long.

<< < > >>
Crying

Cantdoright

Reply To Post Reply & Quote

Posted at: 11/8/09 08:54 AM

Cantdoright LIGHT LEVEL 11

Sign-Up: 08/07/07

Posts: 49

Just started relearning AS2 for Flash today and I have been wanting to make a Escape from Monkey Island type game. I am trying to make my own little look and use buttons (Ex. Hand icon picks things up and glasses looks at things). I want to be able to click a button to change the cursor and then press another button to display another cursor. This is what I have so far. The controls would be simple. Click the button you want to use and it will ethier look or use what you click. I have put down a small amount of code and have been tweeking it for the past few hours. I have looked at multible guides and they only help a little bit.

Here is the code on the frame

_global.Look=0
_global.Use=0

if(_global.Use=1)
{
	cursor_sc.startDrag(true);
	Mouse.hide();
}

if(_global.Look=1)
{
	cursor_mc.startDrag(true);
	Mouse.hide();
}

And this is the code for the glasses button

on(press)
{
	if(_global.Look=0)
	{
		_global.Look=1
		_global.Use=0
	}
}

and finally the hand box code

on(press)
{
	if(_global.Use=0)
	{
		_global.Use=1
		_global.Look=0
	}
}

Something tells me I am forgeting something that will make me feel dumb. Anyways Thanks for viewing and please contact me if you find out what is wrong.

Falling down laughing

BBS Signature

None

El-Presidente

Reply To Post Reply & Quote

Posted at: 11/8/09 08:56 AM

El-Presidente LIGHT LEVEL 27

Sign-Up: 06/02/05

Posts: 5,202

It looks like you're defining it in a place where it only works on the first frame. Try putting it either in an enterframe function of some sort, or just a function that goes off when you click the button.

MY E-PENIS IS BIGGER THAN YOURS
8=================================>
...and this is my fag...

BBS Signature

None

Cantdoright

Reply To Post Reply & Quote

Posted at: 11/8/09 09:05 AM

Cantdoright LIGHT LEVEL 11

Sign-Up: 08/07/07

Posts: 49

would you happen to have an example of an enter frame function or a funtion you might think will work?

Falling down laughing

BBS Signature

None

Yambanshee

Reply To Post Reply & Quote

Posted at: 11/8/09 09:23 AM

Yambanshee DARK LEVEL 11

Sign-Up: 10/05/08

Posts: 1,597

your if statements apear to be wrong aswell

its not (var = val) itss (var == val) note the double =

a = b

sets value a to value b

a == b

checks value a against value b

AS2||AS3||Motox
Thanks to hdxmike for the sig :]

BBS Signature

None

Cantdoright

Reply To Post Reply & Quote

Posted at: 11/8/09 09:49 AM

Cantdoright LIGHT LEVEL 11

Sign-Up: 08/07/07

Posts: 49

Thank you. That helped a bit but now they wont change... hmm any ideas?

Falling down laughing

BBS Signature

Sad

Cantdoright

Reply To Post Reply & Quote

Posted at: 11/8/09 10:09 AM

Cantdoright LIGHT LEVEL 11

Sign-Up: 08/07/07

Posts: 49

Well here is the newer edited version that I can still not find out what is wrong. Did I forget to do something you told me?

here be the demo of it.

and her is the codes for:

frame

_global.Use=false
_global.Look=false

if(_global.Look==true)
{
	cursor_mc.startDrag(true);
	Mouse.hide();
}

if(_global.Use==true)
{
	cursor_sc.startDrag(true);
	Mouse.hide();
}

hand

on(press) 
{
	_global.Use=true
	_global.Look=false
}

glasses

on(press)
{
	_global.Look=true
	_global.Use=false
}

Thanks for the help so far. Hopefully I can finish this soon.

Falling down laughing

BBS Signature

None

Yambanshee

Reply To Post Reply & Quote

Posted at: 11/8/09 10:40 AM

Yambanshee DARK LEVEL 11

Sign-Up: 10/05/08

Posts: 1,597

are your if statements on the main timeline in any loop or function? if not their only going to be checked once and never again

AS2||AS3||Motox
Thanks to hdxmike for the sig :]

BBS Signature

None

Cantdoright

Reply To Post Reply & Quote

Posted at: 11/8/09 11:04 AM

Cantdoright LIGHT LEVEL 11

Sign-Up: 08/07/07

Posts: 49

No there not. How do I put them into a loop/funtion?

Falling down laughing

BBS Signature

None

LeechmasterB

Reply To Post Reply & Quote

Posted at: 11/8/09 11:10 AM

LeechmasterB EVIL LEVEL 16

Sign-Up: 04/01/05

Posts: 938

I would not use globals, use a public class with static access methods instead, a "singleton".


None

Yambanshee

Reply To Post Reply & Quote

Posted at: 11/8/09 11:11 AM

Yambanshee DARK LEVEL 11

Sign-Up: 10/05/08

Posts: 1,597

for this youd probally want a enter frame (runs everything between its { and } every 1/fps seconds)
so:
function onEnterFrame () {
your code
}

AS2||AS3||Motox
Thanks to hdxmike for the sig :]

BBS Signature

Beaten

Cantdoright

Reply To Post Reply & Quote

Posted at: 11/8/09 11:12 AM

Cantdoright LIGHT LEVEL 11

Sign-Up: 08/07/07

Posts: 49

At 11/8/09 11:10 AM, LeechmasterB wrote: I would not use globals, use a public class with static access methods instead, a "singleton".

ummm... huh? singleton, static access methods? Sry im still new to AS. Also I just relized that I forgot to say this is in AS2, if that changes anything.

Falling down laughing

BBS Signature

None

Cantdoright

Reply To Post Reply & Quote

Posted at: 11/8/09 12:07 PM

Cantdoright LIGHT LEVEL 11

Sign-Up: 08/07/07

Posts: 49

At 11/8/09 11:11 AM, Yambanshee wrote: for this youd probally want a enter frame (runs everything between its { and } every 1/fps seconds)
so:
function onEnterFrame () {
your code
}

WooHoo! Thank You so much it now works now! Here is the final Demoill post. It showcases all the code I am going to be useing. Thanks for the help!

I think posting the code for this would take up quite a bit of space, but if anyone wants it, just PM me and ill send it your way.

Falling down laughing

BBS Signature

All times are Eastern Standard Time (GMT -5) | Current Time: 10:57 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!