dcsimg
A Flash Developer Resource Site

Results 1 to 9 of 9

Thread: This makes no sense to me

  1. #1
    Senior Member
    Join Date
    Nov 2001
    Location
    Houston TX
    Posts
    563

    This makes no sense to me

    I have a MC with the instance of "bar" which hold a blank MC with the instance of "pic"
    that I want to load with an image located in a foldeer called "images".

    This works:

    while (n <= num) {
    duplicateMovieClip(bar, "bar" + n, n);
    newClip = "bar" + n;
    trace(newClip);
    ystart = GetProperty(bar,_y) ;
    setProperty(newClip, _y, ystart + n*300);
    loadMovie("images/Image1c.jpg",bar1.pic);
    n = n + 1;
    trace(n);
    }


    This does not:

    while (n <= num) {
    duplicateMovieClip(bar, "bar" + n, n);
    newClip = "bar" + n;
    trace(newClip);
    ystart = GetProperty(bar,_y) ;
    setProperty(newClip, _y, ystart + n*300);
    loadMovie("images/Image1c.jpg",newClip.pic);
    n = n + 1;
    trace(n);
    }

    Anyone have a clue as to why?


    Toby
    Best regards
    Toby Mack

    For the best and funniest Audio Blog on the Internet come visit:

    http://feeds.feedburner.com/Fla****UpBlog

  2. #2
    OOP is one letter from OOPS kortex's Avatar
    Join Date
    Aug 2005
    Location
    New Hope, PA
    Posts
    2,668
    I am guessing because newClip = "bar" + n; is simply a string (or some other object) and not a reference to the new movieclip.
    Jeremy Wischusen
    Flash - Flex - LAMP - Web Developer Purple Inc
    AS OOP FAQ-Best Practices Thread | Flashkit OOP Tutorials | Purple Inc (day job) | Blog


  3. #3
    Senior Member
    Join Date
    Nov 2001
    Location
    Houston TX
    Posts
    563
    I understand it is a string but if a string is not accepted here then why would it be acceptable in this line of code:
    setProperty(newClip, _y, ystart + n*300);

    I amstill confused.

    Toby
    Best regards
    Toby Mack

    For the best and funniest Audio Blog on the Internet come visit:

    http://feeds.feedburner.com/Fla****UpBlog

  4. #4
    OOP is one letter from OOPS kortex's Avatar
    Join Date
    Aug 2005
    Location
    New Hope, PA
    Posts
    2,668
    try:
    newClip = duplicateMovieClip(bar, "bar" + n, n);
    Jeremy Wischusen
    Flash - Flex - LAMP - Web Developer Purple Inc
    AS OOP FAQ-Best Practices Thread | Flashkit OOP Tutorials | Purple Inc (day job) | Blog


  5. #5
    Senior Member
    Join Date
    Nov 2001
    Location
    Houston TX
    Posts
    563
    Nope. Isn't there a prefix that needs to in front of newClip ? Something like
    MovieClip:newClip ?

    Toby
    Best regards
    Toby Mack

    For the best and funniest Audio Blog on the Internet come visit:

    http://feeds.feedburner.com/Fla****UpBlog

  6. #6
    Senior Member
    Join Date
    Nov 2001
    Location
    Houston TX
    Posts
    563
    OK here is what I found. You have to fool flash into thinking "newClip" is a real MC.

    while (n <= num) {
    duplicateMovieClip(bar, "bar" + n, n);
    newClip = "bar" + n;
    trace(newClip);
    ystart = GetProperty(bar,_y) ;
    setProperty(newClip, _y, ystart + n*300);
    this[newClip].pic.loadMovie("images/Image1c.jpg");
    n = n + 1;
    trace(n);
    }


    The answer is:

    this[newClip].pic.loadMovie("");
    Best regards
    Toby Mack

    For the best and funniest Audio Blog on the Internet come visit:

    http://feeds.feedburner.com/Fla****UpBlog

  7. #7
    OOP is one letter from OOPS kortex's Avatar
    Join Date
    Aug 2005
    Location
    New Hope, PA
    Posts
    2,668
    this[newClip] is called an eval (I think) it converts whatever is in to an object reference. Still not sure why the other way did not work, but hey looks you got it working anywauy.
    Jeremy Wischusen
    Flash - Flex - LAMP - Web Developer Purple Inc
    AS OOP FAQ-Best Practices Thread | Flashkit OOP Tutorials | Purple Inc (day job) | Blog


  8. #8
    Senior Member
    Join Date
    Nov 2001
    Location
    Houston TX
    Posts
    563
    There are so many things to learn in flash. Now I understand Actionscript 3 is going to be a new learning cure again. Mercy.

    Toby
    Best regards
    Toby Mack

    For the best and funniest Audio Blog on the Internet come visit:

    http://feeds.feedburner.com/Fla****UpBlog

  9. #9
    OOP is one letter from OOPS kortex's Avatar
    Join Date
    Aug 2005
    Location
    New Hope, PA
    Posts
    2,668
    yeah just starting AS3 now. Looks pretty powerful, but there are some syntaxs that exists in as2 that just are not there in AS3 (e.g., duplicateMovieClip btn.onRelease= function()).
    I have a feeling that once you get used to it, it is going to allow you to do things that AS2 would make pretty tricky.
    Jeremy Wischusen
    Flash - Flex - LAMP - Web Developer Purple Inc
    AS OOP FAQ-Best Practices Thread | Flashkit OOP Tutorials | Purple Inc (day job) | Blog


Posting Permissions

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




Click Here to Expand Forum to Full Width

HTML5 Development Center