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

  • Home
  • SEARCH
  • 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 8951227
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T13:36:54+00:00 2026-06-15T13:36:54+00:00

im working on a Flex application and i need to update a button icon

  • 0

im working on a Flex application and i need to update a button icon source dynamically, but, its not enough for me by changing the icon attribute to another Class variable on runtime, i need to explicitly change the Class source to another. I google my doubt but has no the answer yet.

I want something like the following:
http://www.java2s.com/Code/Flex/Graphics/ChangeImagesourceinbuttonaction.htm

But i need it to do somethig like this instead:

[Embed(source="sun.jpg")]
[Bindable]
private var dayAsset:Class;

private function init(  ):void {
    dayImage.source = dayAsset;
}

private function showMoon(  ):void {
    dayAsset.source = "moon.jpg";
}

private function showSun(  ):void {
    dayAsset.source = "sun.jpg";
}

I have tried the previous code without success.

Why do i need to update the “dayImage” image source this way?? Because i have the image referenced on more than one location and i need to update it all on an event triggered

Any solution 😛 or comments will be greatly appreciated.

Thanks. have a nice night.

  • 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-06-15T13:36:56+00:00Added an answer on June 15, 2026 at 1:36 pm

    IF I understand the question; then the answer is that you cannot change embeds at runtime. They are performed at compile time; and made part of your compiled SWF.

    You most likely want to do an approach like this:

    // embed both images
    [Embed(source="sun.jpg")]
    [Bindable]
    private var dayAssetSun:Class;
    
    [Embed(source="moon.jpg")]
    [Bindable]
    private var dayAssetMoon:Class;
    
    // us a variable to store the reference to the image you want to see
    private var currentDayAsset :Class;
    
    // set the current asset
    private function init(  ):void {
        dayImage.source = currentDayAsset;
    }
    
    // these methods change the currentDayAsset variable; but do not affect the embeds
    private function showMoon(  ):void {
        currentDayAsset =  dayAssetMoon;
    }
    
    private function showSun(  ):void {
        currentDayAsset =  dayAssetSun;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working with flex, but actionscript ideas are just as good. The flex <s:Application>
I have a working Flex/Java application, but if I log out of the channelSet
I'm working on a flex application and I need to call some data with
I'm working with a Flash project, but need some features of Flex. So I
I'm working on an application in Flex 3.2, and I need to be able
I'm working on a project where I need to make a Flex application that
I'm trying to get a loader working in a flex web application, but it
I'm working on a prototype in flex and I need to connect my application
I have a working Flex/BlazeDS application (for simple AMF remoting) with the following settings:
Currently I am working on flex application where I am using multicore variant of

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.