Playing random movieClips onClick, then returning to start screen

Hi- I'm very new to actionScript 3. My project starts out by plying one movie clip(startPage), then onClick, moviecip startPage disappears and a random movieclip(sc01-sc03) loads and plays. Once each random movieclip plays, I want to remove it from the stage and reload startPage. I have the random part figured out using an array, but I can't figure out how to remove the random sc movieClip once it is loaded. I tried using removeChild, but Flash isn't recognizing that I have added and of the sc movieclips as childen. Help!
My current code below:
package
          import flash.display.MovieClip;
          import flash.events.MouseEvent;
          import flash.events.Event;
          public class Main extends MovieClip
                    var startPage:StartPage;
                    var sc01:Sc01;
                    var sc02:Sc02;
                    var sc03:Sc03;
                    private var _scenario:Array;
                    public function Main()
                              startPage = new StartPage();
                              sc01 = new Sc01();
                              sc02 = new Sc02();
                              sc03 = new Sc03();
                              _scenario = new Array();
                              MC.addChild(startPage);
                              //Add Scenes to array
                              _scenario[0] = sc01;
                              _scenario[1] = sc02;
                              _scenario[2] = sc03;
                              //Add Event Listeners
                              startPage.boxButton.addEventListener(MouseEvent.CLICK,onBoxButtonClick);
                              startPage.addFrameScript(startPage.totalFrames - 1, stopPageFunc);
                              sc01.addEventListener(Event.ENTER_FRAME, everyFrame01);
                              sc02.addEventListener(Event.ENTER_FRAME, everyFrame02);
                              sc03.addEventListener(Event.ENTER_FRAME, everyFrame03);
                              //stop at end of startPage timeline
                              function stopPageFunc()
                                            startPage.stop();
                              function onBoxButtonClick(event:MouseEvent):void
                                        MC.removeChild(startPage);
                                        MC.addChild(_scenario[Math.floor(Math.random()*_scenario.length)]);
                              function everyFrame01():void
                                        if (sc01.currentFrame == 50)
                                        MC.removeChild(sc01);
                                        MC.addChild(startPage);
                                        startPage.gotoAndPlay(1);
                                        else
                                        {sc01.play();
                              function everyFrame02():void
                                        if (sc02.currentFrame == 50)
                                        MC.removeChild(sc02);
                                        MC.addChild(startPage);
                                        startPage.gotoAndPlay(1);
                                        else
                                        {sc02.play();
                              function everyFrame03():void
                                        if (sc03.currentFrame == 50)
                                        MC.removeChild(sc03);
                                        MC.addChild(startPage);
                                        startPage.gotoAndPlay(1);
                                        else
                                        {sc03.play();
                    //go to startPage when scenario done

use:
package
          import flash.display.MovieClip;
          import flash.events.MouseEvent;
          import flash.events.Event;
          public class Main extends MovieClip
                    var startPage:StartPage;
                    private var _scenario:Array;
                    public function Main()
                              startPage = new StartPage();
                              _scenario = new Array();
                              MC.addChild(startPage);
                              //Add Scenes to array
                              _scenario[0] = new Sc01();
                              _scenario[1] = new Sc02();
                              _scenario[2] = new Sc03();
shuffle(_scenario);
                              //Add Event Listeners
                              startPage.boxButton.addEventListener(MouseEvent.CLICK, onBoxButtonClick);
                              startPage.addFrameScript(startPage.totalFrames - 1, stopPageFunc);
                              this.addEventListener(Event.ENTER_FRAME, everyFrame;
                              //stop at end of startPage timeline
                              function stopPageFunc()
                                            startPage.stop();
                              function onBoxButtonClick(event:MouseEvent):void
if(startPage.stage){
                                        MC.removeChild(startPage);
if(_scenario.length>0){
                                        MC.addChild(_scenario[0]);
                              function everyFrame():void
if(_scenario[0].currentFrame==_scenario[0].totalFrames){
MC.removeChild(_scenario[0]);
_scenario.shift();
if(_scenario.length==0){
// startPage.gotoAndPlay(1); ???
MC.addChild(startPage);
function shuffle(a:Array) {
    var i:int;
    var j:int;
    var e:*;
    var len:int = a.length;
    for (i = len-1; i>=0; i--) {
        j=Math.floor((i+1)*Math.random());
        e = a[i];
        a[i] = a[j];
        a[j] = e;

Similar Messages

  • After typing login password at login screen osx lion attempts to login then returns to login screen

    after typing login password at login screen osx lion attempts to login then returns to login screen, any ideas?

    While we all have MacBooks in this forum most of us don’t run Lion. There's a Lion Support Community where everybody has Lion. You should also post this question there to increase your chances of getting an answer. https://discussions.apple.com/community/mac_os/mac_os_x_v10.7_lion

  • When I click the icon Phone on my Iphone 5S, returns a white screen during a few seconds and then return the icons screen again

    when I click the icon Phone on my Iphone 5S, returns a white screen during a few seconds and then return the icons screen again. I can not access the Phone features like Favorites etc

    Can you connect your phone to iTunes on your computer?

  • When I touch Mail, it opens then returns to main screen

    When I touch Mail, it opens briefly and then returns to the Main screen. The main screen Mail icon says there are 73 e-mails but it won't stay open longer than a fraction of a second. This began when I was selecting e-mails to delete; the program shut down and returned to the main screen. What to do?

    Hi: A reset may help. Press and hold the Sleep/On/Off button and the Home button at the same time for approximately 10-15 seconds. Ignore the slide to turn off indicator, and wait for the Apple logo to reappear. Release buttons. No content will he changed with this process.
    Stedman

  • Netflix only plays for a minute or so and then returns to start

    Suddenly my shows won't play for more than a minute or two and then they go back to the play menu.  I can fast forward through shows, but they will NOT play.  Have tried unplugging, rebooting--nothing seems to work.  I'm really irritated....reported shows to Netflix but don't expect anything from there.  I can't watch a **** thing!  Any suggestions??

    The newest version of the Nano is the 6th Generation. It is easily found on the website, either under the "Store" or "Support" tabs at the top of this page.
    Here is the link to the Nano 6th Generation user manual:
    http://manuals.info.apple.com/en_US/iPod_nano_6thgen_User_Guide.pdf

  • Playing random movieclips via timeline

    I have a project that is eight frames long on my main timeline. On each frame is a different movieclip with nested animation that play for varying lenghts. I want to play the animation on the first frame. Then, once a button is clicked, randomly load one of the movieclips on frames 1-7. Please see the following screenshot for a view of my main timeline.
    On that first frame I have writtent he actionscript command stop(); I have also told each movieclip to stop on the last frame of the nested animation and return to frame 1 of the main timeline so the process can start all over again.
    Within the first movieclip is the following actionscript to define how the button behaves and load the random animation:
    boxButton.addEventListener(MouseEvent.CLICK, onBoxButtonClick);
    var randNum:Number=Math.floor(Math.random()*8)+2;
    function onBoxButtonClick(event:MouseEvent):void {
                        MovieClip(root).gotoAndStop(randNum);
    Everything works perfectly, exactly how I want, EXCEPT, once the button is pressed, my movieclips seem to play at varying speeds. Sometimes they play perfectly, other times they go by in the blink of an eye. Any idea why this is happenning and how to control it? I want everything to play at 24fps.

    La velocidad a la que corre un Movie Clip se debe principalmente a la memoria disponible que tiene la maquina, y los elementos usados por la pelicula.
    frames 1-7
    I don't think it has to do with the memory on my machine- I tried it on a couple different computers.

  • Ipad Photo App starts to update then returns to main screen

    I have plenty of photos in the ipad but when I commence the app it starts with ' please wait updating library" then goes back to the main screen. I don't really know when it started but it worked fine when I bought it.

    Hello and welcome....
    Try the instructions here and see if that helps.
    Tunes: Photo sync creates iPod Photo Cache folder
    Carolyn

  • Play a movieclip once, then go to the next frame on the main timeline

    Hello, I'm sorry for the long topic's title.
    I have an animation I'd like to use as an INTRO in my flash
    movie. I will joint it inside a movieclip, giving it the istance
    name "INTRO". And I position it in the first frame of the main
    timeline.
    How can I make possible that played once my intro (my
    movieclip) the player jumps to the second frame of the timeline,
    named by the istance "HOME".
    Is it possible?
    Thankyou very much for your help,
    and great things.
    Stebianchi

    on intro's first frame place:
    if(!this.played){
    _level0.gotoAndStop(2);
    and on its last frame place:
    this.stop();
    this.played=true;
    _level0.gotoAndStop(2);
    // or this.removeMovieClip(), if this is no longer ever used.
    and if you use this, you don't need the frame 1 code.

  • Windows 8.1 Start Screen via GPO

    Hello all,
    Thanks for taking the time to read this.  I realise there are other posts with similar issues to myself, however having read through these posts and applied fixes provided, I am still unable to get this to work.  I am having an issue when trying
    to apply the Start Screen Layout GPO.
    I am attempting to configure this GPO on my Windows 8.1 test network at the moment, but having no joy with it.
    I am using Windows Server 2012 R2 Standard, and Windows 8.1 Enterprise.
    Having done gpresult /r on my test workstation I can confirm the GPO has applied, and also when I check in the registry, the value has been changed in line with the GPO.
    The .xml file is located on a share, although I have also tried the with the .xml file locally on a single test machine and the start screen still does not change.
    Some of the policy is applying, as when I link the policy, I cannot then customize the start screen on my pc which from what I understand is expected behaviour. 
    Any help with this issue would be greatly appreciated.
    Kind regards,
    Doug

    Hi,
    Have you tried the technet article given below?
    Customize Windows 8.1 Start Screens by Using Group Policy
    Regards,
    Gopi
    www.jijitechnologies.com

  • Flash Player From Start Screen...

    I woud like to be able to play games or watch videos from my start screen, it keeps telling me to update my flash player, but I have the most updated one. when i do go to the flash player page all i get is a an empty box. i dont seem to have a problem from my desk top, other than a empty box when i go to flash player...  what is wrong???? i would like to watch moives and play games from my start screen... the picture i uploaded is what I get..HELP...... Please

    I do not have Windows 8 (and probably never will); but I read in several forum posts that you need to start IE from the desktop in order for Flash Player to function.

  • How to prevent an audio file to play the second time the users enter the screen?

    Hi there
    I have a request from my client. She wants the audio file I have on one slide not to play again when the users return to that screen. Is it possible to do that using conditions? I searched the forums but couldn't find anything like this.
    I am using Captivate 5.5.
    Thank you in advance.

    I explained that both in workshops for advanced actions and in a presentation (Lectora vs Captivate) at DevLearn. In this blog post an example, with short explanation can be found:
    http://lilybiri.posterous.com/playtime-with-audio-and-widgets
    The idea is to link the audio not to the slide but to an 'invisible' object (I even have a Highlight box style for that). When entering the slide the first time you show the object and audio will play, when entering afterwards it will be hidden again. This implies the use of a user variable to track the first visit, and a conditional action. If you need more info, just ask for it.
    In CP6 another approach would be possible, using the new statements Play audio and Stop Triggered Audio.
    Lilybiri

  • TS3623 Pressing play on purchased downloads and it starts to download  but then returns to the play button. This is for all the purchased items I have. However pressing play on previews works. Please advise.

    Pressing play on purchased downloads and it starts to download  but then returns to the play button. This is for all the purchased items I have. However pressing play on previews works. Please advise.

    Welcome to the Apple community.
    A number of people have reported similar issues recently, many appear to have found a discrepancy of some kind in their account settings and making changes to these settings or simply resetting them has resolved the matter.
    Check your account details are correct, check that you are using the correct details for Location, Region and Time Zone. You may want to change these settings and then change them back to see if that helps.
    Also check your payment details, make sure your details are exactly how they appear on your credit card statement, you might also try changing some of those details, saving them and changing them back again.
    You might also try logging out of and then back into your iTunes account (Settings > iTunes Store > Apple ID’s > Sign Out) and restarting your router. (Some have reported that after doing this, they need to check for rentals even though it may report that there aren’t any, after which rentals once again appear in the ‘movies’ feature)
    Rentals should appear under their own heading in the ‘Movies’ feature, you might also check at Settings > iTunes Store > Check For Rentals.
    At this point in time, I’m wondering if this could be related to (but not restricted to) the new feature that allows others to come into your home and use your Apple TV to download and play their content on your Apple TV without logging into their account on your Apple TV. The Terms of Use for iTunes Store content have always been to require you to only purchase and play the content from the store in the location where you live and to use a credit card registered in that location. Previously Apple seem to have been somewhat lenient on enforcing such restrictions, perhaps now they are not. However I don’t really have any evidence to support this suggestion, except that changes made to accounts in these areas do appear to be helping many.
    If you are successful in resolving your problem, perhaps you would let us know exactly which action resolved the problem for you. If you are having this problem to begin with, can you also tell us your location.

  • Ipod touch 5 - when in song suffle mode, a random album will suddenly appear on the screen and then it is difficult to get back to the song that is playing

    Just "upgraded" to a new ipod touch 5th generation after previously using various ipod classics.  So I am not familiar with all the ins and outs of the device.  One thing that I have a problem with is the fact that there does not seem to be a simple way, while in shuffle mode to quickly move to the next song or back to the prior song.  But forgetting that for a moment, here is my problem and I am trying to figure out if it is a bug or simply some kind of "feature" of the ipod touch that I don't get.
    I am playing music...in song - shuffle mode.  All of a sudden, instead of the particular song that is playing, a different album shows up on the screen.  Meanwhile, the original song keeps playing.  When this happens, sometimes that album then starts playing and sometimes I am able to move the ipod touch in various directions and I can get back to the song that I was originally playing.  Any idea what is happening here and how to stop it?
    Thanks for any help.

    Hello Philly,
    I believe that when you reset your ipod(command given from the computer, right?)  touch WHILE the ipod was updating, It cleared the system in the middle of writing files, thus corrupting(equivalent of cutting of in the middle of a sentence) the basic running system.
    I suggest you go to an apple store and ask for a technical diagonosis in person. they may offer to help if the problem is fixable. If your ipod is still under warrenty, i would guess it would be free/low cost.
    ~Remember, I am just giving an educated guess on limited information

  • When playing music through iTunes, it no longer starts at a random song.

    I have it set to shuffle and it used to start with a random song.  Now, it always starts with the first song in my library. I prefer the random start, but after the last update, it no longer does it.  Can I change this in a setting or something??

    If your country's iTunes Store allows you to redownload purchased tracks, I'd delete your current copy of the track and try redownloading a fresh one. See the following document for instructions:
    Downloading past purchases from the App Store, iBookstore, and iTunes Store
    Otherwise, I'd report the problem to the iTunes Store.
    Log in to the Store. Click on "Account" in your Quick Links. When you're in your Account information screen, go down to Purchase History and click "See all".
    Find the item that is not playing properly. If you can't see "Report a Problem" next to the item, click the "Report a problem" button. Now click the "Report a Problem" link next to the item.

  • Some songs starts on my iPod, then stop and start from the begining and play all the way through

    Hey,
    While listening to songs on my iPod Classic 120gb, some songs will start to play, after 2-3 seconds, stop and start again from the beginning and play through the entire song no problems. On iTunes the songs still plays fine no stopping or starting. All songs are random artists and songs.
    Help! its really frustrating!

    Hey andy8299,
    Do you have any other music software (i.e Limewire) installed? If so perhaps these files are not compatible.
    See this for compatible song formats:
    http://docs.info.apple.com/article.html?artnum=61476
    Hope this helps,
    Generik

Maybe you are looking for

  • Data transfer from PC to mac

    Recently my PC crashed and I was interested in getting over 20gb worth of data off that drive and onto my macbook. I'm using a Bytecc USB drive mate (works sort of like an enclosure) to do the file transfer. The drive is noticed on the desktop but th

  • Error in BAPI_ACC_DOCUMENT_POST

    Hello, I am trying to use the bapi in the subject following other post on the sdn, but I get this error message: Error in document:  200111 AC_DOC_NO E Required field OBJ_TYPE was not transferred in parameter DOCUMENTHEADER E Required field OBJ_KEY w

  • Compare two tables that are in XML format (xml diff)

    I have two tables in XML-format and need to list differences in 1. Structure and/or 2. Content SAP offers CL_SXIVERI_XML_COMPARATOR, but this is too simplistic for the requirement. Any ideas or suggestions will be appreciated. Thank you!

  • How to check summarized item status

    I have a control block having 12 testitems as summarized of 12 months(of data block) My form validation is if total less than 100 then just alert the user Iwant to alert the user only for the respective month when the value is changed in the total. I

  • G4 error: ATA Drive claims FLUSH CACHE EXT

    Hello, I have three Mac at my home. On of these, my G4/450 with 120GB HD and 512Gb RAM, some days ago doesn't start. Appear boot gray screen with Apple's logo and not continue with the boot. If I start in Super User mode with Command-S at the start I