Ask a Question related to Macromedia Flex General Discussion, Design and Development.
-
Jinglesthula #1
Image control runtime creation issue
I am having problems getting the Image control to actually display the image I
specify in the source property. The Image control is created in actionscript
at runtime based on XML returned by an HTTPService request. I have a canvas
that I want to populate with Label, Text, Image, LinkButton, etc. controls
based on the contents of the XML file that is read in, so I have to create all
the components on the fly and use something like this:
var newImage:Image = new Image();
newImage.setStyle("source", "images/myImageFile.jpg");
myCanvas.addChild(newImage);
After I get all the newly created components added as children to the canvas I
go back through and do positioning (something like this):
for each (var child:DisplayObject in myCanvas.getChildren()) {
//set the y property of each component to the y of the previous child plus
//the height of the previous child plus 10 px margin
}
Wherever there is an image in my XML it inserts the 10px margin for that
component, so I know it's creating it and that it gets added as a child, but
for some reason the image is not displaying and so the height of the component
is 0. I even tried hardcoding the height of each Image control in case the
image was there but it just wasn't sizing right, but it puts in the space
without displaying the image.
What I'm wondering is if there is some method that will force the Image
controls to either load the image or render it. When I add an Image in mxml
and use the exact same source data it displays just fine, so the file path is
correct. I also have the same images being read in from XML off the
HTTPService that are showing up just fine in a TileList where my itemRenderer
component has an image with the source set to the same path as I'm trying to
use in the runtime-generated Image controls.
Also, as a side question, does anyone know why a lot of the properties/methods
available from mxml specified comonents aren't available when you create
variables of the same type in actionscript? For example, if I have
<mx:Image id"img"/>
I can go back in actionscript and reference img.source just fine. On the
other hand, if I declare an Image in actionscript, thus:
private var asImg:Image = new Image();
and then try to refer to the source property like so:
asImg.source
it doesn't show up in the code hinting and it also throws an error on compile
(reference to a possibly undefined property source for bla bla bla)
Actually, I've noticed that a lot of the properties and methods of various
components aren't available when they are actionscript rather than mxml. I
didn't see much in the documentation on the difference or what could be done to
work around it.
Thanks much anyone who has input.
Jinglesthula Guest
-
Web user control creation - Resolve an ImageUrl property if control themed
Hi I'm creating a WebControl which has a themeable ImageUrl property : <Bindable(True), Category("Appearance"),... -
Creation and Positioning DataGrid Columns at runtime.
Hello, I need to create a DataGrid that looks something like this... <HyperLinkColumn><ButtonColumn><Data><Data><ButtonColumn> but I can only... -
Adding Validator Control at runtime in a Custom Control
Hi Wim, How do we link the TextBox to this validator control class in runtime ? Could you please tell. Thanks _ Muds. Wim Hollebrandse... -
ASP.NET DataGrid and TextBox creation at runtime?
Hello, How do I create the following at runtime? I am able to create a TextBox Column at runtime using "DataGridColumn" class. But I don't know... -
Runtime control creation
I'm building a page in which - at runtime - I'm adding Button controls to an asp:tablecell. Code looks more or less like this : Public Sub... -
Jinglesthula #2
Re: Image control runtime creation issue
Anybody? .... Bueller? ....
Jinglesthula Guest
-
ntsiii #3
Re: Image control runtime creation issue
Have you tried embedding the image asset? This stuff is well outside my areas of expertise, but, hey, I'm trying.
Tracy
ntsiii Guest
-
Jinglesthula #4
Re: Image control runtime creation issue
The problem is that I want the images to be specified at runtime based on the
contents of the XML file which may change without the Flex app ever being
recompiled. I've embedded images in other Flex apps before, but that requires
that all embedded images to be available at compile time. Thanks for the
suggestion, though. I appreciate it.
Jon
Jinglesthula Guest
-
Jinglesthula #5
Re: Image control runtime creation issue
Ok, got it.
I figured that since the <mx:Image> renders just fine and that the
ActionScript Image object doesn't that I'd just create a custom mxml component
with Image as the base element and with nothing else in it. Then I add an
instance of my custom image component in AS whenever the XML specifies one.
The layout was a bit of an issue, but I just added the image dimensions as
attributes in my XML and size the CustomImage component based on those.
Must be some subtle difference between the mxml and AS Image classes that
isn't documented very well.
Jinglesthula Guest
-
Unregistered #6
Re: Image control runtime creation issue
if you are running it on server, try movinf images to theweb content folder and specify the path of images as http://<server>:<port>/<projectname>/<floder>/image.jpeg
Unregistered Guest



Reply With Quote

