A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: Attach loaded bitmap into nested movieclip

  1. #1
    formerly hooligan2001 :) .hooligan's Avatar
    Join Date
    Mar 2008
    Posts
    405

    Attach loaded bitmap into nested movieclip

    Just trying to work out if this is possible or if theres a better way to do it.

    I have a Moiveclip in my library exported with the class of Circle. Inside that movieclip I have 3 nested clips, with instance names of arms, feet, eyes.

    These moviclips are to act as place holders for loaded images and are animated on the timeline.

    In the Main class I load in an image called image.gif and create a new instance of Circle passing the images to the constructor.

    I use addChild on the Main class to add the Circle to the stage.

    Inside of the Circle class I can use addChild and pass the BitmapData image. But I get a null reference when I try to use eyes.addChild but I can add it to the Circles display list with addChild fine.

    My question is can you add to a nested movieclips display list and if not what would be the best way to set this up?
    World Arcade | Facebook | Twitter - Follow MEEEE! or not......

  2. #2
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    From where are the images, if they are loaded into the movieclips you cannot use addChild.
    - The right of the People to create Flash movies shall not be infringed. -

  3. #3
    lemon juice hurts your eyes florianvanthuyn's Avatar
    Join Date
    Jul 2005
    Location
    Merelbeke, Belgium
    Posts
    546
    Check if the individual animated parts have the same instance name on each keyframe, and if not, make sure they have!
    Florian Vanthuyne

    WAR AGAINST SOLVED THREADS
    mark yours as Resolved under Thread Tools!

  4. #4
    formerly hooligan2001 :) .hooligan's Avatar
    Join Date
    Mar 2008
    Posts
    405
    From where are the images, if they are loaded into the movieclips you cannot use addChild.
    The images are external and I use the Loader class to load it in.

    image = Bitmap(loader.content);

    then I can add it to the Circles display list with addChild(image);

    but when I tried, lets say arms.addChild(image); or this.arms.addChild(image); it doesn't work and throws a null reference.

    I tried MovieClip(getChildByName("arm")).addChild(image); like from your original post and I get a null pointer.

    I also tried not casting it with this.getChildByName("arm").addChild(image); I get a different error.

    1061: Call to a possibly undefined method addChild through a reference with static type flash.displayisplayObject.

    Check if the individual animated parts have the same instance name on each keyframe, and if not, make sure they have!
    Yeah I have triple checked and its all named. Its really bugging me because I also use this line fine within my Circle class and it doesn't throw a null pointer.

    arm.currentFrame != 2 ? (arm.gotoAndStop("run")) : (null);
    Last edited by .hooligan; 07-08-2009 at 08:52 PM.
    World Arcade | Facebook | Twitter - Follow MEEEE! or not......

  5. #5
    formerly hooligan2001 :) .hooligan's Avatar
    Join Date
    Mar 2008
    Posts
    405
    Check if the individual animated parts have the same instance name on each keyframe, and if not, make sure they have!
    Turns out that was the problem. I only had that instance on one frame inside the main clip. Hard to explain the setup but its all good now. I need to change the setup though because the attached Item disappears then I flip between frames on the main clip.

    Thanks again.
    World Arcade | Facebook | Twitter - Follow MEEEE! or not......

  6. #6
    lemon juice hurts your eyes florianvanthuyn's Avatar
    Join Date
    Jul 2005
    Location
    Merelbeke, Belgium
    Posts
    546
    I've had that problem a dozen times by now and I thought this one looked familiar Good luck with the rest of your project
    Florian Vanthuyne

    WAR AGAINST SOLVED THREADS
    mark yours as Resolved under Thread Tools!

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