Results 1 to 2 of 2

Thread: how to get an id into a duplicate movieclip

  1. #1
    Join Date
    Apr 2008
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default how to get an id into a duplicate movieclip

    hi there

    i've got a small problem,
    i'm creating buttons with duplicate movieclip
    but when i use a onPress function i can't send my id with it.

    Can someone help me please, i'm stuck

    See my script below

    PHP Code:
    var total this.aantal_news;
    for (
    i=0i<totali++) {
        if(
    old_y==undefined){
            
    old_y=0;
        }
        
    duplicateMovieClip(_root.nieuws.txtMC"txtMC"+ii);
        
    _root.nieuws["txtMC"+i].news_item.styleSheet Style;
        
    _root.nieuws["txtMC"+i].news_item.autoSize=true;
        
    _root.nieuws["txtMC"+i].news_item.htmlText this["message"+i];

        
    trace("***********************")
        
    trace("1: i="+i)
        
    trace("ID:"+this["id"+i])
        
    //HERE i've got my ID
        
    trace("***********************")                        

        
    _root.nieuws["txtMC"+i].news_item._y old_y+20
        old_y
    =old_y+_root.nieuws["txtMC"+i].news_item._height;
        
    _root.nieuws.gotoAndPlay(2);
        
        
        
        
    //With this i get my i into my onPress
        
    _root.nieuws["txtMC"+i].i;
        
        
    _root.nieuws["txtMC"+i].onPress = function() {
            
    // NOW HERE IS WHERE I NEED MY ID AGAIN
            // but can't get id inhere 
            
    _root.nieuws.gotoAndPlay(10);
            
            
    ItemData1 = new LoadVars();
            
    ItemData1.onLoad = function(){        
                
    Style = new TextField.StyleSheet();
                
    Style.load("style.css");
                
    _root.nieuws.news_items1.styleSheet Style;
                
    _root.nieuws.news_items1.autoSize=true;
                
    _root.nieuws.news_items1.htmlText this.message;
                
                
    trace(_global.base_url+"news.php?r=" random(999)+"&id="+ids)
            };
            
    ItemData1.load(_global.base_url+"news.php?r=" random(999)+"&id="+this[id+this.i]);
        }

    Last edited by mrtvo; 04-05-2008 at 05:57 PM. Reason: nicely ask people to help me?

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

    Default

    I haven't tested your code, but what I usually do in this instance is to use eval()
    Code:
    var x:MovieClip = eval("txtMC" + i);
    x.id = i;
    x.onPress = function() {
         trace("I just clicked on txtMC" + this.id);
    }

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
  •