A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: MovieClipLoader problem - tracing undefined

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

    MovieClipLoader problem - tracing undefined

    Hi guys I dont understand why I am getting undefined in the output panel

    the code is as follows:

    Code:
    var mcl:MovieClipLoader = new MovieClipLoader();
    var mclListener:Object = {};
    mcl.addListener(mclListener);
    
    mclListener.onLoadInit = function(mcImage:MovieClip):Void{
    	trace(mcImage);
    	trace(mcImage.id); //this gives undefined..
    }
    
    
    var mcImage:MovieClip = mcImageHolder.createEmptyMovieClip("mcImage"+1, 1);
    mcImage.id = 1;
    trace(mcImage);
    trace(mcImage.id);
    trace("--------");
    mcl.loadClip("images/rabbits.jpg", mcImage);
    In the output panel i get the following:


    Code:
    _level0.mcImageHolder.mcImage1
    1
    --------
    _level0.mcImageHolder.mcImage1
    undefined //why do i get undefined here?

    Thanks in advance...
    Last edited by silentweed; 01-19-2007 at 09:07 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

  2. #2
    Senior Member
    Join Date
    Aug 2000
    Location
    Montréal
    Posts
    14,141
    I think id got cleared when mcImage1 was created. On your first trace it's there, on the second (onLoadInit) it's gone.

    try:
    mcImageHolder.id = 1;

    then trace mcImageHolder.id it will return 1

    or

    gparis

  3. #3
    Flashmatics silentweed's Avatar
    Join Date
    Mar 2005
    Location
    London, UK
    Posts
    4,875
    yeah it seems the content gets completely replaced by new empty content..hence any dynamic variables are deleted...

    what i ended up doing is defining the id for the mcs within the onInit Handler itself....

    Thanks gparis!!
    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

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