A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: getChildByName return null if publis setting is Flash 9

  1. #1
    Junior Member
    Join Date
    Aug 2008
    Posts
    27

    getChildByName return null if publis setting is Flash 9

    Hi,

    I am facing a weird problem.

    The following code returns null if targeted player is Flash player 9 but works fine for Flash Player 10.

    PHP Code:
    var _mc:MovieClip getChildByName("introMC") as MovieClip
    It works fine if I give a delay using setTimeout.

    I am not sure what I may be doing wrong. I have attached the source files. (Flash CS5 format)

    Any help is appreciated
    Attached Files Attached Files
    Bug? That's not a bug, that's a feature.
    "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rich Coo

  2. #2
    FK Romeo martiansam's Avatar
    Join Date
    Oct 2001
    Location
    Bombay, India
    Posts
    223
    Make sure that the movieclip is available when you call the getChildByName method.

    The fact that it returns the movieclip reference if u add a delay suggest that the method getChildByName is called before the movieclip is rendered available.
    sameer rao

    there...you see!!

  3. #3
    Junior Member
    Join Date
    Aug 2008
    Posts
    27
    But why changing the Flash Player version to 10 makes the same code to work?
    Bug? That's not a bug, that's a feature.
    "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rich Coo

  4. #4
    FK Romeo martiansam's Avatar
    Join Date
    Oct 2001
    Location
    Bombay, India
    Posts
    223
    I really cant answer that question. I can only make assumption that maybe the new player makes sure that all the objects on the frame are loaded and 'available' before sending the completion call or whatever.
    sameer rao

    there...you see!!

  5. #5
    Junior Member
    Join Date
    Aug 2008
    Posts
    27
    There are few solutions to this (for FP 9)

    1. using setTimeout to give delay and call "control()" function.
    2. Put the "control();" function on the layer which has label "start"
    3. attach the MovieClip using the class notation var _mc:MovieClip = new MyMC();

    However I want to understand why the normal method is not working is there any error in the code?
    Bug? That's not a bug, that's a feature.
    "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rich Coo

  6. #6
    FK Romeo martiansam's Avatar
    Join Date
    Oct 2001
    Location
    Bombay, India
    Posts
    223
    This is what i usually follow while coding and make the movieclip structure accordingly. This helps me in loading and managing external files as well.

    1) each swf will have one frame having a main movieclip, this movieclip might have all the movieclips and animations that you want internally in that swf
    2) the class associated with this swf is instantiated in the root timeline itself
    3) this main movielcip will have a blank first frame and a stop() command
    4) the second frame is labeled 'start'
    5) the last frame has a callback function which calls the class method, this makes sure that all the assets (movieclips, textfields) are available before I begin firing all the method and the layout is done and the class instance is already created
    6) as soon as the movieclip loads, the class instance is created and I play it from the label 'start', once the movieclip header reaches the last frame, it calls the callback method from the class which in turn takes over and performs the other commands

    This never fails for me. Be it player 9 or player 10. The movieclip structure is crucial.
    sameer rao

    there...you see!!

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