It has everything I need but does anybody know how to add images to this? Ability of having little image, next to text. Like a book cover, in this particulary example.
How to alter both for xml and as code. Would xml be something like this:
<Books>
<Book ISBN=“xxxx”>
<title> Title of book 1</title>
<author> Author 1</author>
I haven’t looked into the tutorial much but as long as your tag is inside the <book> tag then you should be able to access it from flash for example for your code I would you use a for loop
//if you use an array to capture the imageUrl for example
var urlArray:Array = new Array();
xmContent = XML(xmLoader.data);
//then the for loop to look into each <book>
for (var pic:String in xmContent.book){
urlArray[pic] = xmContent.book[pic].image.url;
}
and then use that as a URLRequest… I hope this helped
which is great! But is it possible to make something like this (sorry for low q):
The difference is about alingment. First comes the picture, then text besides it! And I don’t understand why it’s so much space between Gjuro2 text and rest of text
I would be thankfull for some help.
and this is as code:
function xmlLoaded(event:Event):void {
myXML = XML(myLoader.data);
ParseStory(myXML);
}
// prolazak kroz fju
function ParseStory(bookInput:XML):void {
var my_string:String;
var style:StyleSheet = new StyleSheet();
var styleA:Object = new Object();
var styleA_linc:Object = new Object();
var style_div:Object = new Object();
style_div.color=“#220000”;
style_div.textAlign=“left”;
styleA_linc.color=“#220000”;
styleA.color = “#CCCCCC”;
//styleA_linc.fontWeight = “bold”; //styleA.fontStyle = “italic”;
style.setStyle(“h1”, style_div); //styleA.textDecoration=“underline”;
style.setStyle(“a”, styleA);
style.setStyle(“a:hover”, styleA_linc);
my_txt.styleSheet=style;
function remove_enter(str_line:String):String {
var my_array:Array = new Array();
var my_array_more_null:Array = new Array();
var my_enter:String;
var j:int=0;
my_array = str_line.split("
");//split on symbol
for (var i = 0; i<my_array.length; i++) {
my_enter=my_array*;
//my_array*=my_enter.substring(0,my_enter.length);//remove enter form end line
//trace(my_array*+" "+my_enter.length);//look at result
if (my_enter.length>1) {
my_array_more_null[j]= my_enter;
j++;
}
}
my_enter=my_array_more_null.join("");//symbol for upper plus line(default ",")
return my_enter;
You should using double dot syntax and cast to those expected value types such as
var xml:XML = //the above XML
var b:Book = new Book();
b.title = String(xml..title[0]);
b.img = String(xml..img[0]);
b.alt = String(xml..alt[0]);
Now for my shameless plug. There is a class in AppCoreLib called ClassUtil that has translation methods so that you can pass a class and an XML object and it will spit out a new instance filled in. Of course it requires that you map the XML to the public vars on the class. Check it out:
http://appcorelib.googlecode.com/svn/trunk/asdoc/index.html
http://code.google.com/p/appcorelib/source/browse/trunk/src/appCoreLib/utils/ClassUtil.as
[quote=jwopitz;2334925]
Now for my shameless plug. There is a class in AppCoreLib called ClassUtil that has translation methods so that you can pass a class and an XML object and it will spit out a new instance filled in. Of course it requires that you map the XML to the public vars on the class. Check it out:
Thanx for reply, but I’m not very good in as and xml so ClassUtil means little to me…:jail:
Is there way that I can do what I said in my prevoius post? The problem is that I don’t know how many of this paragraphs will be in my xml, so it has to be in one dynamic text box…Otherwise I would separate different text boxes for different data (images, text etc.). Anyone?
You should using double dot syntax and cast to those expected value types such as
var xml:XML = //the above XML
var b:Book = new Book();
b.title = String(xml..title[0]);
b.img = String(xml..img[0]);
b.alt = String(xml..alt[0]);[/quote]
I could use this part but I don't know how many books there will be, so I have to load them dinamically..Any way of using this but be able to load them dinamically? Probably for loop?