Flasher Archive

[Previous] [Next] - [Index] [Thread Index] - [Previous in Thread] [Next in Thread]

Subject: RE: [flasher] RE: Random
From: Paul Willoughby
Date: Mon, 29 Jan 2001 15:32:37 -0000

Hi Ilja,

The trick is to create a string that corresponds to the names of your MC's.
Pick a point in the string randomly, display that clip, then remove the
reference to that clip from the string by reconstructing it from all the
letters before and after the point you just picked. Here's some example code
i've used before:

15 MC's - mc_a, mc_b, mc_c...mc_o

Initilaize variables in frame 1 -

Comment: initialize
Set Variable: "rString" = "ABCDEFGHIJKLMNO"
Set Variable: "totalLength" = Length(rString)
Set Variable: "i" = 0

On (Release)
Comment: check if anything already displayed. If it is, move it
If (displayed gt "")
Set Property (displayed, X Position) = -50
Set Property (displayed, Y Position) = -50
End If
Comment: see if there are any clips left to display
If (Length(rString) <= 0)
Trace ("all have been displayed")
Comment: pick a random position in 'rString'
Set Variable: "rPos" = Random(Length(rString)) + 1
Comment: reference the clip by the letter at that position in
the string
Set Variable: "nextTarget" = "mc_" & Substring(rString, rPos,1)
Comment: move movie clip to the centre of the screen
Set Property (nextTarget, X Position) = 275
Set Property (nextTarget, Y Position) = 200
Comment: rebuild 'rString' with all the letters before and after
'rPos', but not 'rPos' itself.
Set Variable: "rString" = Substring(rString, 1, rPos-1) &
Substring(rString, rPos+1)
Comment: store the name of the MC currently displayed
Set Variable: "displayed" = nextTarget
End If
End On



> -----Original Message-----
> From: Ilja Goossens [iljaatilja [dot] com (mailto:iljaatilja [dot] com)]
> Sent: Monday, January 29, 2001 12:48 PM
> To: flasher from chinwag
> Subject: [flasher] RE: Random
> And this must be in Flash 4 b.t.w.
> ----------------------------------
> Hi
> How can I randomly display 15 MC's, without having one
> displayed multiple
> times before having seen all of the other 14 MC's?
> Ilja

[Previous] [Next] - [Index] [Thread Index] - [Next in Thread] [Previous in Thread]