Results 1 to 3 of 3

Thread: Dynamically created objects do not get events?!?

  1. #1
    Join Date
    Nov 2008
    Location
    Bulgaria
    Posts
    7
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Dynamically created objects do not get events?!?

    Hi guys.
    I have a little bit of trouble with dynamically creating some elements and applying some event to them. The objects appear as i want to but do not accept the event i try to append! Here is the code:

    function loadThumbs(){
    for(n=0;n<total;n++){
    _root.thumb.duplicateMovieClip ("thumb"+n, _root.getNextHighestDepth());
    thisClip=_root["thumb"+n];
    thisClip._y = 481;
    thisClip._x = xPosition;
    xPosition = xPosition + 87
    thisClip.loadMovie(th[n], 1);
    thisClip._alpha = 60;
    thisClip.onRollOver = function(){
    thisClip._alpha=100;
    }
    thisClip.onRollOut = function(){
    thisClip._alpha=60;
    }
    thisClip.onRelease = function(){
    var currentBtn:String = thisClip._name;
    var currentIndex:String = currentBtn.substring(5,7);
    loadImage(currentIndex);
    }

    }
    }

    function loadImage(j) {
    if (loaded == filesize) {
    bi_holder._alpha = 0;
    bi_holder.loadMovie(image[j], 1);
    picture_num();
    }
    }

    I'd appreciate any ideas because i'm really stuck!

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

    Default

    Have you tested the value of currentBtn and currentIndex to see if it's giving you the values that you expect? I suspect that you might have a problem with the scope of some of those variables.

    Also, it might be less confusing to use the "this" keyword instead of thisClip inside of the mouse events. You don't have to, but it'll reduce the chance of mistakes.

  3. #3
    Join Date
    Nov 2008
    Location
    Bulgaria
    Posts
    7
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Object events

    Thanks for the tip. Will test to see if i can reach them. And yeah using this would be useful instead of variable. Just didn't see it there Thanks!

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
  •