Randomly generating movieClips from the library onto the stage

Hi
I am trying to call objects from the library for a collection game.
Having major issues with the best way to assign the good objects and the bad objects to later update a score.
Can anyone help me with how i can first assign the movieClips from the library into a good and bad array and then after randomally fill the stage with them.
Regards
James

again and always when testing in the ide, use the trace() function to debug your code:
public function checkCollisions()
                              for (var i:int = objects.length - 1; i >= 0; i--)
                                        if (Point.distance(new Point(gamesprite.car.x,gamesprite.car.y),new Point(objects[i].x,objects[i].y)) < pickupDistance)
                                                  if (objects[i].hitTestobjects(gamesprite.car))
                                                            if (objects[i].typestr == "good")
                                                                      score +=  10;
                                                                      trace(score);
                                                            else
                                                                      score -=  4;
                                                                      trace(score);
                                                            if (score < 0)
                                                                      score = 0;
                                                            scoreDisplay.text = String(score);
trace(scoreDisplay.text);
                                                            removeChild(objects[i]);
                                                            objects.splice(i,1);
if you don't see any trace() output, you can conclude that part of your code is not executing.  if see trace output, you can don't see the same value in scoreDisplay, you can conclude you're not seeing your scoreDisplay textfield.

Similar Messages

  • TypeError: Error #1006 - Removing MovieClip from the stage

    I have a movie clip that is called to the stage and once the movieclip is finished it calls a function that removes it from the stage. The code works but I get an error message about 4 seconds after the movie clip ends.
    Here’s the error message:
    TypeError: Error #1006: exitWordMicroscopic is not a function.
                    at ASvocabulary_microscopic/frame110()[ASvocabulary_microscopic::frame110:1]
    Here’s the stage code:
    //************************Removes the movieclip from the stage and enables the button.*************************
    function exitWordMicroscopic():void
                    bnt_vocab_microscopic.mouseEnabled = true;
                    removeChild(word_Microscopic);
    //******************************Stage buttons**************************************
    stage.addEventListener(MouseEvent.MOUSE_DOWN, goButtonsHomeRead_1);
    function goButtonsHomeRead_1(event:MouseEvent):void
                    //Vocabulary buttons
                    if (event.target == bnt_vocab_microscopic)
                                    bnt_vocab_microscopic.mouseEnabled = false;
                                    SoundMixer.stopAll();
                                    addChild(word_Microscopic);
                                    word_Microscopic.x = 47;
                                    word_Microscopic.y = 120;
    Here’s the code inside the movie clip. This is what the error message is referring to:
    //****************** Calls function to remove itself from the stage****************************
    Object(parent).exitWordMicroscopic();
    What am I doing wrong?

    Here' how the code looks now:
    Objective: To remove the current movieclip while it's playing so that it does not show on the next (or previous) frame.
    Here’s the stage code:
    var word_Microscopic:ASvocabulary_microscopic = new ASvocabulary_microscopic();
    //Removes the movieclip from the stage and enables the button.
    function exitWordMicroscopic():void
        bnt_vocab_microscopic.mouseEnabled = true;
        removeChild(word_Microscopic);
    //******************************Stage buttons**************************************
    stage.addEventListener(MouseEvent.MOUSE_DOWN, goButtonsHomeRead_1);
    function goButtonsHomeRead_1(event:MouseEvent):void
        //Vocabulary buttons
        if (event.target == bnt_vocab_microscopic)
            SoundMixer.stopAll();
            bnt_vocab_microscopic.mouseEnabled = false;
            addChild(word_Microscopic);
            word_Microscopic.x = 47;
            word_Microscopic.y = 120;
            word_Microscopic.play();
    //This button takes the user to the Main Screen
        if (event.target == bnt_ReadGoHome_1)
           // exitWordMicroscopic(); [If I use this function I get this error ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.]
            SoundMixer.stopAll();
            gotoAndPlay("1","Main");
            stage.removeEventListener(MouseEvent.MOUSE_DOWN, goButtonsHomeRead_1);
    //This takes the user to the next frame.
    if (event.target == GoNext_1)
            SoundMixer.stopAll();
            gotoAndPlay("2");
            stage.removeEventListener(MouseEvent.MOUSE_DOWN, goButtonsHomeRead_1);
    Here’s the code inside the movie clip.
    //****************** Calls function to remove itself from the stage****************************
    Object(parent).exitWordMicroscopic();

  • Removing a movieclip from the stage after a set amount of time (or once it's finished its animation)

    I've got a movieclip animation which is added to the stage at the start of the .swf.  Its an introduction to the game, and the user is encouraged to click on the movieclip to start the animation.
    Once the animation is finished I'd like the movieclip to be removed from the stage.
    How do I go about doing this?  Do I need to setup some sort of event handler which listens out if the movieclip has finished then start a function once its finished to remove it from the stage?  Which methods look out for movieclips finishing?
    Cheers

    there is no specific event that's called when a movieclip stops playing,
    what you could do is inside your intro movieclip  dispatch an event as soon as the animation is finished
    something like ... dispatchEvent(new Event("introFinished");
    and all you have to do is add and event listener to the intro movieclip intro.addEventListener("introFinished", onIntroFinished);
    when your onIntroFinished is called you can remove the intro from the stage.

  • Can Flash publish video to FMS generated from the Stage?

    I know NetStream can publish video from a camera, but is there anyway to generate video from the stage?
    If would be nice to record what is on the stage to the FMS for playback.
    Even combining the camera with elements on the stage.
    This would be even better once Stage3D is available to generate 3D generated videos.
    Is there anyway to overload Camera to insert any display object you wanted?
    Thanks.

    Maybe something like this:
    var ns:NetStream;
    //...init...
    ns.attachStage(this);
    while (condition) {
      moveObjectsOnStage();
      ns.nextFrame();
    ns.close();

  • I have an apple iphone 4 that I want to download audio books from my library onto it.  I cannot figure out how to do that.  The iphone does not show up on my mac laptop as a connected device.  Does this kind of download have to run through itunes?  Thanks

    I have an apple iphone 4 that I want to download audio books from my library onto.  I cannot figure out how to do that.  The iphone does not show up on my mac laptop as a connected device.  Does this kind of download have to run through itunes?  Thanks

    Yes it is done through iTunes. The iPhone will never show up in Finder as a device. The following is general information on iTunes sync: http://support.apple.com/kb/HT1386 and the following is a previous discussion where the post by Andreas Junge helped others that had a problem syncing audiobooks: https://discussions.apple.com/message/20052732#20052732

  • Is it possible to call a movieClip from the Flash library using XML?

    Instead of using "test_1.swf" or "test_2.jpg" in the <IMAGE> tags shown below, we are wanting to call a movieClip from the same library as the .FLA via XML.
    Is this possible using XML and AS3?
    < ?xml version="1.0" encoding="UTF-8"?>
    < all>
         < GROUP>
              <IMAGE>test_1.swf</IMAGE>
              <QUESTION>Question example #1</QUESTION>
              <OPTION1>Option A example</OPTION1>
              <OPTION2>Option B example/OPTION2>
              <OPTION3>Option C example</OPTION3>
              <IMAGE>test_2.jpg</IMAGE> 
              <QUESTION>Question example #2</QUESTION>
              <OPTION1>Option A example</OPTION1>
              <OPTION2>Option B example/OPTION2>
              <OPTION3>Option C example</OPTION3>
         < /GROUP>
    < /all>

    data.xml:
    < ?xml version="1.0" encoding="UTF-8"?>
    < all>
         < GROUP>
              <IMAGE>MC1</IMAGE>
              <QUESTION>Question example #1</QUESTION>
              <OPTION1>Option A example</OPTION1>
              <OPTION2>Option B example/OPTION2>
              <OPTION3>Option C example</OPTION3>
              <IMAGE>MC2</IMAGE> 
              <QUESTION>Question example #2</QUESTION>
              <OPTION1>Option A example</OPTION1>
              <OPTION2>Option B example/OPTION2>
              <OPTION3>Option C example</OPTION3>
         < /GROUP>
    < /all>
    // a.s.
    var urlLoader:URLLoader=new URLLoader();
    urlLoader.addEventListener(Event.COMPLETE,completeF);
    urlLoader.load(new URLRequest("data.xml"));
    function completeF(e:Event):void{
    var xml:XML=XML(e.data);
    var instance:*=stringToClassInstanceF(xml.GROUP.IMAGE[0]);
    addChild(instance);
    function stringToClassInstanceF(s:String):*{
    var C:Class=Class(getDefinitionByName(s));
    return new C();

  • HT1535 Does iTunes 11 allow for the "dragging" and "dropping" of music from a library onto a manually managed device?

    It appears that iTunes 11 does not allow for the "dragging" and "dropping" of music from a library onto a manually managed device.. is that true? I am trying to drag a playlist onto my iPhone. I've done it many times before on previous versions of iTunes but now that the menu is up in the heading, I can't drag the playlist onto the icon for my iPhone.

    Zmaj3 wrote:
    It appears that iTunes 11 does not allow for the "dragging" and "dropping" of music from a library onto a manually managed device.. is that true?
    No.
    Sync you are not syncing, the ONLY way to get items onto a manually managed device is to drag and drop.
    However, I feel a much simpler way is to create a playlist and add/remove songs from this playlist and autosync this playlist (or multiple playlists). I use about 6 or 7 playlists
    You can still also drag & drop songs while autosycning.

  • I wish to generate reports from the database an out put it but i need to enter a date from and to ina  html input box

    i wish to generate reports from the database an out put it
    but i need to enter a date from and to ina html input box
    in the input box a data of range will be input from a start
    to latest
    latest being the default as today's date.
    any help tips snipplets, concepts , turot=rails.
    thanks

    easycfm.com has tutorials for people who are brand new.
    If you don't know much about sql, I have heard good things
    about the book, Teach Yourself SQL in 10 Minutes by Ben
    Forta.

  • I have a first gen iPad, and it will randomly go home from the Internet when I don't press any button.  I have a wireless connection at home.

    I have a first gen iPad, and it will randomly go home from the Internet when I don't press any button.  I have a wireless connection at home.  Is this a known bug?  What can I do?

    You maybe running low on memory since you are using the original iPad with iOS 5.1.1 and the iPad is crashing. This may help and it certainly won't hurt.
    Quit all apps completely and reboot the iPad. Go to the home screen first by tapping the home button. Double tap the home button and the recents tray will appear with all of your recent apps displayed at the bottom. Tap and hold down on any app icon until it begins to wiggle. Tap the minus sign in the upper left corner of the app that you want to close. Tap the home button or anywhere above the task bar.
    Reboot the iPad by holding down on the sleep and home buttons at the same time for about 10-15 seconds until the Apple Logo appears - ignore the red slider if it appears on the screen - let go of the buttons. Let the iPad start up.
    Do this before you launch Safari again. Go to Settings>Safari>Clear Cookies and Data. You don't have to clear the history.

  • I need to remove a library item from the stage

    Right now I have a button that brings a library symbol to the stage. Ideally, I want to be able to click on the symbol itself to make itself from the stage. Can anyone help me with this?

    for example:
    var sym:WhateverClass=new WhateverClass();
    sym.addEventListener(MouseEvent.CLICK,clickF);
    function clickF(e:MouseEvent):void{
    e.currentTarget.parent.removeChild(e.currentTarget);

  • How-to Generate Script from the export dump file

    Hi all,
    Software : Oracle 10gR2/Windows 2003
    =============================
    Has anyone generated a Script from a export dump file ( exported via data pump export). I know it is possible to generate script from the regular export.
    I want to know how to generate the script for various objects or is it possible to get the counts of types of objects in the dump file and / or generate the script from the export dump file exported via data pump utility on Oracle 10g.
    Thanks,
    SS

    I want to know how to generate the script for various objects.what do you mean by scripts? Assuming the metadata definitions of various objects.
    First of all, you can generate the metadata definitions using import.
    Use, Impdp with SQLFILE parameter to generate the SQL file for the metadata definitions.
    Refer to
    http://download-uk.oracle.com/docs/cd/B19306_01/server.102/b14215/dp_overview.htm

  • How do I remove a child from the stage using a button click?

    I have a movieclip that requires Play, Pause, Forward and Back buttons. The movieclip has actionscript at various frames to load movieclips from the library and repeat them.
    I have tried using a timeline scrubber but it does not trigger the actionscript when scrubbing, only when the movie plays normally.
    My possible solution is to create Fwd and Back buttons that can go to specific frames where key animations will begin.
    I need to develop actionscript that will remove Children when the user clicks Back.
    This is how I am loading several movieclips along the timeline from my library:
    var shpA1:arSHPp1;
    function attachAR1 () {
      shpA1 = new arSHPp1 ();
      shpA1.x = -30;
      shpA1.y = 18;
      addChild (shpA1);
    //the interval is used to repeat the animation to represent continuous flow on a diagram
    var myInterval1:uint = setInterval (attachAR1, 500);
    This what I have tried so far (not working at all - no errors or trace):
    function remChild1(event:MouseEvent) :void {
        if(shpA1.stage)
            trace("arSHPp1 is in display list");
            shpA1.parent.removeChild(shpA1);
            shpA1 = null
        else
            trace("arSHPp1 isn't in display list");

    I did try that but it would not remove the child.
    i appreciate your help though.
    I am also trying to determine if a child is on the stage and if it is, remove it. I have created a button that will jump back on the timeline and the mc's that were loaded after this point in time.
    This looks like it should work. It doesn't give me any errors but the mc remains on the stage.
    var remMC;
    if (getChildByName("mc2") != null) {
      removeChild(mc2);

  • Placing movieclips on the stage

    Hello,
    I am trying to place movieclips from the librari on the stage
    but i only get one row.
    This is wat i want to archieve. (for example M = a
    movieclip).
    M M M M M M
    M M M M M M
    M M M M M M
    M M M M M M
    If i also fill in the _y the result looks like this.
    M
    .. M
    ..... M
    ........ M
    ............. M
    now it looks like this:
    M M M M M M
    This is the code i used:
    var tegelhouder:MovieClip =
    this.createEmptyMovieClip("tegelhouder",
    this.getNextHighestDepth());
    tegelhouder._x = -70;
    tegelhouder._y = 0;
    for(i=1; i<9; i++) {
    tegelhouder.attachMovie("tegelanim", "tegels"+i, i);
    tegelhouder["tegels"+i]._x = i*70;
    So the first thing i am trying to archive is to place the
    movieclips vertical as horizontal.
    Can someone help me with this?
    Regards,
    Micheal

    //this is very simple
    //All is you need them in rows one by one
    //do this
    for (var a:Number = 1; a<=30; a++) {
    attachMovie("dd", "dd"+a, a);
    //if you want them in 5 clips in a row then
    trace(a%5);
    if (a == 1) {
    // to place the first one at some point
    _root["dd"+a]._x = 100;
    _root["dd"+a]._y = 100;
    } else {
    if (a%5 == 1) {
    _root["dd"+a]._y =
    _root["dd"+(a-1)]._y+_root["dd"+(a-1)]._height+2;
    _root["dd"+a]._x = 100;
    } else {
    _root["dd"+a]._y = _root["dd"+(a-1)]._y;
    _root["dd"+a]._x =
    _root["dd"+(a-1)]._x+_root["dd"+(a-1)]._width+2;
    Hope you enjoy

  • How to remove a dynamic symbol from the stage?

    I'm loading dynamically copies of a Library symbol with a button click. Question is, when I move around in the timeline, I don't want to see the symbols at certain points. Can I loop through the json file and remove each symbol from the stage? Or is there a better way of accomplishing this?
    Being new to Edge Animate, I'm also unsure as to the names of the symbols as they are placed on the stage. If I use the browser's developer tools, I can see that the divs are named Stage_90, Stage_91, Stage_92 etc. However doing something like the following does not seem to work:
    sym.$("Stage_90").hide();
    I appreciate the help. Thanks again.

    I got it. It should be:
    $("#region1").remove();  
    // # was missing.
    I actually added that to time 0 on the main timeline so when I got back there it removes the image.
    It's not working from the symbol yet but I guess I should eventually get it working from there instead.
    Thanks for your time.

  • How do you remove a symbol from the stage in Edge animate?

    Hello-
    I'm wondering how to remove a symbol from the stage in Edge Animate so you can jump to another place in the timeline.  In Flash, the symbol was only on the stage for the amount of frames you indicated.  Not sure how it works here.
    For example, I have 2 buttons on my first screen with some text that animates in.  I want the button click to take the user to another section in the timeline or (basically another scene, like in Flash)  that contains different content.  If I change the visibility the buttons are still there and will ( I assume) create problems when other elements are placed on top. 
    Or is the only way with code.  If that is the case what would that code be?
    I would appreciate any help.
    Thank you!

    What I usually do, is, once you have everything set up in the scene you are done with. highlight it all
    right click
    group elements in DIV
    Now all those items act as 1 group and then you give it a properties name, much like a symbol.
    THEN you can refer to that scene name and move it anywhere or hide it and slide in another scene that has the content for that next scene.
    basically you take all the elements that make up 1 scene, gruop it up, name it, and then in the code for the button say something like:
    on click:
    scenename.play(framenumber);
    that will then animate that scene according to any animation you gave it, such as moving to the left, off stage. while moving scene 2 that you create into the stage.
    or just have something like this hide it
    sym.$("scenename").hide();
    sym.$("scene2name").show();
    but if you do that, make sure in your CompositionReady code you hide all scenes EXCEPT the 1st one, so the user doesnt see them all instanatly anyway.

Maybe you are looking for

  • Report for Sales and purchase tax (selection criteria-Tax code)

    Hi I have one query for sales tax details which gives me detail for all A/R invoices and taxes involved in it. But i want that while executing query system should ask tax code and gives detail of tax amount in front of item and invoice according to t

  • Add or remove applications from Startup in LION

    We just did a migration from Tiger to Lion for our primary Mac user and now, on her new machine running Lion, Microsoft Excel and Microsoft Entourage launch every time she starts up her PC.  Microsoft Excel was not even in her Startup on her old syst

  • IPhone 4s Ringtone No Longer Works

    My message alert tone will only work if the message application is open on the screen. This applies to vibrate as well. The ringtones still go off when receiving phone calls, but never for text messages. Help!

  • What is the best iPad 2 file management program?

    My movies are taking over my iPad 2 hard drive.  I purchased movies on my iPad 2 and would like to move them to my macbook for storage.

  • Question regarding the size of a rendered DVD file?

    Hi all, I just finished my first home video using Premiere Pro CS4 and Encore CS4. My source is a consumer HD camcorder. When I created the PP project, I selected AVHCD format to keep it the highest quality possible. So Iimported the files in PP, app