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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T03:30:00+00:00 2026-06-03T03:30:00+00:00

Got solution – See bottom of the post Just want to know if there

  • 0

Got solution – See bottom of the post

Just want to know if there is any problem if I give negative -y coordinates to the child elements? In my project when I do it it behaves very awkwardly.

In my flex 3.5 project I have extended Canvas class. In this class I will have one children (Image) which I load dynamically and set the x, y position to adjust the offsets which usually -x and -y values. Up to this no problem. Now when I try to add another child with -y value dynamically it shrinks the canvas and shows a very small rectangle (without shrinking image sizes)

And also I noticed that Canvas height property is 0 even after adding the 1st image.

Does anyone know what problem it is?

* Edited: Source code added below *

public class WorldElementView extends Canvas {

    private var mainAsset:UIComponent;
    private var shopItem:ShopItem;
    private var map:WorldMapView;
    private var loader:Loader;

    private var timer:Timer;
    private var readyToCollect:Boolean = false;     
    private var loadingUserData:Boolean = false;        
    private var collectionImage:Image;

Removed lot of variables which doesnt make sense in the context

    public function WorldElementView(m:WorldMapView):void{

        map = m;
        mainAsset = new UIComponent();
        loadAsset();        
    }

loadAsset() is called to load the main asset which is loading fine

    private function loadAsset():void{

        loader = new Loader();
        loader.contentLoaderInfo.addEventListener(Event.COMPLETE,onLoadComplete);
        loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR,onLoadError);
        loader.load(new URLRequest(GameConfig.ASSET_IMAGE_PATH + shopItem.ImagePath)); 

    }

all values in the internal variables are correct,
// event handlers
private function onLoadComplete(e:Event):void{

        loader.contentLoaderInfo.removeEventListener(Event.COMPLETE,onLoadComplete);
        loader.contentLoaderInfo.removeEventListener(IOErrorEvent.IO_ERROR,onLoadError);
        addEventListener(MouseEvent.CLICK,onClick);


        var bmp:Bitmap = LoaderInfo(e.target).content as Bitmap;
        //*****NEW CODE****//
        this.height = bmp.height + 20;
        this.width  = bmp.width;

        bmp.x+=shopItem.OffSetX;
        bmp.y+=shopItem.OffSetY;

        mainAsset.addChild(bmp);
        addChildAt(mainAsset,0);
        setDimensions();

        initTimer();

        dispatchEvent(new GreenRevEvent(GreenRevEvent.WORLD_ELEMENT_INITIALIZED));
    }

initTimer() is called to initiate the timer

    public function onLoadError(e:IOErrorEvent):void{

        loader.contentLoaderInfo.removeEventListener(Event.COMPLETE,onLoadComplete);
        loader.contentLoaderInfo.removeEventListener(IOErrorEvent.IO_ERROR,onLoadError);

        Alert.show("Error loading world!" + e.toString());
    }

    private function initTimer():void{

        var interval:int;
        // *** LOGIC to determine "interval"
            interval = 10000; // hardcoded to 10 seconds
            timer = new Timer(interval,1);
            timer.addEventListener(TimerEvent.TIMER,onTimer);
            timer.start();
    }

Not much here, just setting up the timer

    private function onTimer(e:TimerEvent):void{
        readyToCollect = true;
        showCollectIcon();
    }

Problem is below function look at inline comment

    private function showCollectIcon():void{

        if(!collectionImage){
            collectionImage = new Image();
            collectionImage.autoLoad = true;
            collectionImage.source = GameResource.imgCollect;
            collectionImage.y = -20; // **** THIS BEHAVES AWCKWARDLY ****

            addChild(collectionImage);
            collectionImage.filters = [new GlowFilter(0x0000ff,1,10,1,1)]
            collectionImage.mouseEnabled = false;
            collectionImage.visible = false;
        }

        collectionImage.visible = true;
    }
}

If I comment out the below line every thing works fine but the problem is that I need to place the icon just above top of the main image

   collectionImage.y = -20;

Solution

The issue was with setting the dimensions of the parent canvas.
I have added this line in onLoadComplete() function

        //*****NEW CODE****//
        this.height = bmp.height + 20;
        this.width  = bmp.width;

Regards

  • 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-03T03:30:02+00:00Added an answer on June 3, 2026 at 3:30 am

    The issue was with setting the dimensions of the parent canvas.
    I have added this line in onLoadComplete() function

            this.height = bmp.height + 20;
            this.width  = bmp.width;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have got the solution to the problem, want to thank you all you
I have got the solution to the problem, want to thank you all you
I am just wondering if there is a simple solution already to the problem
(Scroll down to bottom of post to find solution.) Got a asp.net page which
I am working with delphi. After I got a solution of this problem, Now
This is a theoretical question, I've already got a solution to my problem that
I asked this question before also but I didnt got any solution. I am
This questions look repeated, but I din't got proper solution for my problem. In
I had a problem with my D3D11CreateDeviceAndSwapChain(). I thought I got a solution in
I want to the solution got back from z3 without simplification using let statements.

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.