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 6680643
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:29:57+00:00 2026-05-26T04:29:57+00:00

I am trying to load an image dynamically to the Image control and then

  • 0

I am trying to load an image dynamically to the Image control and then add it to a sprite and add the sprite to the UIComponent.

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
           xmlns:s="library://ns.adobe.com/flex/spark" 
           xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600"
           applicationComplete="init()">
<fx:Declarations>
    <!-- Place non-visual elements (e.g., services, value objects) here -->
<fx:int id = "_rows" />
<fx:int id = "_cols" />     

</fx:Declarations>
<s:layout>
    <s:VerticalLayout>

    </s:VerticalLayout>

</s:layout>
<fx:Script>
    <![CDATA[
        import as3isolib.geom.Pt;
        import as3isolib.utils.IsoDrawingUtil;

        import mx.controls.Alert;
        import mx.core.IVisualElement;

        private var sprite:Sprite;
        [Binable]
        private var imgUrl:String = "http://localhost/greenrev/images//marketitems/menu_houses.png";
        //[Bindable]
//          private var _rows:int = 1;
//          //[Bindable]
//          private var _cols:int = 1;
        private var _cellSize:int=40;

        private function init(){

            sprite = new Sprite();
            //Alert.show(sprite.numChildren.toString());
            imgContainer.addChild(sprite);
            //Alert.show(sprite.numChildren.toString());

            loadImage(imgUrl);

        }

        private function loadImage(url:String):void{

            //img.source = url;
            img.load(url);

        }

        private function loadingComplete(event:Event):void{

            if (sprite.numChildren>0){
                sprite.removeChildAt(0);
            }

            sprite = new Sprite();
            sprite.addChild(img);
            sprite.cacheAsBitmap = true;
            sprite.graphics.clear();
            sprite.graphics.beginFill(0xffff00, 0.3);
            _rows = int(rows.text);
            _cols = int(cols.text);
            Alert.show(_rows.toString() + "," + _cols.toString());
            IsoDrawingUtil.drawIsoRectangle(sprite.graphics,new Pt(0,0),_cellSize * _rows,_cellSize * _cols);
            sprite.graphics.endFill();

            if (imgContainer.numChildren>0){
                imgContainer.removeChildAt(0);
            }

            imgContainer.addChild(sprite);
//              imgContainer.addChild(img);
            //Alert.show("loading complete");

        }

        private function loadingFail(event:IOErrorEvent):void{

            Alert.show(event.text);

        }

    ]]>
</fx:Script>
<s:BorderContainer id="main"  verticalCenter="-244" horizontalCenter="-422" width="80%" height="90%">
    <s:layout>
        <s:VerticalLayout verticalAlign="middle" horizontalAlign="center">

        </s:VerticalLayout>
    </s:layout>
    <s:BorderContainer>
        <mx:UIComponent id="imgContainer">

        </mx:UIComponent>
    </s:BorderContainer>

    <s:BorderContainer>
        <s:layout>
            <s:HorizontalLayout>

            </s:HorizontalLayout>
        </s:layout>
        <s:VGroup>
            <s:TextInput id="rows"  minWidth="100" text = "{_rows}"/>
            <s:TextInput id = "cols" minWidth="100" text = "{_cols}"/>
            <s:TextInput id = "txtImgUrl" minWidth="400" text="{imgUrl}"/>
            <s:Button label="Refresh" click="loadImage(imgUrl)"/>

        </s:VGroup>


    </s:BorderContainer>

</s:BorderContainer>

<mx:Image id="img" complete="loadingComplete(event)" visible="true" ioError="loadingFail(event)">

</mx:Image>

</s:Application>

I have no clue why the image is not being shown. Like you can see, I am trying to add the image after the COMPLETE event occurs. Please help

  • 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-26T04:29:57+00:00Added an answer on May 26, 2026 at 4:29 am

    I changed the URL to “http://horses-bg.net/wp-content/uploads/2009/11/2752_beloved-horses.jpg” and the image appeared.
    I’ve also commented out the IsoDrawingUtil.drawIsoRectangle(..) cause i don’t have the lib you’re using.
    The problem might be in your URL or in that IsoDrawingutil thing :]

    Hope this helps,

    Good luck!

    Blaze

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

Sidebar

Related Questions

Im loading an image from a SQL CE db and then trying to load
I have been trying: to load an image into a window control with a
I am trying to load an image into a control that has an image
I'm trying to load an image dynamically. Seems like the server doesn't like me
I am trying to load an image in the background and then update the
I am trying to load an image in memory but might have memory issues
I am trying to load a JPEG image using the cvLoadImage function and it
I'm trying to write code that will load an image from a resource, and
I'm trying to load about 600 small images into memory. Size of each image
I'm trying to figure out how to load a new image with ajax when

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.