Using a "shuffle" function to randomize an array?

Hi, for some reason when the line of code "koan.shuffle();" is commented out swfs called "koan_1.swf" or "koan_2.swf" etc are loaded properly into a "koan_loader_mc" on the stage, albeit not randomized.  (Each "koan_#.swf" has code in its last frame to both advance the "shuffle" array in the action script in the first frame of the stage and to load the next koan swf.)   Why does "koan.shuffle();" not only fail to randomize the array, but, break the entire loading process? 
Frame on main stage:
// creates function called at the end of koan_#.swfs
function shuffle(a:Array) {
for (var ivar = a.length-1; ivar>=0; ivar--) {
var p = Math.floor(Math.random())(ivar+1);
var t = a[ivar];
a[ivar] = a[p];
a[p] = t;
This code loads swfs (but they are not randomized/shuffled):
var index:uint = 0;
var koan_loader:Loader = new Loader();
var koan:Array =["swfs/koans/koan_1.swf","swfs/koans/koan_2.swf", "swfs/koans/koan_3.swf", "swfs/koans/koan_4.swf", "swfs/koans/koan_5.swf", "swfs/koans/koan_6.swf", "swfs/koans/koan_7.swf", "swfs/koans/koan_8.swf", "swfs/koans/koan_9.swf", "swfs/koans/koan_10.swf", "swfs/koans/koan_11.swf", "swfs/koans/koan_12.swf"];
//koan.shuffle();
koan_loader.load(new URLRequest(koan[index]));
MovieClip(this).koan_loader_mc.addChild(koan_loader);
Thanks (this is a clarified question from a previous post now marked as answered)

because shuffle() is a function, not an array method:
// creates function called at the end of koan_#.swfs
function shuffle(a:Array) {
for (var ivar = a.length-1; ivar>=0; ivar--) {
var p = Math.floor(Math.random())(ivar+1);
var t = a[ivar];
a[ivar] = a[p];
a[p] = t;
This code loads swfs (but they are not randomized/shuffled):
var index:uint = 0;
var koan_loader:Loader = new Loader();
var koan:Array =["swfs/koans/koan_1.swf","swfs/koans/koan_2.swf", "swfs/koans/koan_3.swf", "swfs/koans/koan_4.swf", "swfs/koans/koan_5.swf", "swfs/koans/koan_6.swf", "swfs/koans/koan_7.swf", "swfs/koans/koan_8.swf", "swfs/koans/koan_9.swf", "swfs/koans/koan_10.swf", "swfs/koans/koan_11.swf", "swfs/koans/koan_12.swf"];
shuffle(koan);
koan_loader.load(new URLRequest(koan[index]));
MovieClip(this).koan_loader_mc.addChild(koan_loader);
Thanks (this is a clarified question from a previous post now marked as answered)

Similar Messages

  • How can i set songs within a playlist, or an entire playlist, so that they are not included when using the shuffle function on IPOD Classic? Is this possible?

    How can i set songs within a playlist, or an entire playlist, so that they are not included when using the shuffle function on IPOD Classic?
    Is this possible?

    You can set any song to Skip when shuffling.
    In your iTunes Library, highlight the song and right-click/Get Info. On the Options tab is the Skip when shuffling box. Select that and then Sync the iPod with your Library.

  • The 'Shuffle' function on my iPod Classic not longer works on my iPod or in my vehicle.  It worked prior to syncing in iTunes using my Macbook.  Now I can only play music sequentially.  Can anyone assist?

    The 'Shuffle' function on my iPod Classic no longer works on my iPod or in my vehicle (2012 Acura TL).  It worked prior to syncing in iTunes using my MacbookPr .Now I can only play music sequentially.  Can anyone assist?

    Reset or restore the device.
    tt2

  • Shuffle function on iPod with iTune Match

    Hello:
    I have just activated iTune Match. now I have the same playlists on all my devides, however, I am not able to deactivete the "Shuffle" function on thw iPod touch. I can on both the PC and the iPad but I do not know how to do it on the iPod. It is a problem as I use the iPod for spinning and I need to play the songs in sequantial order. Thanks

    You can set any song to Skip when shuffling.
    In your iTunes Library, highlight the song and right-click/Get Info. On the Options tab is the Skip when shuffling box. Select that and then Sync the iPod with your Library.

  • IPod nano 7G issues with shuffle function

    Dear all,
    I just bought a 7G iPod nano. Altogether it's great but I have a couple of issues I would like to comment with you:
    1. I sometimes use the "shake to shuffle" function, but when I go and turn it OFF, the shuffle function still remains (although not in the "shake" mode), and I must turn it off manually by tapping on the screen while a song is playing, and de-selecting it. Does this happen to you?
    2. When I pair the iPod nano 7G to my car through bluetooth, after listening to any album up until the end, it then suddenly pauses, then starts playing again but in a shuffle mode, without me having done or touched anything. So after the end of any album, it just turns on the shuffle mode automatically. My car stereo system is a 2012 Mercedes Benz Audio 20 system, which has both A2DP and AVRCP profiles. Has anyone experienced something similar?
    It's sounded like fun to listen to the iPod wirelessly in the car, but I must say that the bluetooth functionalities are so limited (play, stop, next track, last track) that it quicly becomes quite boring. I wish it had all the browsing controls like when you plug it in...Any comments?
    Thanks a lot in advance for you help with these issues,
    CCCP

    im having the same problem. I drive a 203 c class with audio 20 and for some reason the media interface wont sync with my ipod. The bluetooth works fine but when i try to plug it via the media interface cables, it only charges....

  • Using call library function on a dll file created in an old version of labview

    So I'm trying to update an old labview program to work in labview 2012. Everything converted over just fine but labview will always crashoverwrote some while using a  library function in a DLL that was compiled using labview 8.5. Labview exits, stating that it vital memory area. It passes an array of data to the library call and an empty array for output. I thought I could get around this problem by changing my code to initialize the array being passed in so that it would be large enough to hold all the expected output. Now instead of overwritting areas of memory it shouldn't, I get a pop up message that says:
    fatal internal error
    memorymanager.cpp line 406
    8.5.1.f5 
    So it appears because I don't have the ability to recompile the DLL file it runs off of the 8.5 runtime instead of the more recent one. Is there any thing I can do about this?

    rjpierce wrote:
    So I've been trying to figure out a way around this on my own while waiting on a response. From what I'm reading, a dll created in one version of the labview runtime can't be used by a different labview runtime. Am I correct in this? I feel like I must be mistaken since that's basically the opposite of how a dll should work. If nothing else works I have access to the original code for the DLL but it requires the control and simulation toolkit. I would like to avoid having to recompile the DLL since it was put in to a DLL to avoid the need for the toolkit to begin with. 
    Your problem most likely is that you try to pass native datatypes to the DLL function? That only can work if the caller and callee use the same LabVIEW runtime engine. Otherwise the memory block created in the memory manager of the caller will be accessed by the memory manager in the callee and bad things happen. Instead you should define the DLL function to use standard C datatypes (Pointer to C array) and also make sure to allocate the according buffer in the caller for all output array parameters.
    An even more elegant way would be to completely abandon the DLL approach and call the according functions directly in LabVIEW. Then you won't have the problems about mismatched runtime engines. Passing C array pointers to a DLL is less performant than passing native datatypes, but if you use native datatypes you have to make sure the DLL is compiled in the same LabVIEW version as the one you call it from.
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • How to use  Advance java function in graphical mapping in XI 2.0?

    Hi,
    currently I am using a simple java function to make an RFC call to R3 system.
    I want to avoid making connection for each lookup. Instead I want to make a single connection for whole message queue and get the corresponding values in some array or container object.
    please suggest a solution.
    I think this is possible using Advance java function, but I am not able to find any example on using Advance java function at help.sap.com.
    thaks in advance.

    Hi!!!
    I'm not sure if I understood you well.
    Do you want to preload some data into your structures in the memory and keep them there so you don't need to make a new connection during processing the whole message or every message?
    In my opinion you can cache some data during processing a message, but it's impossible to cache some data between processing messages.
    If you write your java mapping or you use graphical mapping (even with user-defined function), then you have a java class. The problem is that XI 2.0 reloads this class during processing every message, so even if you load some data from your data source into your structures in the memory, this data will be lost after reloading your mapping class.
    Regards,
    Andrzej Filusz

  • Using the SVDEx function in LabWindows​CVI

    Hello,
    I am writing an application in LabWindows CVI to display and analize data that we obtain in an optical experiment.  The data is a matrix where the subsequent rows represent spectra collected a different times. There are about 200 columns and 100 rows in each matrix. I want to use singular value decomposition using the  SVDEx function. I get an error every time i try to execute the code in debugguing mode:
    FATAL RUN-TIME ERROR:    The program has caused a 'General Protection' fault at 0x0342BC16.
    I believe that I am passing the incorrect arrays to SVDEx. I  was wondering if there is any example code available, so I can learn how tro do do this.
    Here is a fragment of the code where I call the function SVDEx:
    //declare the arrays to hold S U V
    double *U,*S,*V;
    int isizeS=Y_DATA_POINTS;
    int i;
    int AnalisisError=0;
    if (X_DATA_POINTS<Y_DATA_POINTS) {isizeS=X_DATA_POINTS;}
    //Allocate arrays
    U=malloc(Y_DATA_POINTS*X_DATA_POINTS*sizeof(double​));
    S=malloc(2*isizeS*sizeof(double));
    V=malloc(Y_DATA_POINTS*X_DATA_POINTS*sizeof(double​));
    AnalisisError = SVDEx (adAbsMap, Y_DATA_POINTS, X_DATA_POINTS, FULL_SIZE, U, S+isizeS, V);
    FATAL RUN-TIME ERROR:   "Visualize_12.c", line 2451, col 17, thread id 0x00000E18:   The program has caused a 'General Protection' fault at 0x0342BC16.
    Any help will be very much appreciated.
    J. Hodak

    Hi,
    Thanks for trying to find an answer. I just realized now where the probem was. My mistake was when i allocated the arrays for holding the matrices. Because i was assking SVDEx to carry out FUL SIZE decomposition I must declare the arrays U and V to be , Y_DATA_POINTS*, Y_DATA_POINTS doubles and X_DATA_POINTS*, X_DATA_POINTS doubles respectively. My code was wrong, I was declaring the sizes to be smaller than necessary and  "Visualize_12.c", line 2451, was the call to SVDEx, and col 17 was pointing t that mistake. It took me a while to realize this because the error message did not exlicitly specify that the size or the array passed was too small. Now it is working well. But I believe that it will help to have an example to get started with this.
    Thanks again,
    Fundadero.

  • Memory Leak, Deallocati​ng memory after using imaqImageT​oArray() function

    I have created a program (LW/CVI- Imaq Vision), which uses a timer callback to acquire an image, convert the image to an array using the imaqImageToArray() function, manipulates the data in the array, converts the data to an image, displays the image, and disposes of the image(imaqDispose()), and apparently the imaqImageToArray() function clears the allocation pointer, however does not deallocate the memory, such that the next time the function is called again, imaq allocates new memory, thus eventually the application slows down and freezes due to lack of memory. Does anyone have any suggestions?

    Hello,
    You need to call the imaqDispose() for the assigned pointer to actually clear the allocated memory.
    iPointer = imaqImageToArray(imgInputImage,IMAQ_NO_RECT, &iCols, &iRows);
    imaqDispose (iPointer);
    Let me know if you have further questions regarding this.
    Best regards,
    Yusuf C.
    Applications Engineering
    National Instruments

  • Can I use the Shuffle over USB in a car?

    Hi all,
    Have a brand new iPod Shuffle 4th gen that I want to setup for use in a car.  Have a Nano in one car, using a USB connection...that works great.  I'm trying to do the same with a Shuffle in a different car, but with no luck.  The stereo doesn't acknowledge it's even connected.  That said, I tried connecting it with USB in my car that works with my Nano, and it also didn't work there.
    Can the Shuffle only be connected through AUX?  If I do that, I assume it has to be controlled with the Shuffle as well, and can't be controlled through the stereo (showing the music on screen)?
    (I realize some of this may be car specific, but in general, trying to find out if USB playback is just not possible).
    Thanks!
    -Mike

    When you connect ANY iPod to a car audio system using a USB connection, the iPod is acting as a storage device.  The iPod is not doing anything else.  It is not being controlled to play music.  The car audio system is only accessing the iPod's "disk," like it would access a USB flash drive that has song files on it, and the car audio system is then playing the music.
    The most likely reason it does not work with the shuffle is because the shuffle does not have a dock connector (or Lightning connector) like other iPods.  It uses the headphones jack, so there may be some missing functionality or connection points.  You should check the documentation for the car audio system to see what devices are supported.
    If you connect the shuffle with the appropriate cable to an auxiliary audio input on the car stereo, you are using the shuffle to play through the car speakers, like with any device you connect that way.
    As an alternative, you should consider getting a cheap USB flash drive, like this one that is so small that it barely sticks out of the USB port
    http://eshop.macsales.com/item/SanDisk/SDCZ33008G/
    Put your favorite songs on it, and leave it connected in the car (except when you want to change songs).  It has 4x the storage capacity of a shuffle for about $10, and there's no dangling cable.  You'll save your iPod from the wear and tear of constantly connecting and disconnecting it, plus a USB flash drive is much less susceptible to damage from extreme hot and cold compared to an iPod (especially one that has an LCD screen).

  • Shuffle-function in music player

    I recently bought the N8 and after spending a few days of tagging and downloading album art hours I finally managed to successfully transfer my mp3 library over to the phone with minimal errors occuring.
    However, one thing that gives me a headache is that I just can't figure out how to turn the shuffle playback mode off. There's a button in the music player for turning it ON, but pressing it once again does not appear to de-activate the function, and I can't find a dedicated button for turning it off. Been searching all the menues for this too, but no luck...
    Anyone got an idea how to solve this?

    Select a song using the shuffle icon, then when it is playing select options and a different menu appears, one option of which allows you to select shuffle on or off.
    History: Always Nokia since 1994 including Nokia 2140, 7110e, 6150, 6210, 6310i, 6230i, N82
    Current: Nokia N8 (Anna - I have no intention of going to Belle) - and delighted with it!

  • Random pick / shuffle function

    Hi when i have alot of episodes of a series stored in a folder it would be great to be able to do one or all of the following.
    A have the box pick a random episode from the folder.
    B a shuffle function that will hust keep playing random episodes.
    C be able to put together a play list of episodes out of a folder or a play list of programmes picked from your entire library.

    A and B
    Not sure how useful they would be as most series's are made to be watched in sequence due to story lines that are threaded throughout the series.

  • Calling DLL using "Call library function"

    I am trying to combine labview with my previous fortran functions using Intel Visual Fortran 12.1 and labview 2012 by below steps.
     1. Compile Fortran functions as DLL file.
     2. Call Fortran function from LabView via "Call library function"
    In step 2, DLL file without linker option "/DLL delayimp.lib" cannot be loaded. That is "delay load" is needed for DLL file.
    Are there any limitation or constraint in Call library function?

    Hi Vishnu,
    There's no problem using the Malloc function in C and call it as a DLL in LabVIEW.
    But LabVIEW has a different memory management than C.
    It is probably not recommended to allocate array memory in C for labVIEW arrays
    You can use initialize array in LabVIEW instead.
    Good luck
    Van L
    NI Applications Engineer

  • SAP XI - Using the substring function.

    Hi Experts,
    I am having trouble using the substring function in SAP+XI. I have to consider the value from characters 6 to 19 for a target field of 25 characters. Every time I ma using the standard substring function it is giving an error Array Out of Bounds Exception.
    Please tell me how to proceed.
    Thanks
    Aniruddha

    Hi,
    Above error wil come if the input string length is less than the substring length what you are trying to get..
    i.e length of the input string is less than 25 characters... do some validations or pass substring as 6 and 0 ..
    HTH
    Rajesh

  • Does 'Party Shuffle' function exist on iPod or only on iTunes?

    Help! I'm having a NY Eve party tomorrow and am relying on my iPod and iPod HiFi for the music. I wanted to use the Party Shuffle function but I can't see that option on my iPod menu... does it only exist in iTunes? I have never used or created playlists before, so this is all new to me. I have an old 3G iPod, not sure if this makes any difference. All help is very much appreciated!

    I have the same question. Where did you find the answer? Thanks
    PC   Windows XP Pro  

Maybe you are looking for

  • How to create a system recovery USB drive?

    My U845-S406 crashes every 15 minutes with a BSOD referencing iastor.sys. Multiple diagnostics say it is all good. Multiple virus softwares say it is clean. It crashes even quicker in safe mode. I have the latest Toshiba raid drivers, but updated to

  • Cannot open attachments with my firefox. my wife can with IE

    with firefox I cannot open attachments in my emails. I have been forwarding these emails to my wife's email. She is using internet explorer by yahoo through AT&t and then I have no trouble opening them on her email.

  • ODBC failure at siebel database configuration

    Hi all, I am installing siebel 7.8.2 in my system. I am using oracle 10g... I have installed siebel gateway name server . After siebel server installation and configuration, I was checking for ODBC connectivity as given in manual but i am getting the

  • Send email to each member of a group

    How can I send a mail to each member of a group with the Email activity? It seems I can only send the mail to the grup address...

  • Web Service WLS9.2 and WLS6.1 SOAP compatibility

    We have a Web Service (running on WLS6.1) which has been published for a long time, and many customers have developed their own clients. Now we must upgrade our Web Service from WLS6.1 to WLS9.2. In practice we had to re-develope the Web Service star