Hi
All Great Fash Programmers here
While creating one photo gallery I am facing one problem in controlling the Font Color, Font Size and other characteristics of a text loaded into a text field from an XML File.
The name of the text field in question is “my_txt” it loads the title from the xml file attached herewith.
Can any one tell me how I can control the behavior of the text loaded in that text field.
Thanks in advance.
trnghosh
Here is the AS Code.
import mx.transitions.Tween;
import mx.transitions.easing.*;
var myGalleryXML = new XML();
myGalleryXML.ignoreWhite = true;
myGalleryXML.load("gallery_vertical.xml");
myGalleryXML.onLoad = function() {
_root.gallery_x = myGalleryXML.firstChild.attributes.gallery_x;
_root.gallery_y = myGalleryXML.firstChild.attributes.gallery_y;
_root.gallery_width = myGalleryXML.firstChild.attributes.gallery_width;
_root.gallery_height = myGalleryXML.firstChild.attributes.gallery_height;
_root.myImages = myGalleryXML.firstChild.childNodes;
_root.myImagesTotal = myImages.length;
_root.thumb_height = myGalleryXML.firstChild.attributes.thumb_height;
_root.thumb_width = myGalleryXML.firstChild.attributes.thumb_width;
_root.full_x = myGalleryXML.firstChild.attributes.full_x;
_root.full_y = myGalleryXML.firstChild.attributes.full_y;
callThumbs();
createMask();
scrolling();
callFullImage(0);
startSlideshow();
};
function callThumbs() {
_root.createEmptyMovieClip("container_mc",_root.getNextHighestDepth());
container_mc._x = _root.gallery_x;
container_mc._y = _root.gallery_y;
var clipLoader = new MovieClipLoader();
var preloader = new Object();
clipLoader.addListener(preloader);
for (i=0; i<myImagesTotal; i++) {
thumbURL = myImages*.attributes.thumb_url;
myThumb_mc = container_mc.createEmptyMovieClip(i, container_mc.getNextHighestDepth());
myThumb_mc._y = _root.thumb_height*i;
clipLoader.loadClip("thumbs/"+thumbURL,myThumb_mc);
preloader.onLoadStart = function(target) {
target.createTextField("my_txt",target.getNextHighestDepth(),0,0,100,20);
target.my_txt.selectable = false;
};
preloader.onLoadProgress = function(target, loadedBytes, totalBytes) {
target.my_txt.text = Math.floor((loadedBytes/totalBytes)*100);
};
preloader.onLoadComplete = function(target) {
new Tween(target, "_alpha", Strong.easeOut, 0, 100, .5, true);
target.my_txt.removeTextField();
target.onRelease = function() {
stopSlideshow();
callFullImage(this._name);
r = this._name;
startSlideshow();
};
target.onRollOver = function() {
this._alpha = 50;
};
target.onRollOut = function() {
this._alpha = 100;
};
};
}
}
function callFullImage(myNumber) {
myURL = myImages[myNumber].attributes.full_url;
myTitle = myImages[myNumber].attributes.title;
_root.createEmptyMovieClip("fullImage_mc",_root.getNextHighestDepth());
fullImage_mc._x = _root.full_x;
fullImage_mc._y = _root.full_y;
var fullClipLoader = new MovieClipLoader();
var fullPreloader = new Object();
fullClipLoader.addListener(fullPreloader);
fullPreloader.onLoadStart = function(target) {
target.createTextField("my_txt",fullImage_mc.getNextHighestDepth(),8,450,200,20);
target.my_txt.selectable = false;
};
fullPreloader.onLoadProgress = function(target, loadedBytes, totalBytes) {
target.my_txt.text = Math.floor((loadedBytes/totalBytes)*100);
};
fullPreloader.onLoadComplete = function(target) {
new Tween(target, "_alpha", Strong.easeOut, 0, 100, .5, true);
target.my_txt.text = myTitle;
target.onRelease = function() {
getURL(myImages[myNumber].attributes.link);
};
};
fullClipLoader.loadClip("full_images/"+myURL,fullImage_mc);
}
function createMask() {
_root.createEmptyMovieClip("mask_mc",_root.getNextHighestDepth());
mask_mc._x = _root.gallery_x;
mask_mc._y = _root.gallery_y;
mask_mc.beginFill(0x000000,100);
mask_mc.lineTo(_root.gallery_width,0);
mask_mc.lineTo(_root.gallery_width,_root.gallery_height);
mask_mc.lineTo(0,_root.gallery_height);
mask_mc.lineTo(0,0);
container_mc.setMask(mask_mc);
}
function scrolling() {
_root.onEnterFrame = function() {
container_mc._y += Math.cos(((mask_mc._ymouse)/mask_mc._height)*Math.PI)*15;
if (container_mc._y>mask_mc._y) {
container_mc._y = mask_mc._y;
}
if (container_mc._y<(mask_mc._y-(container_mc._height-mask_mc._height))) {
container_mc._y = mask_mc._y-(container_mc._height-mask_mc._height);
}
};
}
r = 0;
function startSlideshow() {
clearInterval(myInterval);
myInterval = setInterval(GoNext, delay);
}
<gallery thumb_width="70" thumb_height="72" gallery_width="80" gallery_height="449" gallery_x="785.8" gallery_y="14" full_x="28.0" full_y="16.0">
<image thumb_url="thumb1.jpg" full_url="image1.jpg" link="http://yahoo.com" title="Details of Picture Numbner one" />
<image thumb_url="thumb2.jpg" full_url="image2.jpg" link="http://gmail.com"title="Details of Picture Numbner two" />
<image thumb_url="thumb3.jpg" full_url="image3.jpg" link="http://rediffmail.com"title="Details of Picture Numbner three" />
<image thumb_url="thumb4.jpg" full_url="image4.jpg" link="http://viartguru.com"title="Details of Picture Numbner four" />
<image thumb_url="thumb5.jpg" full_url="image5.jpg" link="http://abc.com"title="Details of Picture Numbner five" />
<image thumb_url="thumb6.jpg" full_url="image6.jpg" link="http://xyz.com"title="Details of Picture Numbner six" />
<image thumb_url="thumb7.jpg" full_url="image7.jpg" link="http://testone.com"title="Details of Picture Numbner seven" />
<image thumb_url="thumb8.jpg" full_url="image8.jpg" link="http://testtwo.com"title="Details of Picture Numbner eight" />
<image thumb_url="thumb9.jpg" full_url="image9.jpg" link="http://testthree.com"title="Details of Picture Numbner nine" />
<image thumb_url="thumb10.jpg" full_url="image10.jpg" link="http://testfour.com"title="Details of Picture Numbner ten" />
<image thumb_url="thumb11.jpg" full_url="image11.jpg" link="http://testfive.com"title="Details of Picture Numbner eleven" />
<image thumb_url="thumb12.jpg" full_url="image12.jpg" link="http://testsix.com"title="Details of Picture Numbner twelve" />
<image thumb_url="thumb13.jpg" full_url="image13.jpg" link="http://testseven.com"title="Details of Picture Numbner thirteen" />
<image thumb_url="thumb14.jpg" full_url="image14.jpg" link="http://testeight.com"title="Details of Picture Numbner forteen" />
</gallery>