A Flash Developer Resource Site

Results 1 to 10 of 10

Thread: Checkbox component problem ( label )

  1. #1
    Flashmatics silentweed's Avatar
    Join Date
    Mar 2005
    Location
    London, UK
    Posts
    4,875

    Checkbox component problem ( label )

    Hi,

    I have a movieclip in my library with linkage name mcCheck. This movieclip contains a checkbox component with instance name cmpCheckbox. Using the parameter panel for the checkbox i have removed the label text.

    Now I am trying yo dynamically populate the checkbox label but it doesnt seem to be working: any help would be appreciated..am i missing somethign obvious?

    Code:
    var checkbox  = _root.attachMovie("mcCheck", "mcCheck", _root.getNextHighestDepth());
    
    trace(checkbox.cmpCheckbox); // this gives _level0.mcCheck.cmpCheckbox hence path is correct
    checkbox.cmpCheckbox.label = "hello"; //this does not do anything the label remains empty
    
    trace(checkbox.cmpCheckbox.label); //this traces out "hello"
    Any help appreciated..

    cheers
    Flashmatics | Flashmatics Library (free downloads)
    -----------------------------------------------------
    Latest Projects:
    The Dead Room | Are You Smarter | Prison Break (Frame A Friend) | Beck's Fusions | The 24 Experience

    -----------------------------------------------------
    Flash Certified Developer

  2. #2
    OOP is one letter from OOPS kortex's Avatar
    Join Date
    Aug 2005
    Location
    New Hope, PA
    Posts
    2,668
    Seems to have something to do with nesting it in another clip because if I try:

    var checkbox = _root.attachMovie("CheckBox", "mcCheck", _root.getNextHighestDepth());

    trace(checkbox);
    checkbox.label = "hello";
    trace(checkbox.label);

    It all works
    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
    Flashmatics silentweed's Avatar
    Join Date
    Mar 2005
    Location
    London, UK
    Posts
    4,875
    Cheers for that..thats really incovenient if the 'nested' thing doesnt work..because the container mc in my app will contain other stuff related to the checkbox within it..it will be hassle to do it any other way..
    Flashmatics | Flashmatics Library (free downloads)
    -----------------------------------------------------
    Latest Projects:
    The Dead Room | Are You Smarter | Prison Break (Frame A Friend) | Beck's Fusions | The 24 Experience

    -----------------------------------------------------
    Flash Certified Developer

  4. #4
    OOP is one letter from OOPS kortex's Avatar
    Join Date
    Aug 2005
    Location
    New Hope, PA
    Posts
    2,668
    Try this if you need it nested (remove checkbox from original clip):
    _root.attachMovie("mcCheck", "mcCheck", _root.getNextHighestDepth());
    var checkbox = _root.mcCheck.attachMovie("CheckBox", "cb", _root.mcCheck.getNextHighestDepth());

    trace(checkbox); // this gives _level0.mcCheck.cmpCheckbox hence path is correct
    checkbox.label = "hello"; //this does not do anything the label remains empty
    trace(checkbox.label); //this traces out "hello"

    I tried it and it seems this works. Not sure why the other way does not.
    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
    Flashmatics silentweed's Avatar
    Join Date
    Mar 2005
    Location
    London, UK
    Posts
    4,875
    thanks mate.. yeh weird the first one should work especially since it traces out the correct label.. maybe ill just create a dynamic text field next to the nested checkbox i guess(as essentially it will have the same effect) ... cheers for the help
    Last edited by silentweed; 07-19-2006 at 11:04 AM.
    Flashmatics | Flashmatics Library (free downloads)
    -----------------------------------------------------
    Latest Projects:
    The Dead Room | Are You Smarter | Prison Break (Frame A Friend) | Beck's Fusions | The 24 Experience

    -----------------------------------------------------
    Flash Certified Developer

  6. #6
    Flashmatics silentweed's Avatar
    Join Date
    Mar 2005
    Location
    London, UK
    Posts
    4,875
    Im now using a dynamic text field instead of a label for the above..but for learning purposes was just wondering WHY my origianl code doesnt work ..

    cheers in adavnce
    Flashmatics | Flashmatics Library (free downloads)
    -----------------------------------------------------
    Latest Projects:
    The Dead Room | Are You Smarter | Prison Break (Frame A Friend) | Beck's Fusions | The 24 Experience

    -----------------------------------------------------
    Flash Certified Developer

  7. #7
    Flashmatics silentweed's Avatar
    Join Date
    Mar 2005
    Location
    London, UK
    Posts
    4,875
    bump..
    Flashmatics | Flashmatics Library (free downloads)
    -----------------------------------------------------
    Latest Projects:
    The Dead Room | Are You Smarter | Prison Break (Frame A Friend) | Beck's Fusions | The 24 Experience

    -----------------------------------------------------
    Flash Certified Developer

  8. #8

  9. #9
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    it's a timing issue
    the clip needs to fully instanciate before altering properties
    Code:
    var checkbox  = _root.attachMovie("mcCheck", "mcCheck", _root.getNextHighestDepth());
    
    this.onEnterFrame = function(){
    if(checkbox){
    trace("clip has instanciated");
    checkbox.cmpCheckbox.label = "hello"; 
    this.onEnterFrame = null;
    }
    };

  10. #10

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