Search the web
Sign In
New User? Sign Up
flexcoders · RIA Development with Adobe Flex
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Show off your group to the world. Share a photo of your group with us.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
Problems adding custom MXML component to Canvas at runtime   Message List  
Reply | Forward Message #130852 of 149659 |
RE: [flexcoders] Problems adding custom MXML component to Canvas at runtime

I would expect it to work with Canvas as the top tag.  If you want to use UIComponent, make sure you’ve read the documentation on the component lifecycle, or see Gordon’s and my Flick & Flack article in Flex Authority magazine.  A UIComponent has to implement lifecycle methods in order to be shown correctly

 

From: flexcoders@yahoogroups.com [mailto:flexcoders@yahoogroups.com] On Behalf Of devenhariyani
Sent: Thursday, November 20, 2008 7:10 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Problems adding custom MXML component to Canvas at runtime

 

Hello,

MY GOAL: to add my custom MXML component to a canvas, the custom comp
has a Label and a TextArea object inside, the user can see the Label
but the TextArea is hidden, but when a user hovers the mouse over the
Label, effect will be applied to show the TextArea.

I'm having difficulty displaying a custom MXML component on a canvas
in my application. Basically, I have a very simple MXML component
which is a UIComponent with a Label and a TextArea inside. At
runtime I create an instance of this custom MXML component and then I
set the text field for the Label and I want to add this component to
the main canvas and apply some effects to it.

However, no matter what I try the MXML component does not appear on
my canvas. When I try the same code by using a plain Label instead
of my custom MXML component I am able to see the Label appear on the
canvas and I can apply effects on it as I would expect.

Instead of using a UIComponent as the wrapper class in my custom MXML
class I have also tried using a Canvas class, but that did not make a
difference.

My custom MXML component (CustomMXMLComp.mxml):
<mx:UIComponent xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Label id="lblTitle" text="DEFAULT TEXT" />
<mx:TextArea id="txaBrief" text="DEFAULT BRIEF TEXT" />
</mx:UIComponent>

The code to add this component to the canvas at runtime:

<Application creationComplete="loadApp()">
<mx:Script>
private function loadApp() {
var myObj:CustomMXMLComp = new CustomMXMLComp();
this.myCnv.addChild(myObj);
myObj.x = 100;
myObj.y = 100;
//HELP: NOTHING APPEARS ON THE CANVAS!!
}
</mx:Script>
<Canvas id="myCnv" height="300" width="399">
</Canvas>
</Application>



Fri Nov 21, 2008 4:37 am

alex_harui
Online Now Online Now
Send Email Send Email

Forward
Message #130852 of 149659 |
Expand Messages Author Sort by Date

Hello, MY GOAL: to add my custom MXML component to a canvas, the custom comp has a Label and a TextArea object inside, the user can see the Label but the...
devenhariyani
Offline Send Email
Nov 21, 2008
3:10 am

I would expect it to work with Canvas as the top tag. If you want to use UIComponent, make sure you've read the documentation on the component lifecycle, or...
Alex Harui
alex_harui
Online Now Send Email
Nov 21, 2008
4:37 am

Good news, I figured out my problem! My problem was that i was trying to set properties before calling addChild(). For example, my custom component has a...
devenhariyani
Offline Send Email
Nov 21, 2008
5:07 am
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help