I simplified some of the code and I attached the output screen. I'm using the
onEnterFrame of projector1_mc you can see it running in the output then I push
a button on the scroller and it goes through Intialize and in a short time it
loads the image and after that the projector1_mc onEnterFrame stops running.
Don't know why.
You can see the current state of the program running at:
http://www.jjesteban.com/template.cfm?s1=5&s2=1&ContentID=279
//code in frame 1 the only frame of the root
// variable declarations
var startingY:Number=display_mc.list_mc._y;
var bottom:Number=120;
var direction:String;
var scrollButtonPressed:Boolean=false;
var sitePath:String = "http://www.jjesteban.com";
var SlideDataIndex:Number;
//data variables
var columns:Array;
var dt:Array;
var dat:Array;
var
submitURL:String="http://www.jjesteban.com/flash/ScrollingList/getdata.cfm";
var submitQRY:String="select * from tbl_slideshow order by albumindex";
var datasource:String="jesteban";
var delim1:String="~";
var delim2:String="~~";
var dataReady:Boolean=false;
var firstTime:Boolean=true;
//LoadVars
var i_sql_lv:LoadVars=new LoadVars();
var o_sql_lv:LoadVars=new LoadVars();
//functions
//this goes and gets data from the database
function SandL()
{
o_sql_lv.qry=submitQRY;
o_sql_lv.ds=datasource;
o_sql_lv.delim1=delim1;
o_sql_lv.delim2=delim2;
i_sql_lv.reply_qry=""; //SQL Text
i_sql_lv.reply_ds=""; //datasource
i_sql_lv.reply_c=""; //column headings
i_sql_lv.reply_d=""; //data
o_sql_lv.sendAndLoad(submitURL,i_sql_lv,"POST");
}
//this builds the scroller
function buildList()
{
var spacing:Number=30;
for(var i:Number=0;i<dt.length;i++)
{
var name:String = "infoBar" + String(i) + "_mc";
var y:Number = i * spacing;
display_mc.list_mc.attachMovie("infoBar",name,i);
display_mc.list_mc[name]._y=y;
display_mc.list_mc[name].title_txt.text = dat[i][2];
display_mc.list_mc[name].num_txt.text = dat[i][0];
display_mc.list_mc[name].datidx=i;
display_mc.list_mc[name].onRelease=function()
{
SlideDataIndex=this.datidx;
counter=0;
display_mc.title_txt.text=dat[SlideDataIndex][2];
display_mc.total_txt.text=dat[SlideDataIndex][6];
display_mc.slidestart_btn.enabled=false;
display_mc.slidestart_btn._visible=false;
display_mc.slidestop_btn.enabled=true;
display_mc.slidestop_btn._visible=true;
display_mc.slideinc_btn.enabled=false;
display_mc.slideinc_btn._visible=false;
display_mc.slidedec_btn.enabled=false;
display_mc.slidedec_btn._visible=false;
projector1_mc.Initialize(200,Number(dat[SlideDataIndex][3]),Number(dat[SlideD
ataIndex][6]),true,sitePath+dat[SlideDataIndex][1],dat[SlideDataIndex][5],dat[Sl
ideDataIndex][4]);
}
}
}
function scroll()
{
var speed:Number=10;
if(direction=="up")
{
if(display_mc.list_mc._y - speed + display_mc.list_mc._height > (startingY +
bottom))
{
display_mc.list_mc._y -= speed;
}
else
{
display_mc.list_mc._y = (startingY + bottom) - display_mc.list_mc._height;
}
}
else if(direction=="down")
{
if(display_mc.list_mc._y + speed < startingY)
{
display_mc.list_mc._y += speed;
}
else
{
display_mc.list_mc._y = startingY;
}
}
}
//events
i_sql_lv.onLoad=function(success)
{
if(success)
{
// Column Names
columns = new Array();
columns = i_sql_lv.reply_c.split(delim1);
// Column Data
dt = new Array();
dt = i_sql_lv.reply_d.split(delim2);
dat = new Array(dt.length);
for( var i:Number=0; i < dt.length;i++)
{
dat[i] = new Array();
dat[i] = dt[i].split(delim1);
}
dataReady=true;
}
else
{
dataReady=false;
}
}
display_mc.down_btn.onPress=function()
{
scrollButtonPressed=true;
direction="down";
}
display_mc.down_btn.onRelease=function()
{
scrollButtonPressed=false;
}
display_mc.up_btn.onPress=function()
{
scrollButtonPressed=true;
direction="up";
}
display_mc.up_btn.onRelease=function()
{
scrollButtonPressed=false;
}
display_mc.slidestop_btn.onRelease=function()
{
//goShow=false;
//counter=counterMax;
//fade=false;
display_mc.slidestop_btn.enabled=false;
display_mc.slidestop_btn._visible=false;
display_mc.slidestart_btn.enabled=true;
display_mc.slidestart_btn._visible=true;
display_mc.slideinc_btn.enabled=true;
display_mc.slideinc_btn._visible=true;
display_mc.slidedec_btn.enabled=true;
display_mc.slidedec_btn._visible=true;
}
display_mc.slidestart_btn.onRelease=function()
{
//goShow=true;
//fade=true;
display_mc.slidestart_btn.enabled=false;
display_mc.slidestart_btn._visible=false;
display_mc.slidestop_btn.enabled=true;
display_mc.slidestop_btn._visible=true;
display_mc.slideinc_btn.enabled=false;
display_mc.slideinc_btn._visible=false;
display_mc.slidedec_btn.enabled=false;
display_mc.slidedec_btn._visible=false;
}
display_mc.slideinc_btn.onRelease=function()
{
//changeSlide(currentSlide+1);
//counter=counterMax;
}
display_mc.slidedec_btn.onRelease=function()
{
//changeSlide(currentSlide-1);
//counter=counterMax;
}
//Setup
blinker_mc.gotoAndStop("loaded");
display_mc.slidestart_btn.enabled=false;
display_mc.slidestart_btn._visible=false;
display_mc.slidestop_btn.enabled=false;
display_mc.slidestop_btn._visible=false;
display_mc.slideinc_btn.enabled=false;
display_mc.slideinc_btn._visible=false;
display_mc.slidedec_btn.enabled=false;
display_mc.slidedec_btn._visible=false;
display_mc.progress_mc._visible=false;
slideload_mc._visible=false;
slideload_txt._visible=false;
SandL();
//Program Start
_root.onEnterFrame=function()
{
if(firstTime and dataReady)
{
buildList();
firstTime=false;
}
if(!firstTime and dataReady)
{
if(scrollButtonPressed)
{
scroll();
}
trace("root");
}
}
// code is frame 1 the onl frame of projector1_mc This is the frame that the
image is displayed in and it is attached to the Projector class via linkage
//Projector.as
class Projector extends MovieClip
{
//private variable declarations
private var fade:Boolean=true;
private var projectorWidth:Number=100;
private var imagePath:String="";
private var imageFile:String="";
private var imageExt:String=".jpg";
private var firstImage:Number=1;
private var lastImage:Number=1;
private var currentImage:Number=1;
private var counterMax:Number=150;
private var counter:Number=0;
private var count:Boolean=false;
private var fadeoutRange:Number=30;
private var fadeinRange:Number=30;
//loaders and listeners
private var Projector_mclLoader:MovieClipLoader;
private var Projector_mclListener:Object;
//constructor
function Projector()
{
trace("In Projector");
Projector_mclLoader=new MovieClipLoader;
Projector_mclListener=new Object();
Projector_mclLoader.addListener(Projector_mclListener);
var thisObj:Projector = this;
Projector_mclListener.onLoadInit=function(target_mc:MovieClip)
{
var w:Number = target_mc._width * 100 / target_mc._xscale;
var h:Number = target_mc._height * 100 / target_mc._yscale;
target_mc._xscale=Math.round(20000/target_mc._width);
target_mc._yscale=target_mc._xscale;
target_mc.lineStyle(4*100/target_mc._xscale,0x000000,100);
target_mc.lineTo(0,h);
target_mc.lineTo(w,h);
target_mc.lineTo(w,0);
target_mc.lineTo(0,0);
target_mc._alpha=fade?0:100;
target_mc._count=true;
var c:String=target_mc._count?"true":"false";
target_mc._counter=0;
var n:Number=target_mc._counter;
trace("count=" + c + " counter=" + String(n) + " Image Number = " +
String(target_mc.currentImage));
trace("Projector_mclListener.onLoadInit");
}
Projector_mclListener.onLoadError=function(target_mc:MovieClip,errorcode:Strin
g)
{
trace("onLoadError errorcode= " + errorcode);
}
}
public function
Initialize(w:Number,fir:Number,las:Number,fad:Boolean,path:String,file:String,ex
t:String)
{
trace("Initialized");
this.firstImage=fir;
this.lastImage=las;
this.currentImage=this.firstImage-1;
this.fade=fad;
this.imagePath=path;
this.imageFile=file;
this.imageExt=ext;
this.projectorWidth=w;
this.counter=140;
this.counterMax=150;
this._count=true;
}
private function changeImage(number:Number)
{
if(number < firstImage)
{
number = lastImage;
}
if(number > lastImage)
{
number = firstImage;
}
if(number >= firstImage & number <= lastImage)
{
currentImage = number;
this._yscale=100;
this._xscale=100;
this.count=false;
this.counter=0;
Projector_mclLoader.loadClip(imagePath + imageFile + String(number) +
imageExt,this._name);
}
}
private function Alpha(fiRange:Number, foRange:Number):Number
{
var alpha:Number=100;
var foThreshold:Number=counterMax-foRange;
var fiThreshold:Number=fiRange;
var fadeThreshold:Number=(fiRange+foRange)*0;
if(counterMax >= fadeThreshold and fade==true)
{
if((counterMax-counter)<=foRange )
{
alpha=100-(((counter-foThreshold)/foRange)*100);
}
if(counter<=fiThreshold)
{
alpha=100-(((fiThreshold-counter)/fiRange)*100);
}
}
return(alpha);
}
public function run()
{
var c:String=this._count?"true":"false";
trace("_count=" + c + "_counter=" + String(this._counter));
if(this._count)
{
//this._alpha=Alpha(this.fadeinRange,this.fadeoutRange);
if(++this._counter>=this._counterMax)
{
this.changeImage(this.currentImage+1);
}
}
}
public function set _count(n:Boolean)
{
count=n;
}
public function get _count():Boolean
{
return count;
}
public function set _counter(n:Number)
{
counter=n;
}
public function get _counter():Number
{
return counter;
}
public function get _counterMax():Number
{
return counterMax;
}
}
//output screen
D:\jjesteban.com\src\flash\SlideScroller\scrollingList