Page 2 of 2 FirstFirst 12
Results 11 to 13 of 13

Thread: Target a specific frame in an MC for display

  1. #11
    Join Date
    Jan 2008
    Location
    Near Chicago
    Posts
    247
    Thanks
    105
    Thanked 2 Times in 2 Posts

    Default One question about the code

    each time mc icons

    as in

    icons.addEventListener(MouseEvent.CLICK, showImage);


    var photo:MovieClip = new MovieClip();
    addChild(photo);


    function showImage(e:MouseEvent):void {

    photo.alpha = 0;


    var loader:Loader = new Loader();

    loader.load(new URLRequest(icons.getChildAt(0).name + ".jpg"));


    loader.contentLoaderInfo.addEventListener(Event.COMPLETE, fadeImage);


    photo.addChild(loader);

    photo.addEventListener(MouseEvent.CLICK, hideImage);
    }

    I understand where it works but I am curiose as to how.

    It makes to refference to each photo, yet each picture corresponds perfectly with each icon.I see that with icons.getChildAt(0).name+"jpg")); it calls up a picture in order but how does it know which one is first second etc.?

    the photos are all named Monroe, Elvis etc.

  2. #12
    Join Date
    Mar 2007
    Location
    Currently: New York/Philadelphia
    Posts
    2,735
    Thanks
    3
    Thanked 519 Times in 507 Posts

    Default

    Ok...let me break this down.

    There are a few things at play here.

    1. The next button on the main timeline.
    2. The icons (one each on each frame) in the icons movieclip
    3. Each icon has an instance name that is the same as the .jpg image I want to call

    The "next" button manipulates what frame the icons movieclip is on. When you click on an icon, it runs the showImage() function.

    What the showImage() function is saying is this: load an image with the filename equal to the instance name of the movieclip on _level0 of the icons movieclip. So, it goes to the icons movieclip, looks to see what movieclip is currently showing, and then gets it's instance name. Next, it loads the_instance_name.jpg onto the stage.

    So icons.getChildAt(0).name refers to whichever movieclip is on _level0 of icons.

    Does that answer your question?

  3. The Following User Says Thank You to Medyman For This Useful Post:

    evan (07-03-2008)

  4. #13
    Join Date
    Jan 2008
    Location
    Near Chicago
    Posts
    247
    Thanks
    105
    Thanked 2 Times in 2 Posts

    Default

    It does, big time. I love seeing examples where more than one thing gets done and(to me) it's not apparent right away. Good stuff.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •