Ask a Question related to Macromedia Flash Actionscript, Design and Development.
-
tsetliff webforumsuser@macromedia.com #1
Case Statement
HI All,
I use Macromedia Director and often use case statements
so that I don't have to have a separate script for each button.
An Example in Director:
property pMember
// sets pMember property
on beginSprite me
pMember=sprite(me.spriteNum).member
end
// Identifies the sprite object - similar to one item on a layer in Flash
on mouseUp me
case (pMember).name of
"a":
go to "start"
// Identifies the button "a" and sends the user to frame label "start"
"b":
go to "end"
// Identifies the button "b" and sends the user to frame label "end"
otherwise
nothing
end case
end
I've searched diligently but haven't been able to find something similar in Flash.
Thanks in advance for any help!
Tim
tsetliff webforumsuser@macromedia.com Guest
-
sql select case statement
Hi, Im trying to put together a sql select case statement for coldfusion - can anyone please check over my code and see if i am going along the... -
List in case statement
Is there a way to use a list in a case statement? Can I substitute myList = in the case statement below? case(myVar) of 1, 4, 6, 9, 11: put... -
#23026 [Com]: Make Zend case-sensitive (classes, functions, remove case-insensitive)
ID: 23026 Comment by: nvivo at mandic dot com dot br Reported By: mfischer@php.net Status: Open Bug Type: ... -
Problems with CASE statement
Helpful folks, I seem to be misunderstanding the use of the CASE statement as used within a WHERE clause. I had thought that one could do the... -
CASE statement and CONTAINS
Hello, Is it possible to add a 'contains' clause to the 'case' command? I know I can do this: case variableName OF "foo": doThis() end case -
PierreAlain #2
Re: Case Statement
in Flash <switch>
switch ( Value ){
case 0 : ....
break;
case 1 :.....
--
Pierre Alain
[email]pie@lifnet.com[/email]
"tsetliff" <webforumsuser@macromedia.com> a écrit dans le message de
news:bvrka4$8ns$1@forums.macromedia.com...in Flash.> HI All,
>
> I use Macromedia Director and often use case statements
> so that I don't have to have a separate script for each button.
> An Example in Director:
> property pMember
> // sets pMember property
>
> on beginSprite me
> pMember=sprite(me.spriteNum).member
> end
> // Identifies the sprite object - similar to one item on a layer in Flash
>
> on mouseUp me
> case (pMember).name of
> "a":
> go to "start"
> // Identifies the button "a" and sends the user to frame label "start"
> "b":
> go to "end"
> // Identifies the button "b" and sends the user to frame label "end"
> otherwise
> nothing
> end case
> end
>
> I've searched diligently but haven't been able to find something similar>
> Thanks in advance for any help!
>
> Tim
>
>
PierreAlain Guest
-
Tim A. Setliff #3
Re: Case Statement
HI Pierre,
I'm not sure how to use this. After case - you put "0" - is that the button
name?
do you put the action after that ":" where you put the "...."?
What is the purpose of "break"?
Thanks,
TFlash>
> switch ( Value ){
> case 0 : ....
> break;
> case 1 :.....
>
> --
>
> Pierre Alain
>
> [email]pie@lifnet.com[/email]
>
>
> "tsetliff" <webforumsuser@macromedia.com> a écrit dans le message de
> news:bvrka4$8ns$1@forums.macromedia.com...> > HI All,
> >
> > I use Macromedia Director and often use case statements
> > so that I don't have to have a separate script for each button.
> > An Example in Director:
> > property pMember
> > // sets pMember property
> >
> > on beginSprite me
> > pMember=sprite(me.spriteNum).member
> > end
> > // Identifies the sprite object - similar to one item on a layer in> in Flash.> >
> > on mouseUp me
> > case (pMember).name of
> > "a":
> > go to "start"
> > // Identifies the button "a" and sends the user to frame label "start"
> > "b":
> > go to "end"
> > // Identifies the button "b" and sends the user to frame label "end"
> > otherwise
> > nothing
> > end case
> > end
> >
> > I've searched diligently but haven't been able to find something similar>> >
> > Thanks in advance for any help!
> >
> > Tim
> >
> >
>
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system ([url]http://www.grisoft.com[/url]).
Version: 6.0.572 / Virus Database: 362 - Release Date: 1/27/2004
Tim A. Setliff Guest
-
PierreAlain #4
Re: Case Statement
hum, in fact I always used it with numeric value. Have to try with text.
the <break;> is to make it jump to the end without testing other values.
example (with numbers, you will have to try with chars :-)
buttonNumber = parseint( callingButton.substr( callingButton.lenght-2), 10);
// lets suppose I received a call from a button sending its name, witch ends
buy a number)
switch ( ButtonNumber ){
case 0 : trace( "my button 0 has called"); break;
case 1 : trace( "my button 1 has called"); break;
case 2 : trace( "my button 2 has called"); break;
default : trace("I haven't set a call for " + ButtonNumber);
}
hope that helps
--
Pierre Alain
[email]pie@lifnet.com[/email]
"Tim A. Setliff" <tsetliff@earthlink.net> a écrit dans le message de
news:bvrupg$jl4$1@forums.macromedia.com...button> HI Pierre,
>
> I'm not sure how to use this. After case - you put "0" - is that thesimilar> name?
> do you put the action after that ":" where you put the "...."?
> What is the purpose of "break"?
>
> Thanks,
> T> Flash> >
> > switch ( Value ){
> > case 0 : ....
> > break;
> > case 1 :.....
> >
> > --
> >
> > Pierre Alain
> >
> > [email]pie@lifnet.com[/email]
> >
> >
> > "tsetliff" <webforumsuser@macromedia.com> a écrit dans le message de
> > news:bvrka4$8ns$1@forums.macromedia.com...> > > HI All,
> > >
> > > I use Macromedia Director and often use case statements
> > > so that I don't have to have a separate script for each button.
> > > An Example in Director:
> > > property pMember
> > > // sets pMember property
> > >
> > > on beginSprite me
> > > pMember=sprite(me.spriteNum).member
> > > end
> > > // Identifies the sprite object - similar to one item on a layer in> > >
> > > on mouseUp me
> > > case (pMember).name of
> > > "a":
> > > go to "start"
> > > // Identifies the button "a" and sends the user to frame label "start"
> > > "b":
> > > go to "end"
> > > // Identifies the button "b" and sends the user to frame label "end"
> > > otherwise
> > > nothing
> > > end case
> > > end
> > >
> > > I've searched diligently but haven't been able to find something>> > in Flash.> >> > >
> > > Thanks in advance for any help!
> > >
> > > Tim
> > >
> > >
> >
>
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system ([url]http://www.grisoft.com[/url]).
> Version: 6.0.572 / Virus Database: 362 - Release Date: 1/27/2004
>
>
PierreAlain Guest
-
Jeckyl #5
Re: Case Statement
> What is the purpose of "break"?
Try reading the help files on the switch statement.
It is all explained there with examples etc. It would help if people read
the docs before asking questions about things that are already well
documented. Grrr.
Jeckyl Guest
-
tsetliff webforumsuser@macromedia.com #6
Re: Case Statement
In response to the last post, since you've wasted the space with a rebuke that provided no useful information, I will respond. I did read the documentation, I was asking for a clarification since Lingo and Action Script are similar but quite different!
Get a life and stop wasting everyone's time by trying to be a room monitor!
tsetliff webforumsuser@macromedia.com Guest
-
tsetliff webforumsuser@macromedia.com #7
Re: Case Statement
Hi Pierre,
I am trying your code and not getting it to work.
I copied and pasted the script into a frame.
I labeled the buttons: 0,1,2.
I don't have a clue as what to do now.
Thanks again for the information!
Tim
tsetliff webforumsuser@macromedia.com Guest
-
PierreAlain #8
Re: Case Statement
here is a function srite from one of my menu :
----------------------------------------
function bouton_HT_numero(objet_in){
var objet = string(objet_in);
var L = objet.length;
var Numero = 999;
for ( var i=objet.length-1; i > 0; i-- ){
var M = parseInt(objet.substr(i,10));
if ( M > -1 ) {
Numero = M;
}
else
{
return Numero;
}
}
return Numero;
}
//------------------------------------------------------------
function bouton_HT_init(objet){
var Numero = bouton_HT_numero(objet);
switch ( Numero ){
case 1 : objet.btn_init( "mon texte 1");
break;
case 2 : objet.btn_init( "et le texte 2");
break;
case 3 : objet.btn_init( "voilà le 3");
break;
default : // objet.btn_init( "");
// juste pour les tests
objet.btn_init( "bouton "+Numero);
}
}
-----------------------------------
my buttons instances are called <bouton1>, <bouton2>....<bouton919>;
telle me if it is clearer like that. The <bouton_HT_init() is called from
inside the button once instancied (last instruction) with this syntax :
_root.bouton_HT_init(this);
--
Pierre Alain
[email]pie@lifnet.com[/email]
"tsetliff" <webforumsuser@macromedia.com> a écrit dans le message de
news:bvtdoc$c8s$1@forums.macromedia.com...> Hi Pierre,
>
> I am trying your code and not getting it to work.
> I copied and pasted the script into a frame.
> I labeled the buttons: 0,1,2.
>
> I don't have a clue as what to do now.
>
> Thanks again for the information!
>
> Tim
>
>
PierreAlain Guest
-
Jeckyl #9
Re: Case Statement
What's the point of responding with information that is already right in
front of your face if you simply look in the actionscript docs.
Try helping your self rather than wanting to be spoon fed information. Its
not that hard.
monitor!> Get a life and stop wasting everyone's time by trying to be a room
Stop wasting everyone else's time by asking questions that you already have
answer for.
Jeckyl Guest
-
PierreAlain #10
Re: Case Statement
you said :
Sorry having tried to help some users. Seems that your field. bye> monitor!> > Get a life and stop wasting everyone's time by trying to be a room
--
Pierre Alain
[email]pie@lifnet.com[/email]
"Jeckyl" <jeckyl@hyde.com> a écrit dans le message de
news:bvug3e$o0$1@forums.macromedia.com...Its> What's the point of responding with information that is already right in
> front of your face if you simply look in the actionscript docs.
>
> Try helping your self rather than wanting to be spoon fed information.have> not that hard.
>> monitor!> > Get a life and stop wasting everyone's time by trying to be a room
>
> Stop wasting everyone else's time by asking questions that you already> answer for.
>
>
PierreAlain Guest



Reply With Quote

