Hi!
As the title sais i am making a ImageViewer. But i have a problem, the pictures that i’m looping out in movieclips ends up ontop of each other. i want the pictures to be in two rows with three cols. How do i fix that problem? And also if i want to be able to click on the movieClips to scale it how do i fix that? Because someone told me that the movieclips won’t be clickable?
Thanks in advance!
Code:
XmlParser class
Loading pictures with XML
ActionScript Code:
[FONT=Courier New][LEFT][COLOR=#0000ff]import[/COLOR] [COLOR=#0000ff]System[/COLOR].[COLOR=#0000ff]useCodepage[/COLOR];
[COLOR=#0000ff]import[/COLOR] Library.[COLOR=#000080]com[/COLOR].[COLOR=#000080]xfactorstudio[/COLOR].[COLOR=#0000ff]xml[/COLOR].[COLOR=#000080]xpath[/COLOR];
[COLOR=#000000]class[/COLOR] xmlParser
[COLOR=#000000]{[/COLOR]
[COLOR=#0000ff]public[/COLOR] [COLOR=#000000]**function**[/COLOR] xmlParser[COLOR=#000000]([/COLOR][COLOR=#000000])[/COLOR]
[COLOR=#000000]{[/COLOR]
[COLOR=#000000]**var**[/COLOR] xmlData:[COLOR=#0000ff]XML[/COLOR] = [COLOR=#000000]**new**[/COLOR] [COLOR=#0000ff]XML[/COLOR][COLOR=#000000]([/COLOR][COLOR=#000000])[/COLOR];
xmlData.[COLOR=#0000ff]ignoreWhite[/COLOR] = [COLOR=#000000]**true**[/COLOR];
[COLOR=#000000]**var**[/COLOR] imageNode:[COLOR=#0000ff]XMLNode[/COLOR] = xmlData.[COLOR=#0000ff]firstChild[/COLOR];
xmlData.[COLOR=#0000ff]load[/COLOR][COLOR=#000000]([/COLOR][COLOR=#ff0000]"library/Images.xml"[/COLOR][COLOR=#000000])[/COLOR];
xmlData.[COLOR=#0000ff]onLoad[/COLOR] = [COLOR=#000000]**function**[/COLOR][COLOR=#000000]([/COLOR]xmlLoad:[COLOR=#0000ff]Boolean[/COLOR][COLOR=#000000])[/COLOR]:[COLOR=#0000ff]Void[/COLOR]
[COLOR=#000000]{[/COLOR]
[COLOR=#0000ff]if[/COLOR][COLOR=#000000]([/COLOR]xmlLoad == [COLOR=#000000]**true**[/COLOR][COLOR=#000000])[/COLOR]
[COLOR=#000000]{[/COLOR]
[COLOR=#0000ff]trace[/COLOR][COLOR=#000000]([/COLOR][COLOR=#ff0000]"Images.xml Was Loaded Successfully"[/COLOR][COLOR=#000000])[/COLOR];
[COLOR=#000000]**var**[/COLOR] imgIdNode:[COLOR=#0000ff]XMLNode[/COLOR] = xmlData.[COLOR=#0000ff]firstChild[/COLOR]; [COLOR=#808080]*// images*[/COLOR]
[COLOR=#000000]**var**[/COLOR] images:[COLOR=#0000ff]XMLNode[/COLOR] = imgIdNode.[COLOR=#0000ff]firstChild[/COLOR]; [COLOR=#808080]*//file name*[/COLOR]
[COLOR=#000000]**var**[/COLOR] title:[COLOR=#0000ff]XMLNode[/COLOR] = imgIdNode.[COLOR=#0000ff]nextSibling[/COLOR]; [COLOR=#808080]*//title*[/COLOR]
[COLOR=#000000]**var**[/COLOR] fileName_array:[COLOR=#0000ff]Array[/COLOR] = [COLOR=#000000]**new**[/COLOR] [COLOR=#0000ff]Array[/COLOR][COLOR=#000000]([/COLOR][COLOR=#000000])[/COLOR];
[COLOR=#0000ff]for[/COLOR][COLOR=#000000]([/COLOR][COLOR=#000000]**var**[/COLOR] i:[COLOR=#0000ff]Number[/COLOR] = [COLOR=#000080]0[/COLOR]; i < xmlData.[COLOR=#0000ff]firstChild[/COLOR].[COLOR=#0000ff]childNodes[/COLOR].[COLOR=#0000ff]length[/COLOR]; i++[COLOR=#000000])[/COLOR]
[COLOR=#000000]{[/COLOR]
[COLOR=#808080]*//trace(xmlData.firstChild.childNodes*.firstChild.lastChild);*[/COLOR]
[COLOR=#808080]*//fileName_array* = xmlData.firstChild.childNodes*.firstChild.lastChild;*[/COLOR]
[COLOR=#808080]*//var ob:Object = new Object({id: i});*[/COLOR]
[COLOR=#000000]**var**[/COLOR] fileName:[COLOR=#0000ff]String[/COLOR] = xmlData.[COLOR=#0000ff]firstChild[/COLOR].[COLOR=#0000ff]childNodes[/COLOR][COLOR=#000000][[/COLOR]i[COLOR=#000000]][/COLOR].[COLOR=#0000ff]firstChild[/COLOR].[COLOR=#0000ff]lastChild[/COLOR];
[COLOR=#0000ff]trace[/COLOR][COLOR=#000000]([/COLOR][COLOR=#ff0000]"Filnamn: "[/COLOR] +fileName[COLOR=#000000])[/COLOR];
[COLOR=#000000]**var**[/COLOR] img:Image = [COLOR=#000000]**new**[/COLOR] Image[COLOR=#000000]([/COLOR][COLOR=#0000ff]_root[/COLOR], [COLOR=#ff0000]"library/Bilder/"[/COLOR] +fileName[COLOR=#000000])[/COLOR];
[COLOR=#000000]}[/COLOR]
;
[COLOR=#000000]}[/COLOR]
[COLOR=#0000ff]else[/COLOR]
[COLOR=#000000]{[/COLOR]
[COLOR=#0000ff]trace[/COLOR][COLOR=#000000]([/COLOR][COLOR=#ff0000]"Error: Document Could Not Be Loaded"[/COLOR][COLOR=#000000])[/COLOR]
[COLOR=#000000]}[/COLOR]
[COLOR=#000000]}[/COLOR]
[COLOR=#000000]}[/COLOR]
[COLOR=#000000]}[/COLOR]
[/LEFT]
[/FONT]
Image
Handles positioning and other stuff
ActionScript Code:
[FONT=Courier New][LEFT][COLOR=#000000]**class**[/COLOR] Image [COLOR=#0000ff]extends[/COLOR] xmlParser
[COLOR=#000000]{[/COLOR]
[COLOR=#0000ff]private[/COLOR] [COLOR=#000000]**var**[/COLOR] image_mc:[COLOR=#0000ff]MovieClip[/COLOR];
[COLOR=#0000ff]private[/COLOR] [COLOR=#000000]**var**[/COLOR] imgMcl:[COLOR=#0000ff]MovieClipLoader[/COLOR];
[COLOR=#000000]**function**[/COLOR] Image[COLOR=#000000]([/COLOR][COLOR=#0000ff]_parent[/COLOR]:[COLOR=#0000ff]MovieClip[/COLOR], [COLOR=#0000ff]_url[/COLOR]:[COLOR=#0000ff]String[/COLOR] [COLOR=#000000])[/COLOR] [COLOR=#0000ff]extends[/COLOR] xmlParser
[COLOR=#000000]{[/COLOR]
image_mc = [COLOR=#0000ff]_parent[/COLOR].[COLOR=#0000ff]createEmptyMovieClip[/COLOR][COLOR=#000000]([/COLOR][COLOR=#ff0000]"iMage"[/COLOR], [COLOR=#0000ff]_parent[/COLOR].[COLOR=#0000ff]getNextHighestDepth[/COLOR][COLOR=#000000]([/COLOR][COLOR=#000000])[/COLOR], [COLOR=#0000ff]_parent[/COLOR].[COLOR=#0000ff]getNextHighestDepth[/COLOR][COLOR=#000000]([/COLOR][COLOR=#000000])[/COLOR][COLOR=#000000])[/COLOR];
imgMcl = [COLOR=#000000]**new**[/COLOR] [COLOR=#0000ff]MovieClipLoader[/COLOR][COLOR=#000000]([/COLOR][COLOR=#000000])[/COLOR];
image_mc.[COLOR=#0000ff]_xscale[/COLOR] = [COLOR=#000080]29[/COLOR];
image_mc.[COLOR=#0000ff]_yscale[/COLOR] = [COLOR=#000080]27[/COLOR];
image_mc.[COLOR=#0000ff]_x[/COLOR] = [COLOR=#000080]10[/COLOR];
image_mc.[COLOR=#0000ff]_y[/COLOR] = [COLOR=#000080]10[/COLOR];
[COLOR=#000000]**var**[/COLOR] loadListener:[COLOR=#0000ff]Object[/COLOR] = [COLOR=#000000]**new**[/COLOR] [COLOR=#0000ff]Object[/COLOR][COLOR=#000000]([/COLOR][COLOR=#000000])[/COLOR];
[COLOR=#000000]**var**[/COLOR] [COLOR=#0000ff]name[/COLOR]:[COLOR=#0000ff]String[/COLOR] =
[COLOR=#808080]*/*(var i:String != fileName)
{
image_mc._x = 130;
} */*[/COLOR]
loadListener.[COLOR=#0000ff]onLoadComplete[/COLOR] = [COLOR=#000000]**function**[/COLOR][COLOR=#000000]([/COLOR]target_mc:[COLOR=#0000ff]MovieClip[/COLOR], httpStatus:[COLOR=#0000ff]Number[/COLOR][COLOR=#000000])[/COLOR]:[COLOR=#0000ff]Void[/COLOR]
[COLOR=#000000]{[/COLOR]
[COLOR=#0000ff]trace[/COLOR][COLOR=#000000]([/COLOR][COLOR=#ff0000]"--- Klar---"[/COLOR][COLOR=#000000])[/COLOR];
[COLOR=#000000]}[/COLOR]
imgMcl.[COLOR=#0000ff]addListener[/COLOR][COLOR=#000000]([/COLOR]loadListener[COLOR=#000000])[/COLOR];
[COLOR=#0000ff]trace[/COLOR][COLOR=#000000]([/COLOR][COLOR=#ff0000]"I image "[/COLOR] +[COLOR=#0000ff]_url[/COLOR][COLOR=#000000])[/COLOR];
imgMcl.[COLOR=#0000ff]loadClip[/COLOR][COLOR=#000000]([/COLOR][COLOR=#0000ff]_url[/COLOR], image_mc[COLOR=#000000])[/COLOR];
[COLOR=#000000]}[/COLOR]
[COLOR=#000000]}[/COLOR]
[/LEFT]
[/FONT]
Xml-file:
[FONT=Courier New][LEFT]<imageGallery>
<image>
<file>bmegl074602.[COLOR=#000080]jpg[/COLOR]</file>
<title>Samurai red sun</title>
</image>
<image>
<file>koi.[COLOR=#000080]jpg[/COLOR] </file>
<title>Koifish</title>
</image>
<image>
<file>koiflowe.[COLOR=#000080]jpg[/COLOR]</file>
<title>Koi [COLOR=#0000ff]with[/COLOR] flowers</title>
</image>
<image>
<file>koitattoonow.[COLOR=#000080]jpg[/COLOR]</file>
<title>Black [COLOR=#0000ff]and[/COLOR] Grey Koi [COLOR=#0000ff]in[/COLOR] water</title>
</image>
<image>
<file>bmegl048322.[COLOR=#000080]jpg[/COLOR]</file>
<title>Leaf i water</title>
</image>
<image>
<file>bmegl063809.[COLOR=#000080]jpg[/COLOR]</file>
<title>Koi [COLOR=#0000ff]with[/COLOR] water [COLOR=#0000ff]and[/COLOR] flowers</title>
</image>
</imageGallery>
[/LEFT]
[/FONT]