Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4253246
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T04:55:14+00:00 2026-05-21T04:55:14+00:00

I want to dynamically load the graphic of the button into an mc inside

  • 0

I want to dynamically load the graphic of the button into an mc inside each frame of the button (up and over).
Inside each frame I have a movie clip (canvas and canvas_over)

The green box is the button object (header_btn):

The green box is the button object (header_btn)

This is my code:

var hLoader:Loader = new Loader();
hLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, hLoaded);
hLoader.load(new URLRequest("http://django.liveproject.is/misc/current_flash_header/image.png"));

function hLoaded(event:Event):void {
    var image:Bitmap = new Bitmap(event.target.content.bitmapData);
    header_btn.canvas.addChild(image);
}

var hoLoader:Loader = new Loader();
hoLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, hoLoaded);
hoLoader.load(new URLRequest("http://django.liveproject.is/misc/current_flash_header_over/image.png"));

function hoLoaded(event:Event):void {
    var image:Bitmap = new Bitmap(event.target.content.bitmapData);
    header_btn.over_canvas.addChild(image);
}

The error I get is:

TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at MethodInfo-78()
TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at MethodInfo-77()

Edit – Solved:

header_canvas and header_canvas_over are placed on stage. header_canvas_over is placed over header_canvas.

Code:

var context:LoaderContext = new LoaderContext();
context.checkPolicyFile = true;

var hLoader:Loader = new Loader();
hLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, hLoaded);
hLoader.load(new URLRequest("http://django.liveproject.is/misc/current_flash_header/image.png"), context);

function hLoaded(event:Event):void {
    var image:Bitmap = new Bitmap(event.target.content.bitmapData);
    header_canvas_up.addChild(image);
}

var hoLoader:Loader = new Loader();
hoLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, hoLoaded);
hoLoader.load(new URLRequest("http://django.liveproject.is/misc/current_flash_header_over/image.png"), context);

function hoLoaded(event:Event):void {
    var image:Bitmap = new Bitmap(event.target.content.bitmapData);
    header_canvas_over.addChild(image);
    header_canvas_over.visible = false;

    header_btn.addEventListener(MouseEvent.MOUSE_OVER, onHover);
    function onHover(event:Event):void {
        header_canvas_over.visible = true;
    }

    header_btn.addEventListener(MouseEvent.MOUSE_OUT, onOut);
    function onOut(event:Event):void {
        header_canvas_over.visible = false;
    }
}

It would be nice though if as3 allowed for buttons to contain objects. :/

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T04:55:14+00:00Added an answer on May 21, 2026 at 4:55 am

    The SimpleButton class is extended from DisplayObject, not DisplayObjectContainer. That means that you can’t access objects on a button’s timeline in that way, nor can you add or remove children.

    For what you’re wanting do do it might be worth creating a custom button class that extends MovieClip. You’d have to add code yourself for moving between the states on user interaction, but you would get a lot more control over the visual transition between states as well as the content of them.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a few internal Canvas xaml files which I want to load dynamically
i have a web page that i want to load dynamically (ajax) into a
I have a bunch of links that I want to load dynamically within the
I want to dynamically load (AJAX) the text from some Microsoft Word files into
I have been looking for a way to dynamically load functions into c++ for
I have a MVC2 user control that I want to dynamically load the menu
I have a Flash in AS3. I want to dynamically load code that performs
Suppose i have some tabs (e.g. jquery tab) and I want to dynamically load
I'm creating a CMS, and I want to dynamically load the style from the
I have a custom control and I want to dynamically insert a link to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.