Mailing List
Home
Forum Home
Flash Pro
Subjects
Firework Effect
setInterval bug identified and fixed
setInterval bug identified and fixed
ScrollPane component doesn 't auto update
Help: MX 2004 How to script a print button to print the entire sli
Event Dispatcher between classes
memory management removeMovieClip /
MX2004 Dataset itemClassName
Order of events per frame
XML to Object help
Textfield prototype question
Flash and QuickTime VR
Reading and displaying RSS feeds in Flash MX
Flash MX 2004 Sucks
AW: [Flashcoders] Switch/Case vs If/else
AW: [Flashcoders] Switch/Case vs If/else
Flash Interface with 10mb xml file
Web Service Results
Listener Object 's best practice
 
FW:

FW:

2004-02-18       - By Lord, Susan Ms.

 Back
I had taken this conversation offline, but this was such good advice, I wanted
to post it!  Thanks again Jesse for all of your help!

-- --Original Message-- --
From: Jesse Warden [mailto:warden@(protected)]
Sent: Wednesday, February 18, 2004 2:55 PM
To: Lord, Susan Ms.
Subject: RE:


First, yeah, check the 3rd parameter:

attachMovie(getRandomSymbol2(), "mc2", 0);

0 is the zDepth, or stacking order.  Only one movie clip can ever be present at
any given level.  What us lazy programmers do is:

depth = -1;

depth++;
attachMovie(getRandomSymbol2(), "mc" + depth, depth);
depth++;
attachMovie(getRandomSymbol2(), "mc" + depth, depth);
depth++;
attachMovie(getRandomSymbol2(), "mc" + depth, depth);

Now, Flash is weird in that you can have symbols named the same, but your never
allowed to to have 2 movie clips in teh same depth.  Using a forever
incrementing depth variable, you'll never run out of room... unless it hits
like 3 billion or something (I think that's the highest Flash can do), but that
will like never happen.

As far as keeping what they hit, modify this slighty:

function showRandomSymbol(){
       mc1.removeMovieClip();
       mc2.removeMovieClip();
       sym2 = getRandomSymbol2();
       sym1 = getRandomSymbol1();
       attachMovie(getRandomSymbol2(), "mc2", 0);
       attachMovie(getRandomSymbol1(), "mc1", 0);
       mc1._y = 165;
       mc1._x = 125;
       mc2._y = 165;
       mc2._x = 245;
}

Notice how I did't preced "sym2" and 1 with "var"?  var, when put in front of a
variable in a function, makes it local, meaning that after the function is done
running, it dies.

function test(){
  var cow = "moo";
  trace(cow); // moo
}
trace(cow); // undefined

However, since I didn't preced it with var, it's now global, so the latest
symbol gotten is kept in sym1 and sym2.

Hope that helps!




-- --Original Message-- --
From: Lord, Susan Ms. [mailto:susan.lord@(protected)]
Sent: Wednesday, February 18, 2004 02:47 PM
To: warden@(protected)
Subject:



Hey there Jesse,

Sorry to bug you again... I have 2 more quick questions.  I attempted to add a
new slot.  Below is the code.  Basically, in the attachMovie portion, the 2nd
attach movie is the only one that works.  So, if I switch the positions of
attaching mc1 and mc2, only the latter shows up.  Any ideas on that one?  I
imagine it is a weird flash thing.

Also, for my 3rd slot, when I add it, there is a dependency based what the
student gets for the 2nd slot.  Is there any way to capture the symbol name
getRandomSymbol returns in a variable?

Susan

-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------
-- ---- -----

stop()

slot1 = ["S1_car", "S1_foot"];
slot2 = ["S2_Binoculars", "S2_NoBinoculars"]

function getRandomSymbol1(){
       var howMany1 = slot1.length;
       return slot1[Math.floor(Math.random() * howMany1)];
       
}

function getRandomSymbol2(){
       var howMany2 = slot2.length;
       return slot2[Math.floor(Math.random() * howMany2)];
       
}

function showRandomSymbol(){
       mc1.removeMovieClip();
       mc2.removeMovieClip();
       attachMovie(getRandomSymbol2(), "mc2", 0);
       attachMovie(getRandomSymbol1(), "mc1", 0);
       mc1._y = 165;
       mc1._x = 125;
       mc2._y = 165;
       mc2._x = 245;
}

lever1_btn.onRelease = function() {
       showRandomSymbol();
       gotoAndPlay(lever1_btn);
       trace("lever 1 clicked");
}




<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859 (See http://iso-8859.ora-code.com)-1">
<TITLE>Message</TITLE>

<META content="MSHTML 6.00.2800.1400" name=GENERATOR></HEAD>
<BODY>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN class=687091620-18022004>I had
taken this conversation offline, but this was such good advice, I wanted to
post
it!&nbsp; Thanks again Jesse for all of your help!</SPAN></FONT></DIV><BR>
<DIV></DIV>
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left><FONT face=Tahoma
size=2>-- --Original Message-- --<BR><B>From:</B> Jesse Warden
[mailto:warden@(protected)] <BR><B>Sent:</B> Wednesday, February 18, 2004
2:55 PM<BR><B>To:</B> Lord, Susan Ms.<BR><B>Subject:</B> RE:
<BR><BR></FONT></DIV>
<DIV><SPAN class=261454819-18022004><FONT face=Arial color=#0000ff size=2>First
,
yeah, check the 3rd parameter:</FONT></SPAN></DIV>
<DIV><SPAN class=261454819-18022004><FONT face=Arial color=#0000ff
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=261454819-18022004><FONT face=Arial
size=2>attachMovie(getRandomSymbol2(), "mc2", 0);<FONT face="Times New Roman"
size=3> </FONT></FONT></SPAN></DIV>
<DIV><SPAN class=261454819-18022004></SPAN>&nbsp;</DIV>
<DIV><SPAN class=261454819-18022004><FONT face=Arial color=#0000ff size=2>0 is
the zDepth, or stacking order.&nbsp; Only one movie clip can ever be present at
any given level.&nbsp; What us lazy programmers do is:</FONT></SPAN></DIV>
<DIV><SPAN class=261454819-18022004><FONT face=Arial color=#0000ff
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=261454819-18022004><FONT face=Arial color=#0000ff size=2>depth
= -1;</FONT></SPAN></DIV>
<DIV><SPAN class=261454819-18022004><FONT face=Arial color=#0000ff
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=261454819-18022004><FONT face=Arial color=#0000ff
size=2>depth++;</FONT></SPAN></DIV>
<DIV><SPAN class=261454819-18022004><FONT face=Arial size=2><SPAN
class=261454819-18022004><FONT face=Arial size=2>attachMovie(getRandomSymbol2()
,
"mc" + depth, depth);<FONT face="Times New Roman" size=3>
</FONT></FONT></SPAN></FONT></SPAN></DIV>
<DIV><SPAN class=261454819-18022004><FONT face=Arial color=#0000ff size=2><SPAN
class=261454819-18022004>depth++;</SPAN></FONT></SPAN></DIV>
<DIV><SPAN class=261454819-18022004><FONT face="Times New Roman" size=3><SPAN
class=261454819-18022004><SPAN class=261454819-18022004><FONT face=Arial
size=2><SPAN class=261454819-18022004><FONT face=Arial
size=2>attachMovie(getRandomSymbol2(), "mc" + depth, depth);<FONT
face="Times New Roman" size=3>
</FONT></FONT></SPAN></FONT></SPAN></SPAN></FONT></SPAN></DIV>
<DIV><SPAN class=261454819-18022004><FONT size=+0><SPAN
class=261454819-18022004><SPAN class=261454819-18022004><FONT face=Arial
color=#0000ff size=2><SPAN
class=261454819-18022004>depth++;</SPAN></FONT></SPAN></SPAN></FONT></SPAN><
/DIV>
<DIV><SPAN class=261454819-18022004><FONT face="Times New Roman" size=3><SPAN
class=261454819-18022004><SPAN class=261454819-18022004><FONT
face="Times New Roman" size=3><SPAN class=261454819-18022004><SPAN
class=261454819-18022004><FONT face=Arial size=2><SPAN
class=261454819-18022004><FONT face=Arial size=2>attachMovie(getRandomSymbol2()
,
"mc" + depth, depth);<FONT face="Times New Roman" size=3>
</FONT></FONT></SPAN></FONT></SPAN></SPAN></FONT></SPAN></SPAN></FONT></SPAN><
/DIV>
<DIV><SPAN class=261454819-18022004><FONT face="Times New Roman" size=3><SPAN
class=261454819-18022004><SPAN class=261454819-18022004><FONT
face="Times New Roman" size=3><SPAN class=261454819-18022004><SPAN
class=261454819-18022004><FONT face="Times New Roman" size=3><SPAN
class=261454819-18022004></SPAN></FONT></SPAN></SPAN></FONT></SPAN></SPAN><
/FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=261454819-18022004><FONT size=+0><SPAN
class=261454819-18022004><SPAN class=261454819-18022004><SPAN
class=261454819-18022004><SPAN class=261454819-18022004><FONT face=Arial
color=#0000ff size=2><SPAN class=261454819-18022004>Now, Flash is weird in that
you can have symbols named the same, but your never allowed to to have 2 movie
clips in teh same depth.&nbsp; Using a forever incrementing depth variable,
you'll never run out of room... unless it hits like 3 billion or something (I
think that's the highest Flash can do), but that will like never
happen.</SPAN></FONT></SPAN></SPAN></SPAN></SPAN></FONT></SPAN></DIV>
<DIV><SPAN class=261454819-18022004><FONT size=+0><SPAN
class=261454819-18022004><SPAN class=261454819-18022004><SPAN
class=261454819-18022004><SPAN class=261454819-18022004><FONT face=Arial
color=#0000ff size=2><SPAN
class=261454819-18022004></SPAN></FONT></SPAN></SPAN></SPAN></SPAN></FONT><
/SPAN>&nbsp;</DIV>
<DIV><SPAN class=261454819-18022004><FONT size=+0><SPAN
class=261454819-18022004><SPAN class=261454819-18022004><SPAN
class=261454819-18022004><SPAN class=261454819-18022004><FONT face=Arial
color=#0000ff size=2><SPAN class=261454819-18022004>As far as keeping what they
hit, modify this
slighty:</SPAN></FONT></SPAN></SPAN></SPAN></SPAN></FONT></SPAN></DIV>
<DIV><SPAN class=261454819-18022004><FONT size=+0><SPAN
class=261454819-18022004><SPAN class=261454819-18022004><SPAN
class=261454819-18022004><SPAN class=261454819-18022004><FONT face=Arial
color=#0000ff size=2><SPAN
class=261454819-18022004></SPAN></FONT></SPAN></SPAN></SPAN></SPAN></FONT><
/SPAN>&nbsp;</DIV>
<DIV><SPAN class=261454819-18022004><FONT size=+0><SPAN
class=261454819-18022004><SPAN class=261454819-18022004><SPAN
class=261454819-18022004><SPAN class=261454819-18022004><FONT size=+0><SPAN
class=261454819-18022004>
<P><FONT size=2><FONT face=Arial><FONT color=#0000ff>function
showRandomSymbol(){ <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
mc1.removeMovieClip(); <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
mc2.removeMovieClip();<BR><SPAN
class=261454819-18022004>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sym2 =
getRandomSymbol2();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sym1
=&nbsp;getRandomSymbol1();</SPAN></FONT></FONT></FONT><FONT
size=2><BR></FONT><FONT face=Arial color=#0000ff
size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
attachMovie(getRandomSymbol2(), "mc2", 0);
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; attachMovie(getRandomSymbol1(),
"mc1", 0); <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; mc1._y = 165;
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; mc1._x = 125;
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; mc2._y = 165;
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; mc2._x = 245; <BR>} </FONT></P>
<P><SPAN class=261454819-18022004><FONT face=Arial color=#0000ff size=2>Notice
how I did't preced "sym2" and 1 with "var"?&nbsp; var, when put in front of a
variable in a function, makes it local, meaning that after the function is done
running, it dies.</FONT></SPAN></P>
<P><SPAN class=261454819-18022004><FONT face=Arial color=#0000ff size=2
>function
test(){<BR>&nbsp;&nbsp; var cow = "moo";<BR>&nbsp;&nbsp; trace(cow); //
moo<BR>}<BR>trace(cow); // undefined</FONT></SPAN></P>
<P><FONT face=Arial><FONT color=#0000ff><FONT size=2><SPAN
class=261454819-18022004>However, since I didn't preced it with var, it's now
global, so the latest symbol gotten is kept in sym1 and sym2.<SPAN
class=687091620-18022004>&nbsp;</SPAN></SPAN></FONT></FONT></FONT></P>
<P><FONT face=Arial><FONT color=#0000ff><FONT size=2><SPAN
class=261454819-18022004>Hope that
helps!</SPAN></FONT></FONT></FONT></P></SPAN></FONT></SPAN></SPAN></SPAN></SPAN
></FONT></SPAN></DIV>
<DIV><SPAN class=261454819-18022004><FONT size=+0><SPAN
class=261454819-18022004><SPAN class=261454819-18022004><SPAN
class=261454819-18022004><SPAN class=261454819-18022004><FONT face=Arial
color=#0000ff size=2><SPAN
class=261454819-18022004></SPAN></FONT></SPAN></SPAN></SPAN></SPAN></FONT><
/SPAN>&nbsp;</DIV>
<DIV><SPAN class=261454819-18022004><FONT size=+0><SPAN
class=261454819-18022004><SPAN class=261454819-18022004><SPAN
class=261454819-18022004><SPAN class=261454819-18022004><FONT face=Arial
color=#0000ff size=2><SPAN
class=261454819-18022004></SPAN></FONT></SPAN></SPAN></SPAN></SPAN></FONT><
/SPAN>&nbsp;</DIV>
<BLOCKQUOTE style="MARGIN-RIGHT: 0px">
 <DIV></DIV>
 <DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left><FONT
 face=Tahoma size=2>-- --Original Message-- --<BR><B>From:</B> Lord, Susan Ms.
 [mailto:susan.lord@(protected)] <BR><B>Sent:</B> Wednesday, February 18,
 2004 02:47 PM<BR><B>To:</B> warden@(protected)<BR><B>Subject:</B>
 <BR><BR></FONT></DIV><!-- Converted from text/rtf format -->
 <P><FONT face=Arial size=2>Hey there Jesse,</FONT> </P>
 <P><FONT face=Arial size=2>Sorry to bug you again... I have 2 more quick
 questions.&nbsp; I attempted to add a new slot.&nbsp; Below is the code.&nbsp
;
 Basically, in the attachMovie portion, the 2nd attach movie is the only one
 that works.&nbsp; So, if I switch the positions of attaching mc1 and mc2,
only
 the latter shows up.&nbsp; Any ideas on that one?&nbsp; I imagine it is a
 weird flash thing.</FONT></P>
 <P><FONT face=Arial size=2>Also, for my 3rd slot, when I add it, there is a
 dependency based what the student gets for the 2nd slot.&nbsp; Is there any
 way to capture the symbol name getRandomSymbol returns in a
 variable?</FONT></P>
 <P><FONT face=Arial size=2>Susan</FONT> </P>
 <P><FONT face=Arial
 size=2>-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --
-- ---- ---- ---- ----</FONT>
 </P>
 <P><FONT face=Arial size=2>stop()</FONT> </P>
 <P><FONT face=Arial size=2>slot1 = ["S1_car", "S1_foot"];</FONT> <BR><FONT
 face=Arial size=2>slot2 = ["S2_Binoculars", "S2_NoBinoculars"]</FONT> </P>
 <P><FONT face=Arial size=2>function getRandomSymbol1(){</FONT>
 <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT face=Arial size=2>var
 howMany1 = slot1.length;</FONT> <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp
;
 <FONT face=Arial size=2>return slot1[Math.floor(Math.random() *
 howMany1)];</FONT> <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR><FONT
 face=Arial size=2>}</FONT> </P>
 <P><FONT face=Arial size=2>function getRandomSymbol2(){</FONT>
 <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT face=Arial size=2>var
 howMany2 = slot2.length;</FONT> <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp
;
 <FONT face=Arial size=2>return slot2[Math.floor(Math.random() *
 howMany2)];</FONT> <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR><FONT
 face=Arial size=2>}</FONT> </P>
 <P><FONT face=Arial size=2>function showRandomSymbol(){</FONT>
 <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT face=Arial
 size=2>mc1.removeMovieClip();</FONT>
 <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT face=Arial
 size=2>mc2.removeMovieClip();</FONT>
 <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT face=Arial
 size=2>attachMovie(getRandomSymbol2(), "mc2", 0);</FONT>
 <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT face=Arial
 size=2>attachMovie(getRandomSymbol1(), "mc1", 0);</FONT>
 <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT face=Arial size=2>mc1._y
 = 165;</FONT> <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT face=Arial
 size=2>mc1._x = 125;</FONT> <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 <FONT face=Arial size=2>mc2._y = 165;</FONT>
 <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT face=Arial size=2>mc2._x
 = 245;</FONT> <BR><FONT face=Arial size=2>}</FONT> </P>
 <P><FONT face=Arial size=2>lever1_btn.onRelease = function() {</FONT>
 <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT face=Arial
 size=2>showRandomSymbol();</FONT>
 <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT face=Arial
 size=2>gotoAndPlay(lever1_btn);</FONT>
 <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT face=Arial
 size=2>trace("lever 1 clicked");</FONT> <BR><FONT face=Arial size=2>}</FONT>
 </P><BR><BR></BLOCKQUOTE></BODY></HTML>