cangeceiro
12-18-2007, 02:46 PM
Im currently working on building a revolving image ticker type system with flash. but im having a few issues.
the issue im stumped on is depth swapping in flash. I have a for loop that dynamically creates copies of a movie clip i have in my library based on data pulled from a drupal/amfphp services setup. The clip has 2 text fields, the mx.loader component, and a button. . This being the first time i have worked with depths, im really not sure where to even begin to get this to work right. ideally i want to mouse over one of the instances of the clip and it come to the front.
this is my first time working with remoting and depths, so i could be going about this all wrong.
here is my code.
first frame
import mx.remoting.*;
import mx.rpc.*;
import mx.utils.Delegate;
import mx.remoting.debug.NetDebug;
var gatewayUrl:String = siteRoot + "/services/amfphp";
var imagePath:String = "files/imagecache/flash_image/";
var view:Service = new Service(gatewayUrl, null, "views", null, null);
infoTxt.text = "Loading....";
NetDebug.initialize();
getView('flash_feed','onResultSuccess',['title','path','teaser','field_flash_rotation_imag e']);
function onResultSuccess(re:ResultEvent){
var oTicker:Object = re.result;
var xpadding:Number = 400/oTicker.length;
var z:Number = 0;
var countDown:Number = oTicker.length;
var counter = countDown;
for (i = 0; i < oTicker.length; i++) {
if (i == 0) {
alphaVal = 100;
} else {
alphaVal = 50;
}
trace("Path:" + oTicker[i].path);
trace("Counter:" + counter);
imageClip = this.attachMovie('imageClip','image' + i, counter, {
_x:0,
_y:0,
_alpha:alphaVal,
xpadding:z,
titleText:oTicker[i].title,
teaserText:oTicker[i].teaser,
path:oTicker[i].path,
imageHolder:siteRoot + imagePath + oTicker[i].field_flash_rotation_image[0].filepath
});
imageClip.onEnterFrame = updateClip;
z=z+xpadding;
counter = countDown-1;
}
}
function getView (viewName:String, handler:String, fields:Array, arg:Array) {
var pc:PendingCall = view.getView (viewName, fields, arg);
pc.responder = new RelayResponder (this, handler, "handleRemotingError");
}
function handleRemotingError (fault:FaultEvent):Void {
NetDebug.trace ({level:"None", message:"Error: " + fault.fault.faultstring});
}
function updateClip() {
this.titleTxt.text = this.titleText;
this.teaserTxt.text = this.teaserText;
this.imageLoader._x = this.xpadding;
this.gotoBtn._x = this.xpadding;
this.imageLoader.contentPath = this.imageHolder;
this.infoLoaded = imageLoader.getBytesLoaded();
this.infoTotal = imageLoader.getBytesTotal();
this.percentage = Math.floor(this.infoLoaded/this.infoTotal*100);
infoTxt.text = percentage+"%";
if (percentage>=100) {
delete this.onEnterFrame;
//infoTxt._visible = false;
}
}
button in image_clip from library
on(release) {
getURL(path);
}
on(rollOver) {
trace("Rollover start:" + _parent.getDepth());
titleTxt._visible = true;
teaserTxt._visible = true;
trace("Rollover after:" + _parent.getDepth());
}
on(rollOut) {
trace("Rollout start:" + _parent.getDepth());
titleTxt._visible = false;
teaserTxt._visible = false;
trace("Rollout after:" + _parent.getDepth());
}
the issue im stumped on is depth swapping in flash. I have a for loop that dynamically creates copies of a movie clip i have in my library based on data pulled from a drupal/amfphp services setup. The clip has 2 text fields, the mx.loader component, and a button. . This being the first time i have worked with depths, im really not sure where to even begin to get this to work right. ideally i want to mouse over one of the instances of the clip and it come to the front.
this is my first time working with remoting and depths, so i could be going about this all wrong.
here is my code.
first frame
import mx.remoting.*;
import mx.rpc.*;
import mx.utils.Delegate;
import mx.remoting.debug.NetDebug;
var gatewayUrl:String = siteRoot + "/services/amfphp";
var imagePath:String = "files/imagecache/flash_image/";
var view:Service = new Service(gatewayUrl, null, "views", null, null);
infoTxt.text = "Loading....";
NetDebug.initialize();
getView('flash_feed','onResultSuccess',['title','path','teaser','field_flash_rotation_imag e']);
function onResultSuccess(re:ResultEvent){
var oTicker:Object = re.result;
var xpadding:Number = 400/oTicker.length;
var z:Number = 0;
var countDown:Number = oTicker.length;
var counter = countDown;
for (i = 0; i < oTicker.length; i++) {
if (i == 0) {
alphaVal = 100;
} else {
alphaVal = 50;
}
trace("Path:" + oTicker[i].path);
trace("Counter:" + counter);
imageClip = this.attachMovie('imageClip','image' + i, counter, {
_x:0,
_y:0,
_alpha:alphaVal,
xpadding:z,
titleText:oTicker[i].title,
teaserText:oTicker[i].teaser,
path:oTicker[i].path,
imageHolder:siteRoot + imagePath + oTicker[i].field_flash_rotation_image[0].filepath
});
imageClip.onEnterFrame = updateClip;
z=z+xpadding;
counter = countDown-1;
}
}
function getView (viewName:String, handler:String, fields:Array, arg:Array) {
var pc:PendingCall = view.getView (viewName, fields, arg);
pc.responder = new RelayResponder (this, handler, "handleRemotingError");
}
function handleRemotingError (fault:FaultEvent):Void {
NetDebug.trace ({level:"None", message:"Error: " + fault.fault.faultstring});
}
function updateClip() {
this.titleTxt.text = this.titleText;
this.teaserTxt.text = this.teaserText;
this.imageLoader._x = this.xpadding;
this.gotoBtn._x = this.xpadding;
this.imageLoader.contentPath = this.imageHolder;
this.infoLoaded = imageLoader.getBytesLoaded();
this.infoTotal = imageLoader.getBytesTotal();
this.percentage = Math.floor(this.infoLoaded/this.infoTotal*100);
infoTxt.text = percentage+"%";
if (percentage>=100) {
delete this.onEnterFrame;
//infoTxt._visible = false;
}
}
button in image_clip from library
on(release) {
getURL(path);
}
on(rollOver) {
trace("Rollover start:" + _parent.getDepth());
titleTxt._visible = true;
teaserTxt._visible = true;
trace("Rollover after:" + _parent.getDepth());
}
on(rollOut) {
trace("Rollout start:" + _parent.getDepth());
titleTxt._visible = false;
teaserTxt._visible = false;
trace("Rollout after:" + _parent.getDepth());
}