adding video clips at random to the scene with ACE

Hello

I need help with my code.

I have 3 different film clips.

They are called butterfly00, butterfly01, butterfly02. They are exported for ACE

I need to add to the scene by ACE. Randomly. With the help of a timer.

I put them in a table and the idea was to get out of here, but it is not working properly.

At the moment it works fine for the first 2 butterflies. After that, it adds the butterflies to stage 2 on the same time and then 3 and 4 and etc. Accumulates.

Maybe someone can comment on the code.

Thanks in advance!

var timerLeft: timer = new Timer (5000, 10);

var liblikas00: butterfly00;

var liblikas01: butterfly01;

var liblikas02: butterfly02;

var liblikas: MovieClip;

var symbolArray: Array;

var symbolButterfly: int;

symbolArray = new Array();

  1. symbolArray.push (liblikas00);

trace(symbolArray[0]);

  1. symbolArray.push (liblikas01);

trace(symbolArray[1]);

  1. symbolArray.push (liblikas02);

trace(symbolArray[2]);

  1. timerLeft.addEventListener (TimerEvent.TIMER, butterflyToStage);
  2. timerLeft.start ();

function butterflyToStage(event: TimerEvent): void

{

symbolButterfly = Math.floor (Math.random () * symbolArray.length);

trace ("symbol is" + symbolButterfly);

Switch (symbolButterfly)

{

case symbolButterfly = 0:

var liblikas00: butterfly00 = new butterfly00();

liblikas00.x = stage.stageWidth / 2;

liblikas00.y = Math.floor (Math.random () * (1 + 150 - 350)) + 150;

stage.addChild (liblikas00);

break;

case symbolButterfly = 1:

var liblikas01: butterfly01 = new butterfly01();

liblikas01.x = stage.stageWidth / 2;

liblikas01.y = Math.floor (Math.random () * (1 + 150 - 350)) + 150;

stage.addChild (liblikas01);

break;

case symbolButterfly = 2:

var liblikas02: butterfly02 = new butterfly02();

liblikas02.x = stage.stageWidth / 2;

liblikas02.y = Math.floor (Math.random () * (1 + 150 - 350)) + 150;

stage.addChild (liblikas02);

break;

by default:

trace ("Nothing");

break;

}

}

This is a reduced version of the code:

var timerLeft: timer = new Timer (5000, 10);
var symbolArray:Array = new Array("butterfly00","butterfly01","butterfly02");

timerLeft.addEventListener (TimerEvent.TIMER, butterflyToStage);
timerLeft.start ();

function butterflyToStage(event: TimerEvent): void
{
var butterflyClass = symbolArray [Math.floor (Math.random () * symbolArray.length)];
trace ("symbol is" + butterflyClass);

var ClassRef: Class = Class (getDefinitionByName (butterflyClass));
var classInstance: * = new ClassRef();
classInstance.x = stage.stageWidth / 2;
classInstance.y = Math.floor (Math.random () * (1 + 150 - 350)) + 150;
addChild (classInstance);
}

If you want to be able to target objects then you can place them in a table as you add them and target them to that.

Tags: Adobe Animate

Similar Questions

  • Change the background color of the scene with ACE

    We I have a preloader who plays behind my clip of transparent film and I want to change the scene in the dark
    When I go to full screen. What I found most use a black box, but which are resized to FS.
    So does anyone have an alternative to change the background color with AS it would help a lot.

    Bell W.

    To resize a box mc-background to the size of the stage, you can use the following script:

    lsnr var = new Object();

    lsnr.onResize = function () {}

    _root.boxMc._width = Stage.width;

    _root.boxMc._height = Stage.height;

    }

    Stage.addListener (lsnr);

    This assumes that your background-box is named boxMc and is located in the root timeline, and the film is in mode to noscale.

    EDIT: Another option is just to make the huge background mc, so it will always cover the entire screen.

  • Loading of several video Clips in random order

    I have a flash file that loads video clips at random. The code below is the Framework 1. I have a gotoAndPlay at the end of the timeline to start over so it allows to scroll all the clamps instead of playing one. I don't think that this way is really the best way to do it... but that's what I have so far. Ideally what I need to do, is have it Browse clips in random order, preference not to resume until he got through them all, but at least don't play is not the same one twice in a row. Any suggestions are greatly appreciated.


    Suggestions were very helpful. Thank you! This is the code that we ended up using it. This code was part 1 and forces us to a loop by putting a gotoAndPlay (1) at the end of the main timeline. I don't know why he did that but it didn't work without it.

  • Error #1009 when sound inside game, a movie clip that is called to the scene with child add method

    What is supposed to happen

    I have a clip that is called when the user clicks a button. When moving clip appears music is expected to play. When the user clicks the close button the music stops and the clip is removed from the scene.

    But then I get an error

    When I test the movie I get the following error:

    TypeError: Error #1009: cannot access a property or method of a null object reference.

    to mc_playSong / frame2 () [mc_playSong::frame2:6]

    This is the code that calls the clip on the stage (no problem here):

    Call the video clip with the song played on stage

    stage.addEventListener (MouseEvent.MOUSE_DOWN, goButtons);

    function goButtons(event:MouseEvent):void

    {

    If (event.target is song_bnt)

    {

    SoundMixer.stopAll ();

    addChild (myPlaySong);

    myPlaySong.x = 558;

    myPlaySong.y = 384;

    Event.stopImmediatePropagation;

    }

    The following code inside the clip is called to the scene. The music is meant to play:

    Stop();

    Variables for listening to music

    var RJPlaySong:RJSong = new RJSong();

    var RJPlaySongChannel:SoundChannel;

    Music for plays

    stage.addEventListener (Event.ENTER_FRAME, startRJSong); (I think that the error in the code is in this function. When I comment on him I don't get error.)

    function startRJSong(event:Event):void

    {

    RJPlaySongChannel = RJPlaySong.play ();

    }

    Stop all sounds, sets variables to null and calls a send event that removes the clip of the scene.

    bnt_closeSong.addEventListener (MouseEvent.MOUSE_DOWN, closeCreditSongScreen);

    function closeCreditSongScreen(event:MouseEvent):void

    {

    SoundMixer.stopAll ();

    RJPlaySong = null;

    RJPlaySongChannel = null;

    dispatchEvent (new Event ("RemoveMCsong"));

    }

    Someone at - it ideas? This seems to be a pretty simple question, but I can't understand it.

    I meant that you have quoted just to be taken literally.  If it's still not clear what I say or what did your code, try the following in order to demonstrate the IT change... This code to be...

    stage.addEventListener (Event.ENTER_FRAME, startRJSong);

    function startRJSong(event:Event):void {}

    trace ("I can do this all day");

    }

    After doing this, you can see why you want to only call the function once, and you could eliminate most of it and just put...

    RJPlaySongChannel = RJPlaySong.play ();

    Instead, or as I said originally, you can change it to be...

    function startRJSong (): void

    {

    RJPlaySongChannel = RJPlaySong.play ();

    }

    startRJSong();

  • I get videos from cell phones of the people with a type of file like 3GP. I need to know how to save and change the format so I can open them.

    I get videos from cell phones of the people with a type of file like 3GP. I need to know how to save and change the format so I can open them.

    Trying to convert to the. WMV format:

    There are many converters available on the net... some
    free... some detail.

    The following freeware converter is just one example:

    (FWIW... it's always a good idea to create a system)
    Restore point before installing software or updates)

    Format Factory (freeware)
    http://www.videohelp.com/tools/Format_Factory
    (the 'direct link' is faster download)
    (the file you want to download is: > FFSetup295.zip<>
    (FWIW... installation..., you can uncheck
    ('all' boxes on the final screens)
    (Windows XP / Vista / 7)

    First, you will need to decompress the file or just open the
    Drag > FFSetup295.exe< out="" of="" the="">
    and drop it on your desktop. To install left click.

    Next, after the download and installation of Format
    Factory... you can open the program and
    left click on the toolbar, the "Option" button and
    "Select an output folder to" / apply / OK.
    (this is where you find your files after they)
    are converted)

    Drag and drop your video clips on the main screen...

    Select "all to WMV" / OK...

    Click on... Beginning... in the toolbar...

    That should do it...

    Good luck...

  • In Movie Maker 6.0 can a video clip (with mute) be spliced in another video clip so it seems to work with the original sound of the first video?

    Hi, I put a video together for my MOM to 70th and one of her friends has provided a video clip of her playing a classical piece on the piano for several minutes.  I would like to cover this clip with other video sequences (landscapes, etc.) whereas the way piano since the main video track in the background.
    I tried to let fall the piano video file directly in the audio editing panel and then cut a second 20 segment in the video editing and insert a 20 second video (mute) images of landscape. However, the piano audio from the first video stops as soon as the strike chronology inserted piece landscape and picks up again when it ends, even if the audio scenario shows the audio piano continuously?  Am I missing a step or is this not possible?   Thank you very much.

    It should work quite as much as you described in Windows Movie Maker 6.0 (WMM 6.0), then maybe there is a step that is missed.  Let me describe how I could do and see if there's something you overlooked.

    First of all, I assume that you have already imported the clip of piano and your other clips of landscape in your collection then you can drag the there where necessary.  First, drag the piano music to the track Audio / Music in the timeline panel.  Note that if you have your video extended timeline, it will show video, Transition & Audio, but you want to get off- below that, to the Audio / Music , to follow.  At this point if you play your 'film', you should not to see any picture but just to hear the sound of the piano.  You should also only see a waveform on the audio / music.

    Now you can put anything you want on the video track.  Let's start by putting another copy of the original video of piano, but this time on the video track.  If you have developed the video track (to see the Vidéo/Audio/Transition) you will see the video piano and its associated audio waveform.  However, in your case, since you already have the audio separated, you want to cut that his partner.  Right-click on the Audio (attached to the video) track and select Muteor use the menus (Clip > Audio > Mute).

    When you preview the project, you have synchronized video browsing with the original copy of the audio piano.  At the point in the video where you want to replace the video with another piano play, making a split (key M).  Make another split at the end of the section.  It is very import that select you the video track when you add new divisions and you have not also be divide the track Audio / Music .

    Important: You want to make sure this divide the part that has the exact duration as well as landscape images, you want to replace.  So if you have 20 seconds to add, you divide 20 seconds piano images.

    Right-click on the part of piano footage (video track) and choose Remove.  Then, insert the part of sequences of landscape (also on the video track) in its place.  Once again, you will have need put this added sequence muted landscape (Clip > Audio > Mute).

    You should now see and hear the piano play.  Without any change in the audio playback in the preview window should implement the landscape images, then returns to piano images.

    If you find that your project is not behaving correctly after these splits, but are you sure that you have followed these steps, it could be a problem with your video file types.  If in doubt, try to convert all your videos to .wmv format using something like Freemake Video Converter (freemake.com)

    In any case, I hope that you are able to achieve, because it is certainly possible.  Good luck and post back with further questions or information, you can have.

  • View and play video clips at random.

    Hi followers!

    I am trying to put 6 video clips in a table and to access randomly so that when you press a button on a movieclip appears and plays randomly.

    All MCs are in a setting with this code:

    Stop();
    BLK1._visible = false;
    blk2._visible = false;
    blk3._visible = false;
    ppk1._visible = false;
    ppk2._visible = false;
    ppk3._visible = false;

    storeCartons = new Array();
    storeCartons = (blk1, blk2, blk3, ppk1, ppk2, ppk3);

    startButton.onMouseUp = function() {}
    trace (MyNumber);

    myNumber = Math.floor (Math.random () * 7) + 0;
    activeCarton = storeCartons (myNumber);
    activeCarton._visible = true;

    }
    How can I get it work?

    Here is the updated code.

    Stop();
    BLK1._visible = false;
    blk2._visible = false;
    blk3._visible = false;
    ppk1._visible = false;
    ppk2._visible = false;
    ppk3._visible = false;

    storeCartons = new Array();
    storeCartons = [blk1, blk2, blk3, ppk1, ppk2, ppk3];

    startButton.onRelease = function() {}
    myNumber = Math.floor (Math.random () * storeCartons.length);
    trace ("myNumber" + myNumber);
    activeCarton = storeCartons [myNumber];
    activeCarton._visible = true;

    };

  • A particular website comes in the form of text only, no graphics, after I attepted to change a setting while streaming a video clip. IExplore shows the site properly.

    Windows XP. Firefox 3.6.12. Java extensions console, AVG safe search, ADblocker plus, Deputy MS net framework.
    Was watching a video clip on PBS. Full screen. The video menu wouldn't go away. I have a click with the right button on the video screen, changed a setting, in that I think has a filter setting and now I can't get into PBS.org. Iexplore works very well. Uninstall (save all settings) and reinstalling firefox did not work.

    Sounds that you have blocked some content in Adblock Plus. You must click on the ABP icon and check what is blocked on this page.

  • Button in a movie clip that will command the scene?

    Salvation;

    Type of document html5 Canvas.

    What could be the code for a button (bt1_btn as instance name) which is in a clip (anim_mc as instance name), when the event on the button's "click" and that the statement is: take the play (a scene that already stopped)?

    Cause when I got the script code in the level of the scene that it works fine:

    This.Stop ();

    This.anim_mc.bt1_btn.addEventListener ("click", letsGo.bind (this));

    function letsGo() {}

    This.Play ();

    }

    But what I want is to write the code in the anim_mc clip:

    This.bt1_btn.addEventListener ("click", letsGo.bind (this));

    function letsGo() {}

    //what is the correct script here? > > > Stage.Play ();

    }

    THX

    You don't play the scene. The scene is just a container for the whole object. What you want is to play the root (or hand) timeline.

    To play the root timeline (or any scenario really) anywhere, without having to worry about the use of references, parent.parent.parent etc, store a global reference to the timeilne. On the first image of the timeline root, put something like:

    thisIsTheRootTimeline = this;

    Then in the event handler, follow these steps:

    thisIsTheRootTimeline.play ();

  • video clip of load in the much bigger than 100 preview window &amp;

    I use Premiere Pro on a Mac. That has started to happen, is that when I drag a clip form the window source on the timeline, the video clip in the preview window is huge - from most large it displayed in the source window. I don't want to have to go in and resize each clip. What is the cause and how to fix it?  Also, I went into preferences and pliers to adjust the value.

    What is your sequence Match your source footage?  I do NOT!

  • Coding of a button in a movie clip problems to navigate the scenes

    Hello! I have an another probably noobish question to ask on the CS6.

    My goal is very similar to the mentioned in this forum question described above: http://forums.Adobe.com/message/837995#837995 and also in this issue http://forums.Adobe.com/message/4172919#4172919

    I'm trying to make a button inside a clip in my first scene when you click in the first frame of my second scene. I appointed menu_button_1 instance of the button, and I think that the stage 1 and stage 2 are the names of the scenes. (If they should have special names or instance names, I do not see where type them.) Because of the similarities, I tried to follow the suggestions on these pages. However, I did probably some small thing wrong, (or heck, maybe one thing huge.) that I what I would like to help find.

    Stop();
    myButton.addEventListener (MouseEvent.CLICK, clickHandler);
    function clickHandler(evt:MouseEvent):void {}
    Stop (1, "scene 1");
    }

    This seems to be what has been proposed to enter. I tried to change it works as well for me. That's what I typed to the button action.

    menu_button_1.addEventListener (MouseEvent.CLICK, clickHandler);

    function clickHandler(evt:MouseEvent):void {}

    gotoAndPlay (1, "scene 2");

    }

    (I removed the stop function because I have music on a loop in the clip I want to play until the mouse is clicked). (Also, I took gotoandplay because I wanted to stage 2 to start playing immediately when clicked, rather than to stop.)

    I tried variations, including the "2" instead of "scene 2" and whatnot. I also tried connecting to differnet places just to see if that would work. It seems that she would be able to join if I only asked a frame in the clip of the film itself, but he couldn't go to all other executives in stage 1 or stage 2. When I try this message appears in the output:

    ArgumentError: Error #2108: stage 2 was not found.

    at flash.display::MovieClip/gotoAndPlay()

    at interactivestgermant_fla::menu_1/clickHandler()

    It seems that not finding my scene 2. (She also can't find scene 1 when I invite you to do so.) I'm afraid that I'm not sure of what I entered incorrectly, although I imagine that this is how I typed the navigation of the scene. Should have an instance name or something? I was very muchappreciate a little nudge in the right direction. If you need more info, I'll be happy to provide. Thanks for the help! I appreciate that very much.

    The first image you provided shows that you have assigned an image tag, not an instance name.  You must select the menu object on the stage and then you should see a section of the properties panel at the top which has a field with "", said inside (assuming it's a movieclip symbol).  This is where you enter the word 'menu'... which is by assigning a name to the instance of the menu you have on the stage.

    The way you seem to have a number of keyframes that precedes in the timeline may mean you need to do this in each keyframe where there is this menu item.  IF you do not, then it can inherit the lack of a name of a previous frame.

  • XML to fill some movieclips added to the scene with AS3

    OK, I am new to AS3 and it's the biggest thing that I tried to do.

    I'm just at a loss for the right path to take to achieve what I want to do.

    In short, here is what the final result will look like:

    The scene contains a large (about X size) movieclip with a scroll bar (not important for this discussion). This movieclip is created using AS3.

    The large movieclip is filled with many small movieclips created from a template in the library. This model contains certain dynamic text fields (let's call them text1_MC and text2_MC). Dynamic text for each small movieclip is provided of an XML file that contains the text and text1 2 data.

    I was watching tutorials to dynamically add a text as well as the instructions of plotting xml data analysis and others. What I can't find is how add dynamically the text to a text field in a movieclip and then add the movieclip on the stage and then start everything for the next bit of data.

    What we call this process? I know that I am using a loop statement, but someone could give me an overview of all the different things I do to get my data on xml, fill a single movieclip, and then adding this movieclip to the greatest MC, then doing that everywhere for all xml entries I've got, then adding that great MC on the stage?  I would be happy to get it all myself.

    Thank you!

    Hello

    You have created a single object. Only, I changed your code. pls watch it.

    var Timeline_mc:MovieClip = new Timeline_MC();

    var flag: Flag_MC.

    function ParseFlags(flagInput:XML):void
    {
    var locationList:XMLList = flagInput.Flag.Location;
    var titleList:XMLList = flagInput.Flag.Title;
    var actionList:XMLList = flagInput.Flag.Action;
    for (var i: int = 0; i< locationlist.length();="">
    {

    flag = new Flag_MC();

    var locationElement: Number = locationList [i];
    var titleElement:XML = titleList [i];
    var actionElement: XML = actionList [i];
    Flag.txt_title. Text = (titleElement);
    Flag.txt_intro. Text = (actionElement;)
    Flag.x = (location element);

    Timeline_mc. AddChild (flag); / /[i] ;

    }
    }

    addChild (Timeline_mc);

    Thank you

    Concerning

    Bala.S

  • try to export a video clip, but it's not compatible with flash player 17. Help?

    I'm trying to export a video clip, but it indicates that it contains features that are not compatible with flash player 17 and don't work every time, I tried exporting in different ways and using parameters different flash player, but nothing seems to work. It displays a message at the bottom of the screen, but I don't know how to solve this problem. Once I have try to export the adobe media encoder file opens and shows me a video file, but it lacks almost everything I did and is not what I'm trying to export. I hope you can help, thanks Caitlin

    You cannot export the integrated H.264 video. If you try to put animations on top of some videos, do export you already, but it does not send through Adobe Media Encoder. There is also a checkbox to ignore the color of the scene and to generate an alpha channel. Do it too. You should end up with a MOV file that can sit on top of the original video, click, in After Effects or Premiere.

  • Get the library MovieClip is on the scene with AS3

    Hey guys, a simple I think, right

    Could I please have the answer to get an element of MovieClip on the stage within say the class Document.

    The trick is

    I want to do when the MovieClip is link refers to a class name, but doesn't actually have a document class that is created.

    I know you can give a complete class with the document and which would not be easy.  But if you have 10 enemy objects literally doing the same thing, but just look different, why create 10 separate classes!

    or I am barking the wrong tree and that I should just set up 10 different enemy styles in the MovieClip 1 and just 1 class join her?

    Although always, I would like to know how to get dynamically a MovieClip on the stage of the library, when he isn't a class file associated with the class name in the link

    I saw that somewhere there are many moons but do not remember how it was done: s

    Thanks in advance

    Pocketninja

    I'll spare you any attempt by me to answer the questions of the Document class, but here are the basics to dynamically load a symbol in the library...

    First of all you must designate the object in the library as an element that can be dynamically loaded.

    Right-click on it in the library and select the link in the menu that appears. In the interface that appears, select export for Actionscript. A class name will be automatically assigned, you can change as you wish (let's just say you name MyObject). Is the name you will use to call in the library item.

    When you click OK to close this interface, it can come up with an indication saying that he finds not only the class so it will create a moment complie... click OK here.  You are made to prepare the object in the library.

    To add the item to the scene, treat it like any other new object instance:

    var newObject:MyObject = new MyObject();
    newObject.x =... etc...
    this.addChild (newObject);

  • paste video clips and audio in the timeline (why failing A1 and V1)?

    Hey guys. This is probably a simple shortcut or something I am doing wrong.

    Say that I'm going to copy a piece of audio or video, I notice not always blocks V1 or A1 even if I have not currently selected.

    Same thing with extraction of the ins and outs... The V1 V2 V3 highlighted on the left side do not seem to make a difference when it comes to copying and pasting or extraction. I'm a usual AVID editing system which maybe why I'm used to directing where to go the A1 and V1.

    Help someone?

    Am I stupid? Could be...

    This could be useful? Correction of the source in Premiere Pro sequences

Maybe you are looking for

  • What kind of main card has Satellite P30?

    Can someone tell me who 'brand' the main Board is my p30-109, P4 3.06 GHz, 60GB HD. Is a main Intel card? Kind regardsLEF

  • ProLiant ML310e

    I just bought a HP Proliant ML310e Gen v2.  I tried to install two SAS drives, but the computer does not recognize the readers at all.   I just tried disk SATA set up and it 'clear'.  However the two SAS drives are still not recognized.   Leafing tro

  • Why can I not make a continuous sampling of port 0 on USB 6216?

    I have a USB-6216 of NOR. I try to capture digital signals using port 0. However, the only way that I can function is samples on request. If I select N samples or continuous sampling, I get the following in the DAQ SignalExpress Wizard error message

  • How to delete songs that came on my Sansa Fuze?

    My Sansa Fuze came with 19 songs on what I want to delete but I don't know how.  When I plug in my Sansa Fuze in my computer the songs do not appear on my computer but they are on the device when I use it.  They are not in the 'Music' folder or any f

  • Smartphone blackBerry Bold 9700 on Bouygues in Paris

    I'll buy a Bold 9700 unlocked for someone as a gift. Originally from Rogers in the Canada, to go to Paris on the SIM Bouygues. I can't find anywhere what Bouygues (MHz) network runs. UNLOCKED Rogers Bold 9700 runs on networks of Bouygues? Thank you.