AS3 moving clips in array not working

I'm having three movie clips, which I would like to move randomly within a set box. The following script works with one movie, but not with all movies placed in an array.
Please help!
var clipSpeed:Number= 1;
var speedX:Number = 0
var speedY:Number = 0
var upperLeftLimit:Point = new Point(0, 0)
var bottomRightLimit:Point = new Point(300, 300)
var clipArray:Array= [clip, clip1, clip2];
for (var i=0; i<clipArray.length; i++)
trace (clipArray[i])
clipArray[i].addEventListener(Event.ENTER_FRAME, randomMove);
function randomMove(e:Event) {
     speedX += Math.random() * clipSpeed - clipSpeed / 2;
    speedY += Math.random() * clipSpeed - clipSpeed / 2;
    if (clipArray[i].x + speedX > upperLeftLimit.x && clipArray[i].x + speedX < bottomRightLimit.x)
       { clipArray[i].x += speedX;}
  else
        {speedX = 0}
    if (clipArray[i].y + speedY > upperLeftLimit.y && clipArray[i].y + speedY < bottomRightLimit.y)
        {clipArray[i].y += speedY;}
    else
        {speedY = 0}
Thanks 

then one or more of your clips are starting outside your limits.  and, you probably don't want to use that code because all the clips move the same amount each loop. 
try:
var clipSpeed:Number=1;
var speedX:Number=0;
var speedY:Number=0;
var upperLeftLimit:Point=new Point(0,0);
var bottomRightLimit:Point=new Point(300,300);
var clipArray:Array=[clip,clip1,clip2];
for(var i:int=0;i<clipArray.length;i++){
    clipArray[i].speedX = speedX;
    clipArray[i].speedY = speedY;
this.addEventListener(Event.ENTER_FRAME,randomMove);
function randomMove(e:Event) {
    for(var i:int=0;i<clipArray.length;i++){
    var mc:MovieClip=clipArray[i];
    mc.speedX+=Math.random()*clipSpeed-clipSpeed/2;
    mc.speedY+=Math.random()*clipSpeed-clipSpeed/2;
    if (mc.x+mc.speedX>upperLeftLimit.x&&mc.x+mc.speedX<bottomRightLimit.x) {
        mc.x+=mc.speedX;
    } else {
        mc.speedX=0;
    if (mc.y+mc.speedY>upperLeftLimit.y&&mc.y+mc.speedY<bottomRightLimit.y) {
        mc.y+=mc.speedY;
    } else {
        mc.speedY=0;

Similar Messages

  • Publishing a flash with AS3.0 on website does not work

    Okay, I'm finally at the end of my flash card. Here's the whole code.
    //import classes
    import com.greensock.TweenLite;
    import com.greensock.easing.*;
    import fl.transitions.Tween;
    import fl.transitions.easing.*;
    //end of importing
    //start of sound section is for sound
    var cssLoader:URLLoader;
    var css:StyleSheet;
    var soundReq:URLRequest=new URLRequest("audioFiles/PaukenBrumfiel_AngelsOnHigh.mp3");
    var sound:Sound = new Sound();
    sound.load(soundReq);
    sound.addEventListener(Event.COMPLETE, onComplete);
    //end of sound section
    //Loading external texts
    var weiss:Font = new Weiss();
    var weissBold:Font = new WeissBolder18();
    var weissBolder:Font = new WeissBolder();
    var slideXTween:Tween;
    var txtAlphaTween:Tween;
    var txtNextText:Tween;
    var txtContainer:Sprite;
    var txtField:TextField = new TextField();
    var myTxtField:TextField = new TextField();
    var txtFldwebImages:TextField = new TextField();
    var textRequest:URLRequest=new URLRequest("happyHoliday.txt");
    var textLoad:URLLoader = new URLLoader();
    var txtFormat:TextFormat = new TextFormat();
    var myLinkFormat:TextFormat = new TextFormat();
    var strLink:String;
    var numXPos:Number;
    var numYPos:Number;
    //end of loading external texts
    function onComplete(event:Event):void {
        sound.play();
    function textReady(event:Event):void {
        //txtFormat.font= weiss.fontName;
        txtFormat.color=0x000066;
        txtFormat.size=24;
        //txtField.x = stage.stageWidth;
        //txtField.width = 800;
        txtField.autoSize=TextFieldAutoSize.LEFT;
        //txtField.height = txtField.autoSize
        txtField.wordWrap=false;
        txtField.text=event.target.data;
        txtField.setTextFormat(txtFormat);
        //txtField.y = 350;
        txtField.embedFonts=true;
    textLoad.load(textRequest);
    txtFormat.font= weiss.fontName;
    textLoad.addEventListener(Event.COMPLETE, textReady);
    txtField.x=stage.stageWidth;
    addChild(txtField);
    txtField.y=350;
    TweenLite.to(txtField, 40, {x:-stage.stageWidth*2.25, ease:Linear.easeNone, delay:0.5, onComplete:Inspiration});
    function Inspiration():void {
        txtFormat.font= weissBolder.fontName;
        textLoad.load(new URLRequest("inspiration.txt"));
        txtField.x=130;
        txtField.y=330;
        txtField.alpha=0;
        TweenLite.to(txtField, 5, {alpha:1, onComplete:GoogleFunc});
    function GoogleFunc():void {
        //create and initialize css
        addChild(myTxtField);
        strLink = "<a href='http://www.google.com/' target='_blank'>Google</a>";
        numXPos = 180;
        numYPos = 370;
        var myCSS:StyleSheet = new StyleSheet();
        myCSS.setStyle("a:link", {color:'#000066',textDecoration:'none'});
        myCSS.setStyle("a:hover", {color:'#FF6600',textDecoration:'underline'});
        txtFormat.font = weissBold.fontName;
        //txtFormat.color=0x000066;
        txtFormat.size=20;
        //txtFormat.bold = true;
        myTxtField.setTextFormat(txtFormat);
        myTxtField.defaultTextFormat=txtFormat;
        myTxtField.styleSheet = myCSS; // Linking CSS to TextField
        myTxtField.htmlText="";
        myTxtField.htmlText=strLink;
        myTxtField.wordWrap=false;
        //myTxtField.embedFonts = true;
        myTxtField.width = strLink.length*2;
        myTxtField.x=numXPos;
        myTxtField.y=numYPos;
        //trace("Third txtField.y: " + txtField.y);
        myTxtField.alpha=0;
        TweenLite.to(myTxtField, 1, {alpha:1, onComplete:webImages});
        //trace("tween done");
    function webImages():void {
        addChild(txtFldwebImages);
        var myCSS:StyleSheet = new StyleSheet();
        myCSS.setStyle("a:link", {fontsize:'20',color:'#000066',textDecoration:'none'});
        myCSS.setStyle("a:hover", {fontsize:'20',color:'#FF6600',textDecoration:'underline'});
        txtFormat.font = weissBold.fontName;
        //txtFormat.color=0x000066;
        txtFormat.size=20;
        //txtFormat.bold = true;
        txtFldwebImages.setTextFormat(txtFormat);
        txtFldwebImages.defaultTextFormat=txtFormat;
        txtFldwebImages.styleSheet = myCSS; // Linking CSS to TextField
        txtFldwebImages.htmlText = "";
        txtFldwebImages.htmlText="<a href='http://www.google.com/webImages/' target='_blank'>Google Images</a>";
        txtFldwebImages.wordWrap=false;
        //myTxtField.embedFonts = true;
        txtFldwebImages.width = 300;
        txtFldwebImages.x=300;
        txtFldwebImages.y=370;
        txtFldwebImages.alpha=0;
        TweenLite.to(txtFldwebImages, 1, {alpha:1});
    //end of loading external texts
    Okay, the problem is when I publish the .swf files and put it in an html or .aspx page, it does not work. The audio is not there and a few others things ar enot working. However, it does work if I click on the.html file that Flash created during the publication.
    Here are the folder structions:
    www.mysite.com/myFlashPage.aspx
    www.mysite.com/flashFileFolder/
    www.mysite.com/flashFileFolder/audioFiles/
    So, the myFlashPage.aspx containsthe myFlash.swf file that is inside the flashFileFolder. For some reason, it does not work. Any suggestion is much appreciated.

    The .html file does work if I publish it into the same folder as I created the Flash project. However, when I publish the
    flash .swf to my web site folder (mapped), it's no longer working. The mapped web site drive structher are as follows:
    D:\Mysite\ contains the .html file
    D:\Mysite\flashFileFolder\ contains the .swf file
    D:\Mysite\flashFileFolder\audioFiles contains the PaukenBrumfiel_AngelsOnHigh.mp3 file
    D:\Mysite\flashFileFolder\greensock-tweening-platform-as3 contains all the tweenlite files
    The .html file does not work either. What else do I need to change?

  • Clip name effect not working correctly in 2014/2014.1

    I'm referring to these notes from the latest bug fixes here...
    Bugs fixed in Premiere Pro 2014.1 Release | Premiere Pro work area
    "Clip name effect doesn’t work correctly if Source Track is set to a different track."
    "The Clip Name effect does not work when applied to a transparent video track item, with Source Track set to a video clip."
    I've just updated Premiere (2014.1) to specifically fix these two bugs. The Clip name effect isn't using the correct file names. It uses something close but not quite e.g. clip 100 shows as 100B which is down the timeline.
    The effect is applied to a transparent layer (have also tried it in a black video layer) and the clip name drawn from a different video track (video/PNGs in track 1, transparent video and effect is in track 3). This problem only appears when videos are in the timeline. When used with stills (PNGs) it works fine.
    Any idea of a fix or workaround that isn't using some kind of titling filter? I'm looking to automate the shot naming process for a pipeline in creating animation animatics and this would be perfect. If to actually worked properly.
    Using Premiere on a Mac Book Pro with 10.9.5.

    Anyone from Adobe care to offer some insight as it's something that is reportedly fixed?

  • Arrays not working in flash lite

    I could not get a multidimensional array to work in flash
    lite, then tried a regular array - it is not working either.
    This code works:
    var myVar;
    myVar = 5;
    answer_true_button_btn.onPress = function() {
    points_txt.text = String( myVar );
    This code does not work:
    var myVar:Array = new Array(5);
    myVar[0] = 5;
    answer_true_button_btn.onPress = function() {
    points_txt.text = String( myVar[0] );
    Now do multidimensional arrays.
    I have tried in Flash Lite 2 and 2.1.

    Here was the problem: I had ActionScript 1 selected (even
    though Flash Lite 2.1 was selected in the "Version" box) in the
    publish settings. Apparently, you write in AS 1 or AS 2, and
    publish in Flash Lite x.x.
    Flash Lite 1.1 does not support arrays, except for the latest
    version.

  • MOVED: MSI Live Update not working Windows XP Professional 64bit Edition!!!

    This topic has been moved to Operating Systems.
    MSI Live Update not working Windows XP Professional 64bit Edition!!!

    Thank you so much. I just want to say I really appreciate when people do take the time to post me in return. So I really mean it, Thank You.
    A quick question. You see, I have been upgrading my computer. I installed a Belkin USB USB Card (high speed 2.0) cause I needed more USB ports. Then I checked for compatable RAM and upgraded my RAM from 512MB to 2Gigs. Everything alright.
    Now, I have checked for processors that are compatable with my board K9VGM-V (MS-7253). And MSI's chart says mine is compatable with the AMD Athlon 2x 6000 (3.0Ghz) *IF* I use the 89 watt and not the 125 watt. Here is a good URL for the processor details I found:
    http://www.cpu-world.com/CPUs/K8/AMD-Athlon%2064%20X2%206000+%20-%20ADA6000IAA6CZ%20(ADA6000CZBOX).html
    Now do you have any tips and I will probably have to flash to BIOS for sure after this upgrade won't I?

  • Clipping Mask is NOT working

    This is so strange , i can't get the clipping mask feature to work on my pc. I tried it on another one and it worked.
         This is before i apply the mask to my rectangle.
         After i apply it , the image dissapears and nothing else happens.
    I've been trying for 4 hours to fix this and it keeps refusing to work properly.

    Without trying to analyze just what you're doing with the clipping mask functionality, an initial response:
    If it fails for you on one computer but not another, assuming you're doing exactly the same things to the same file, that says there's a problem with the computer.
    Try disabling OpenGL Drawing temporarily in the Edit - Preferences - Performance menu.
    If that works around the issue, go to the web site of the maker of your video card and download and install an updated video driver.  Assuming your video card is still being supported by the manufacturer, updated video drivers usually solve strange display issues like this.
    -Noel

  • Help! Pavilion Dv7 Integrated mic array not working!

    Ok ive looked at many forums and couldnt find a solution i recently booted my laptop and didnt have a driver backup so i manually downloaded and installed all the correct drivers everything seems to be functioning correctly accept the mic. in the recording section of the sound control panel all i see is external mic, integrated mic, and stereo mix. my problem is that when i listen to my int. mic array all i hear is static, i turned down the levels and it still didnt work; i updated but the problem kept occuring. any help; i think its the idt codec idk but help please!

    Raddy_Srey
    The following steps were posted by @DavidPK. I am copying the steps I want you to try rather than just linking you the thread as it is quite long. I am also providing a link to the thread below.
    “Right click the speaker icon in the Taskbar and select Playback Devices. Click the Recording tab, right click the 'Integrated Microphone array' and select Properties. Click the Microphone Enhancements tab and put a tick in the box next to 'Disable microphone enhancements'. Click Apply and Ok to save this change and the restart the notebook - has this made any difference?”
    The thread named “ internal microphone not working on pavilion dv7” is linked below.
    http://h30434.www3.hp.com/t5/Notebook-PC-Sound-and​-Audio/internal-microphone-not-working-on-pavilion​...
    If this does not resolve your issue please re-post so we can continue.
    Please click the "Thumbs Up" on the bottom right of this post to say thank you if you appreciate the support I provide!
    Also be sure to mark my post as “Accept as Solution" if you feel my post solved your issue, it will help others who face the same challenge find the same solution.
    Dunidar
    I work on behalf of HP
    Find out a bit more about me by checking out my profile!
    "Customers don’t expect you to be perfect. They do expect you to fix things when they go wrong." ~ Donald Porter

  • Basic invisible button movie clip frame actions not working, pls. help!

    Hi,
    I've got a basic little slide show player which is timeline-based, rolling through 5 images with alpha transitions, and on the topmost layer, I have 5 invisible movie clips which have actions applied to them as follows:
    on (press) {
        gotoAndPlay(21);
    This action should allow for the on click button to navigate to that specific frame, or image, but for some reason it is not working.
    Did I do something wrong? I feel like I've done this before but I'm rusty with Flash since I don't use it all the time.
    Any help is greatly appreciated!
    Thanks,
    Sean

    The invisible movie clip is something I know I've done over the years on many occasions - I'm not sure I'm understanding your alternate technique, can you explain it better? The way my movie clips are invisible is just by setting the alpha to zero in the properties for the movie clip instance (clicking on the object on stage, then setting it in properties)..
    Also, the actions are on the invisible movie clips (buttons) and not the timeline.
    Cheers,Sean

  • Toggle clip keyfram button not working...

    I recently upgraded to the latest version of fcp and I'm trying to do a variable speed change.
    My toggle clip does not work. When I click on it, nothing happens. the tick marks that show the speed are not showing up. (I have also tried opt T) anyone know if I have a setting wrong???
    Thanks

    Thanks, that was it...
    I right clicked and had to select "keyframe editor" and "speed indicators" under video.
    Solved

  • Intergrate​d microphone array not working

    I have an Hp elitebook. I went through are various directions to edit the properties concerning my microphone, but it will not work. I use headphones, which are in the correct jack. I enabled the device, went to my system bios and disabled and re-enabled it. Nothing is working, please help

    Hello @Rilsere 
    To get your issue more exposure I would suggest posting it in the commercial forums since the EliteBook is a commercial product. You can do this here Notebook - HP ProBook, EliteBook, Compaq, Slate/Tablet PC, Armada, LTE
    When you put your post in that forum be sure to include the full product number and operating system for your notebook to save time.
    How Do I Find My Model Number or Product Number?
    Is the Windows Version on My Computer 32-bit or 64-bit?
    I hope this helps!
    Thank you for posting on the HP Forums.
    Malygris1
    I work on behalf of HP
    Please click Accept as Solution if you feel my post solved your issue, it will help others find the solution.
    Click Kudos Thumbs Up on the right to say “Thanks” for helping!

  • Moving Clips - and how not to lose the audio? Help needed!

    Hi,
    I have used Premiere Pro 6.0 quite extensively over the years and have recently moved to Premiere Pro CS5.
    With Premiere Pro 6.0 I could move/drag clips on the time-line and their linked audio would move with them.  If I moved the video clip to another video track, say, above an existing clip, the audio would also move to a free audio track and not automically write over any existing audio.  This would allow me to easily reorder clips on the timeline by simply moving them around and using other video tracks as temporary storage locations... and not lose or write over any other existing audio.
    However in Premiere Pro CS5 if I do the same thing, the video will move to the other video track I move it to, but the audio will stay in the say audio track and will write-over any existing audio when the mouse button is released.  The only way around this I can find in the manual is to: (1) drag the video to the other video track, and (2) press and hold the <SHIFT> key, whilst, (3) draging the linked audio to another audio track to avoid existing audio from being over-written.
    My question:  Is there a configuation I can set in CS5 to allow moving/draging of clips to work like in Premiere Pro 6.0?  I have already messed up multiple times in CS5 by inadvertently over-writing existing audio.
    Your expert advice and recommendations would be greatly appreciated.
    THANKS IN ADVANCE.

    Harm,
    Your reply is not helpful.  Just so you know, I have read through the manual extensively and could not find an answer for my question.  AND that's why I brought my question here.
    Perhaps I missed something in the manual.  Would you mind re-reading my question and helping me if it is so easy?!
    This has been frustrating for me for the last three months and I thought I would come to this forum for some expert advice.  So far I have been told that CS5 is designed to be like this (does not answer my question), and now you tell me to look up the manual (again does not answer my question).
    I'm amazed by responses that miss the question entirely and give helpful suggestions like that!

  • Sorting array not working when run as a job

    I have a Powershell script that reads data from a log file, extracts a username and adds it to an array. I then sort the array to remove duplicates and export the data to a CSV file. The script works fine when run locally on the server but I need to call
    the script remotely for a number of servers and when I do this it does not output anything to the CSV. The script is run as a job.
    $ArrList = [System.Collections.ArrayList]@()
    # open file and read data
    $arrlist.Add("$final")
    $arrlist | sort -unique | out-file c:\scripts\iis_users.csv
    If I change the script to use add-content it can add entries to the same CSV file. But ideally I need to sort the output as there are many duplicates.

    Not sure why but that would only export the last user. I didn't have time to investigate so instead I decided to only add users to the array after first checking they didn't exist already:
    if ($arrlist -notcontains $final)
    $arrlist.Add("$final")
    add-content c:\scripts\iis_users.csv "$final"
    I thought this would create a performance hit but it seems almost as fast.

  • AS3 Timer to change frames not working correctly. PLS help

    HI I am having a big of trouble with this code to change frames on my timeline. I thought my code below would work fine but its not. For some reason it will go to frames 1-4 (4 is the last frame) then it will go back to 1 again just fine as its supposed to... but then will jump to 3 then back to 1... all random instead of staying in sync.  I have attached both my as2 version and my as3 version. My as 2 is working perfectly. I can define the amount of time a frame will pause for on each frame. ... the as3 though I am having no luck. Any help or advice would be appretiated! Thank you
    here is my as 3 code;
    stop();
    var frameTimer:Timer = new Timer(1000);
    frameTimer.addEventListener(TimerEvent.TIMER, frameChange);
    function frameChange(e:TimerEvent):void
        if(currentFrame == totalFrames)
            gotoAndStop(1);
        else
            nextFrame();
    frameTimer.start();
    here is my as 2 code;
    stop();
    function GotoFrame ()
        StopTimer ()
        var frame:Number = _root._currentframe;
        var total:Number = _root._totalframes;
        var Next:Number = (frame % total) + 1;
        _root.gotoAndStop (Next);
    function StartTimer (Time)
        _root.myTimer = setTimeout (GotoFrame, Time);
        _root.stop ();
    function StopTimer ()
        clearTimeout (_root.myTimer);
        delete _root.myTimer;
    StartTimer (1000);

    Oh I didn't think about that! ... I suppose it is ok to overlook things like this while im still learning
    Thanks for that answer. Perfect! .. that was driving me crazy.
    any chance you could help me solve the next task of defining the amount of time each frame will pause on each frame. In my action scrip 2 code I could put timerFunctioName(5000); and it would pause only that frame for that amount of time and I was able to put different time pauses on each frame in this way.

  • Set range selection on a clip using "X" not working!

    So I just downloaded FCPX this afternoon and am trying to select a range on a clip in the Event Browser to then drag that selection down to the Timeline.  On a 20 second clip, I press the "I" at 7 seconds in, then I press "O" at 14 seconds.  That's the part of the clip I want.  So then the FCPX Online User Guide tells me to do this:
    In the Event Browser or the Timeline, move the skimmer (or the playhead) over a clip and press X.
    Final Cut Pro sets the range selection start and end points at the clip start and end points.
    Note:  To use this X key method with connected clips or clips in a connected storyline, move the pointer directly over the clip and press X.
    BUT, when I press X, it discards my "I" and "O" points and puts the yellow selection box around the entire clip again!  It's very frustrating.  Please help me, what am I doing wrong, or is this a bug?  I'm up against a deadline and this is preventing me from moving forward because it won't "store" or remember, I don't know what to call it, my in and out points and the yellow bounded selection range on the clip!
    Thank you!
    Paul

    Huh?  Tom, thank you, but I'm not supposed to use the manual?  I desperately need a User Guide.  Is there one? And you did not explain what X does then, or what I am supposed to do?  If the X does not do what that manual says, then how do I set the In and Out points on the clip?
    Confused,
    Paul

  • How to get around audio clips' audio changes not working

    Here is how I got around the annoying (and recurring) problem of audio clips not being adjustable. First, it's a good idea to add your music track as the very last thing you do. Often, when I am editing a video together, as soon as I drop in a full length music track, I'm no longer able to make changes to my audio clips. So now I drop in the music track as the very last thing I do to my project. If I want to test a music track in the file, then I drop it in, press Command G to preview my project, and when I'm done previewing the project with the music track, I immediately press Command Z to undo the addition of the music track. If, for whatever reason, I'm still having problems with audio clips no longer updating changes I make to them, I have discovered a trick that works: make the changes to the clip's audio, then copy the clip, then delete it, then paste it. The pasted version should now have the updated audio adjustments. Worked for me, anyway.

    Hi,
    Have you tried the very first link ? Please try it now if still no luck please use    Scan now    from the following link:
       http://h10025.www1.hp.com/ewfrf/wc/softwareCategory?cc=us&lc=en&dlc=en&product=5318926
    Regards.
    BH
    **Click the KUDOS thumb up on the left to say 'Thanks'**
    Make it easier for other people to find solutions by marking a Reply 'Accept as Solution' if it solves your problem.

Maybe you are looking for

  • No longer able to boot - failure with /boot

    I recently, due to a hard drive change, rebuilt my desktop.  Every now and again, since then, it hasn't booted.  I just logged into root and rebooted; figuring I'd sort it out at some point. Only, now it won't boot at all.  When I go through journalc

  • Fontsare to small and I can't change them and unable to submit feedback in help

    Am really upset. I submitted a question and tried to browse through questions asked and answers given. There appears to be no way to do that from the help screen. What trash. I even went to Feedback to complain but coud not even get Submit feed back

  • How to define match code in Vendor master

    Hi All, I want to put a check in vendor master if we are creating new vendor and this is having a same name and address of existing vendor then it should be give error message through matchcode. So we want to know how we can configure matchcode in sp

  • Issue with Adobe flex redeployment

    when I redeploy Flex web application by copying all files from bin-release to IIS , after refreshing or re-open the browser(chrome/IE)the client side still using the previous files, I have to clear web browser history to get the latest files, my serv

  • Tracking the workflow in running status

    HI guys,              My workflow will trigger , when ever a SO is posted in Va01.So once the user goes to Va02 and changes the same SO which is in running status.A warning message has to be displayed like ' Workflow is running  and its in approval p