Referencing a movie clip by using a variable

I have been using this line of code to fade in a movie clip:
new Tween(background_mc, "_alpha", None.easeNone, 0, 100, .5, true);
Now, I want to accomplish the same thing, only this time by using an element from an array (bg_array[currentSlideNumber]) that stores the instance name "background_mc"
I've tried the following, but it doesn't work:
new Tween(bg_array[currentSlideNumber], "_alpha", None.easeNone, 0, 100, .5, true);
What am I doing wrong?
Thanks

You are telling flash to look inside that array and tween the _alpha property of the string -- because instance names are strings -- "background_mc" from 0 to 100. But generally speaking a string doesn't have an _alpha property.
What you really want to do is tell flash, look inside this array find the string then use that string to look inside another array -- the array of all objects on some timeline -- to find a clip and then tween its _alpha property. That sounds like a lot, but it only adds a little bit to your code.
new Tween(this[bg_array[currentSlideNumber]], "_alpha", None.easeNone, 0, 100, .5, true);
I'm assuming the code is on the same timeline as background_mc?
Annother approach would be to store instance references instead of the names. I'm not sure how you are creating the background, but instead of putting the name into the array, put a reference. So if you were using attachMovie you could do something like this.
var bg_array:Array=new Array()
var tempVar:MovieClip=this.attachMovie("background","background_mc",100);
bg_array.push(tempVar);
Finally, and not to anything you've asked about, but don't you find the suffixes annoying? Why, bg_array and background_mc? If you type your variables you will still get code completion and you will have less to type and your code won't be so long. I just find that having to type those underscores and all makes me likely to make mistakes and makes it much harder to read the code. Just a thought.

Similar Messages

  • How to find out where movie clips are used?

    When I look at FLA project tree, I see Use Count column next to a movie clip. How do I find where this movie clip is used?

    Hi,
    You can use Edit > Find and Replace panel and set Symbols to Search
    Hope this Helps
    Thanks!
    Mohan

  • Referencing duplicated movie clips

    I am using the following script to duplicate the movie clips
    pixel.duplicateMovieClip("pixel"+i,
    this.getNextHighestDepth(), {_x
    , _y:m});
    how can I get the x and y values for the duplicated clips, I
    tried assigning a text box with variable xget an d wrote the
    script:
    xget = pixel+i._x
    how should I be scripting this?

    you could do something like:
    xget = eval("pixel" + i +"._x");
    -or-
    xget = this["pixel" + i]._x;
    Either one could work...

  • How do I remove a the contents of a movie clip created using loadClip?

    I have a Flash site that loads specific SWFs into a movie
    clip called "content_mc" based on a button click. I do this using
    the "loadClip" method. I then remove (I thought) the SWF from the
    movie clip with "unloadClip" and replace it with a new SWF using
    "loadClip." All seemed to be working fine, but now I see that
    scripts from a SWF that I thought I unloaded are still running.
    I'm sure this is due to my lack of understanding of what
    "loadClip" and "unloadClip" are doing. And there certainly may be a
    better way to do what I want to do... but such is life. What is the
    method to delete a the contents of a movie completely from memory?
    or is there a better way to do what I want to do?
    Thanks for your help,
    David

    Nope you understand more or less correctly. unloadClip takes
    away the contents that loadClip placed. However there are certain
    things that don't go away.
    My guess is that you have some setIntervals. Those must be
    cleared (clearInterval) before you do the unloadClip.
    Or perhaps you have set up some listeners? Again those must
    be removed.

  • How do I backup movies/clips to use in future projects?

    After burning my first DVD & deleting the iMovie file, I was sad to discover that I could not just pop the DVD into my drive & access the material to use in future projects. (Is there a way to do do this that I don't know about?)
    I'm guessing I need to burn the archived iMovie file onto multiple regular CDs (I have not burned anything that spans several CDs before). This is confusing me because the zipped file is hardly smaller than the original (Is there a better zip program than the one that comes with this system?) I threw away the wrapper for my blank CDs so I don't know how much they hold but I think it is something ridiculously small like 670MB and the iMovie file is 7GB. Is this the only way to save my movie/clips so that I can bring clips into a future movie?
    1.8 GHz Power PC G5   Mac OS X (10.3.9)   256 MB DDR SDRAM

    welcome Novice to the  board ....
    hmm, multidimensional question ...
    DVD is end-of-the-road, not meant for further processing; there are tools, allowing to import DVD to iM, but that is a time-consuming and lossy (=losing pic quality) process, due to the deliver-format nature of DVDs.... search forum for "DVD import"
    iM is by concept not meant to handle a clip in many projects (that can easily been accomplished with pro tools as FC(E), which offer "bins" for imports, offering the content to many sequences/projects).
    there are workarounds, dragging clips from the internal files of an iM project to another... but, as said: you "fumble" the concept: import tape, edit, burn - done.
    a video contains ~13GB of data per hour... and, video is allready highly compressed, no zipper can reduce that dramatically... and, you risk damage of files... yepp, a cd-r fits ~700MB = 3.5min of video......
    recommended workflow:
    * don't store iM projects on -r media (cd/dvd), but firewire connected harddrives..
    * keep the tapes; import clips from tape into project; you can export single clips out of iM/import into another project, I wouldn't do that with "lots" of clips, importing the tape is... more convenient..

  • Playing Movie clip backward using buttons?

    Im trying to create a series of images that scroll acoss the page left and right using arrows at either side of the stage. The arrows use mouse over events to play a movie clip of the images foward and backward.
    There are a few issues I am having. I have a mouse over and mouse out events in place to start and stop the clip on to different buttons. However when playing the clip backward with my current script the mouse out doesnt do anything so the clip just keeps playing backward to the beggining. Once this has happened neither button then does anything.
    Another issue is once the clip has played foward once in total and I mouse over the same arrow button again it flicks back to the begginging of the clip.
    Here is my current scrpit:
    panel.stop();
    leftarrow_btn.addEventListener(MouseEvent.MOUSE_OVER, fl_MouseOverHandler_7);
    leftarrow_btn.addEventListener(MouseEvent.MOUSE_OUT, fl_MouseOutHandler_4);
    function fl_MouseOverHandler_7(event:MouseEvent):void
              panel.play();
    function fl_MouseOutHandler_4(event:MouseEvent):void
              panel.stop();
    rightarrow_btn.addEventListener(MouseEvent.MOUSE_OVER, fl_MouseOverHandler_9);
    rightarrow_btn.addEventListener(MouseEvent.MOUSE_OUT, fl_MouseOutHandler_7);
    function fl_MouseOverHandler_9(event:MouseEvent):void
       panel.addEventListener(Event.ENTER_FRAME, everyFrame);
    function everyFrame(event:Event):void
              panel.prevFrame();
    function fl_MouseOutHandler_7(event:MouseEvent):void
              panel.stop();
    Please Help!!
    Patrick

    use:
    panel.stop();
    leftarrow_btn.addEventListener(MouseEvent.MOUSE_OVER, fl_MouseOverHandler_7);
    leftarrow_btn.addEventListener(MouseEvent.MOUSE_OUT, fl_MouseOutHandler_4);
    function fl_MouseOverHandler_7(event:MouseEvent):void
              panel.play();
    function fl_MouseOutHandler_4(event:MouseEvent):void
              panel.stop();
    rightarrow_btn.addEventListener(MouseEvent.MOUSE_OVER, fl_MouseOverHandler_9);
    rightarrow_btn.addEventListener(MouseEvent.MOUSE_OUT, fl_MouseOutHandler_7);
    function fl_MouseOverHandler_9(event:MouseEvent):void
       panel.addEventListener(Event.ENTER_FRAME, everyFrame);
    function everyFrame(event:Event):void
              panel.prevFrame();
    function fl_MouseOutHandler_7(event:MouseEvent):void
    panel.removeEventListener(Event.ENTER_FRAME,everyFrame);

  • Randomize a Movie Clip Animation Using Actionscript

    I'm new to actionscript.
    I've been working on this sort of sunset-like sequence in
    Flash. I've created a movie clip of a star that has a sort of
    twinkle animation. It consists of 3 layers. What I want to do is
    randomize this animation so I can use the symbol spray tool to fill
    my sky with twinkling stars. If I just to a "gotoAndPlay" repeat,
    they all twinkle at the same time, and this looks pretty stupid.
    My limited knowledge and experience with Actionscript tells
    me that I need to define the animation as a function and use some
    sort of math randomizer to control when it plays?
    I have some books on actionscript I'm yet to work through, as
    this is sort of a hobby of mine that I'm teaching myself, but I
    haven't had the time nor energy to wrap my brain around it yet.
    Thanks for any help!

    Well, I've now decided to only have a few stars twinkling, so
    it's no longer going to be that much of an effort to do a couple of
    different movie clips that twinkle at different periods of time. I
    just had the brilliant idea to do constellations that highlight and
    serve as the button navigation for my portfolio website, and I plan
    to have it seem like your panning up above the horizon and looking
    up into the sky, and having about a hundred twinkling stars moving
    and twinkling at the same time would probably prove super taxing on
    most computers lol...
    I'd still like to hear from anyone who may know how to do
    this as it would still come in handy to me.

  • Encode movie clips for use in PDF presentation?

    I've tried several formats for use in PDF.
    FLV, F4V and H.264. But i always experience massive lag in Full Screen Mode. Even when I encode with low rate settings.
    Any best practises?

    Those are the only formats supported in Rich Media Annotations. Within the Acrobat Family they render using Flash Player, so the performance should be similar to a full-screen display of the same video from another source (e.g. on a website).
    What do you mean by 'massive lag'? Are the audio and video tracks out of sync, is the playback slow or buffering? You must expect an initial delay when the RMA activates, as the video file must be decompressed from the PDF file's data stream and transferred to memory for Flash Player to open. That can take anything up to three seconds depending on the hardware and size of the stream.

  • [AS3] how do i use this angle in another lower level movie clip?

    i'm tryin to use an angle from one movie clips to be part of
    an if statement in another lower level movie clip. my code is
    probably ugly but here it is. thank you in advance for the
    help

    i need to learn how to declair a variable (like angle) in a
    lower level movie clip to use it in other movie clips is this not
    correct?
    var angle:Number;
    please help

  • Update variables in Movie Clip

    Hi!
    Is there anybody who can help me with a simple (?) problem:
    I have loded a movieclip into a movie:
    var mcl:MovieClipLoader = new MovieClipLoader();
    mcl.loadClip("Legend_movie.swf",legend_mc);
    In the main movie a variable is changed by on EnterFrame:
    figure_mc.onEnterFrame = function() {
    size = circle_map_mc._width;
    The variable "size" is also used by the movie clip.
    Can anybody tell me how the movie clip can be updated for
    each "onEnterFrame"?
    At the moment the movie Clip only reads the variable "size"
    at the first frame...
    tm

    Hi!
    Actually it is circle_map_mc that is declared on the main
    timeline and changes in a motion tween....
    In my movie clip I have tried:
    shadow_mc._width = _level0.circle_map_mc._width;
    and
    shadow_mc._width = _root.size;
    Both updates the movie clip once, but I need a continous
    updating as long the variable is changing (along the time line) in
    the main movie... Any cloue?

  • Dynamic movie clip removal

    I'm working on a Flash/XML photo album that loads image
    thumbnails dynamically by creating individual movie clips for each
    thumbnail. The thumbnails are divided into 10 groups. Every time a
    new group of thumbnails is selected from the album the XML array is
    upadated with the correspondig image file name and path. The only
    problem is that since there are different number of photos in each
    thumbnail group the extra image_mc's created dynamically remain,
    even if they are not from the specific group. For example for group
    1 I have 6 thumbnail images, group 2 contains 4 thumbnail images.
    If I start with group 1 and then select group 2, the 4 thumbnails
    from group 1 are displayed plus number 5 and 6 from the previous
    group. What's the best way to remove all the image_mc's created
    dynamically before each new thumbnail load. This is what I have so
    far and it doesn't work:
    // thumbnails is the array
    function thumbDisplay(thumbnails){
    var galleryLength:Number = thumbnails.length;
    removeMC();
    // loop through each of the images in the gallery_array.
    for (var i = 0; i<galleryLength; i++) {
    /* create a movie clip instance which holds the image, also
    set a variable,
    thisMC, which is an alias to the movie clip instance. */
    thisMC = this.createEmptyMovieClip("image"+i+"_mc", i);
    /* load the current image source into the new movie clip
    instance,
    using the MovieClipLoader class. */
    mcLoader_mcl.loadClip("photos/"+selectedGallery+"/thumbs/"+thumbnails
    ,thisMC);
    function removeMC():Void{
    for(var i=0; i<thumbnails.length; i++){
    thisMC.removeMovieClip("image"+i+"_mc");
    Any help would be great. Thanks.

    try:

  • How to play movie clips for a certain amount of time only

    Hello everyone, I think I have a relatively basic question here but I can't figure it out. I have a movie clip loaded using action script 3 at the start of my animation, I want ito to end at the 120th frame. But I can't use the stop(); command because it will also stop the rest of my animations from the 121st frame onwards. So my problem is, how can I stop the movie clip without stopping the rest of my animations?
    Thank you in advance!

    I don't think I have codes that load the swf, but I've sent you the code that I would like to stop. Thanks!

  • Help with smooth scrolling (masked movie clip)

    Ok, I really need help here, and I'll be very grateful for
    help before Monday.
    Someone has made a movie with a different set of text on each
    frame, the text goes out of the viewable area.
    I have been asked to make these frames appear in a pop-up on
    another flash and be scrollable.
    i thought this would be easy...just cut and paste them into a
    movie clip, then using a mask to hide the rest of the text.
    However, it is going painstakingly slow.
    Seems to be a performance issue, but it might be my code.
    Any help with the code, or optimisation elsewhere would be
    helpfully.
    Heres a simplified version of the flash;
    www.darkflame.co.uk/flashwork/Flash_popuptest.fla
    Code for the scrolling;
    _global.MoveUp = function(text) {
    _root.ITproduct.IT_productlist._y =
    _root.ITproduct.IT_productlist._y+6;
    updateAfterEvent();
    //trace('press');
    Called and stopped by;
    on (press){
    //this._parent.IT_productlist._y =
    this._parent.IT_productlist._y +10;
    //_global.scrollon = "yes";
    clearInterval(IntervalID);
    IntervalID = setInterval(MoveUp,100);
    updateAfterEvent()
    //updateAfterEvent();
    //MoveUp();
    //scroll on
    on (release) {
    //this._parent.IT_productlist._y =
    this._parent.IT_productlist._y +10;
    clearInterval(IntervalID);
    updateAfterEvent();
    //scroll off
    which is linked to a button.
    I dont know if this is a actionscript problem, or the way the
    page is made, or both.
    Any help would be appreciated.
    Thanks in advance,
    Thomas Wrobel

    you have extraneous graphics on-stage that are slowing the
    scrolling (and even causing problems in the authoring environment).
    here's your file with those graphics removed:
    http://www.gladstien.com/Files.popupTest.fla

  • Finding the width of a JPEG loaded into a movie clip

    I will be loading a page of bio information. Next to the
    person's photo (photos will vary in width) I want to put a column
    of buttons about 20 pixels to the right of the photo. So after I
    load the photo into an empty movie clip, I'm trying to get the
    width of the photo in order to figure out the x position of the
    buttons next to it. Here is what I have:
    myImage = "images/" + _level0.images[link];
    loadMovie(myImage,image_mc);
    // JPEG loads okay into image_mc //
    trace("image_mc._x = " + image_mc._x);
    // I get "Image_mc._x = 393" as expected //
    trace("myImage._width = " + myImage._width);
    // I get "image_mc._width = undefined" //
    trace("image_mc._width = " + image_mc._width);
    // I get "image_mc._width = 0" //
    How do I find the width of the loaded JPEG?

    you are probably trying to get the width before the image has
    loaded completely.. use the MovieClipLoader class to load the image
    into the empty movie clip, then use the onLoadInit event to get the
    movie clips's width(which is the images width);
    var mcLoader:MovieClipLoader = new MovieClipLoader();
    var myListener:Object = new Object();
    myListener.onLoadInit = function(target:MovieClip):Void{
    trace(image_mc._width);
    mcLoader.addListener(myListener);
    mcLoader.loadClip(myImage, image_mc);

  • Trying to access a specific movie clip with a string

    Ok, what I am trying to do is create as many movie clips as I
    need and then access those movie clips using string values. These
    string values are stored in an array and coincide with a given
    movie clips instance name. Check out the following code:
    I think my problem is that Flash is trying to call movie clip
    methods on a string instance. I'm not sure how to type cast in
    Flash, or even if it is possible, but how would I access the
    strings as movie clips?

    DuhChamp,
    > I think my problem is that Flash is trying to call movie
    > clip methods on a string instance.
    Bingo.
    > I'm not sure how to type cast in Flash, or even if it is
    > possible, but how would I access the strings as movie
    > clips?
    Use eval() or the array access operator, []. Details here
    http://www.quip.net/blog/2006/flash/actionscript-20/reference-objects-dynamically
    David
    stiller (at) quip (dot) net
    Dev essays:
    http://www.quip.net/blog/
    "Luck is the residue of good design."

Maybe you are looking for

  • Startup Screen Pixelated - I really need help on this one.

    15" Macbook Pro - Spring 2011 My startup screen sometimes would be pixelated with the Apple logo and then would go to grey screen and do nothing... then I would be forced to shut down and power it up again. On two occasions, the bootup would have str

  • TDS Problem at the time of Advance to Vendor

    Hi here is a proplem at the time of Vendors Advance payment thro f-48, aft complition of document when simulating the document ,it come Vendor-----Dr,Bank A/C-- Cr, but TDS amount is not shown(At the time of its Invoicing Every things is ok,TDS is al

  • Droid Maxx Updated to 4.4.4

    The Droid Maxx Family of  Phones  has a new update  Motorola is now pushing out after the Soak Test was completed  the   4.4.4  or 21.11.21. update as I've read has some nice changes to it..  follow the Link below for those changes..  Enjoy and if an

  • Data Sync between ORACLE and SQLServer

    Hi, I would like to here the possible options for "Bi-Directional Data Sync" between ORACLE 10g (Enterprise Edition Release 10.2.0.4.0) and SQL Server 7.0 (7.00 - 7.00.961 Standard Edition on Windows NT 5.0 ). Please let me know the available tools o

  • CS4/Win 7 Upgrade in Place?

    Has anyone done an upgrade in place from Vista 64 to Win 7 64 with CS4 onboard?? Would be very interested to hear how it went.