-
assigning xml value to Image.Source ?
Hi,
i'm loading a xml :
<?xml version="1.0"?>
<jz>
<inhoud>
<url>test</url>
<slide_prefix>lzcv1_</slide_prefix>
<first_slide_nr>1</first_slide_nr>
<last_slide_nr>3</last_slide_nr>
<extension>.png</extension>
</inhoud>
</jz>
In the xml is the name of slides i want to load. The prefix + slidenr + extension gives the filename, ex : "lzcv1_1.png"
The XML and the slides i want to load are in a subfolder : imagesSmart
I use actionscript to get the xml and put the file names together.
This seems to work correctly. I test it with a text box (test) to see if the name is assembled correctly.
The problem is that when i assign the filename to the source of an image the image doesn't display ? The filename i assign is converted to a string. Should i make it something else ?
An overview of the file :
In flex i use this code to get the XML and put the filenames together.
[Bindable]
private var ImagesSmartAC:ArrayCollection;
private var imagesDefinition:Object
private var first_slide_nr:String
private var last_slide_nr:String
private var slide_prefix:String
private var extension:String
private var slide_nu:String
private function resultHandlerImages(event:ResultEvent):void {
ImagesSmartAC= event.result.jz.inhoud;
imagesDefinition= ImagesSmartAC.getItemAt(0)
first_slide_nr= String(imagesDefinition.first_slide_nr);
last_slide_nr= String(imagesDefinition.last_slide_nr);
slide_prefix = String(imagesDefinition.slide_prefix);
extension = String(imagesDefinition.extension);
slide_nu = first_slide_nr ;
slideNrNu.text = first_slide_nr;
slideNrTot.text = last_slide_nr ;
}
code to go to the next slide :
private function laadSlideNrImagesVooruit():void {
if (slide_nu < last_slide_nr){
slide_nu= String(Number(slide_nu)+1);
var teLadenImage:String = String("imagesSmart/" + slide_prefix + slide_nu + extension);
test.text += "\n " + teLadenImage;
laadImage.source="teLadenImage";
slideNrNu.text = slide_nu;
}
}
design :
<mx:Canvas x="10" y="425" width="530" height="25">
<mx:Label x="10" y="5" text="Slide :"/>
<mx:Label x="80" y="5" text="van :"/>
<mx:Text x="50" y="5" width="30" height="18" id="slideNrNu" />
<mx:Text x="115" y="5" width="30" height="18" id="slideNrTot"/>
<mx:Button x="250" y="2" label="Vorige" height="20" id="btnVorige" click="laadSlideNrImagesTerug()"/>
<mx:Button x="330" y="2" label="Volgende" height="20" id="btnVolgende" click="laadSlideNrImagesVooruit()"/>
</mx:Canvas>
grtz,
b
-
And code for the image :
<mx:Canvas x="10" y="25" width="530" height="400">
<mx:Image x="0" y="0" width="530" height="173" id="laadImage"
source="imagesSmart/lzcv1_1.png"/>
</mx:Canvas>
-
Senior Member
Have you tested manually if the source into which you load the image loads properly? Just use a url to one of the images without going over the XML.
Regarding your XML you do not need typecasting String(......), since node values, attributes etc are all of datatype string already.
- The right of the People to create Flash movies shall not be infringed. -
-
Just to note that attributes, text nodes &c are XMLLists. There are a bunch of instances however, where they are automatically toString ()-ed.
-
thx guys,
the solution : use load instead of source :
laadImage.load(TeLadenImage);
grtz,
b
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|