Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > Extensions and Plugins > Components

Reply
 
Thread Tools Rate Thread Display Modes
Old 03-23-2003, 04:34 PM   #1
yorkeylady
Registered User
 
Join Date: Jan 2003
Posts: 397
Send a message via ICQ to yorkeylady Send a message via AIM to yorkeylady Send a message via Yahoo to yorkeylady
Default preload/setInterval /resizing/fading images code needs refining

Can someone check this fla for me.
This is the function that goes with my listbox:
function onClick(){
var num = _title.getSelectedIndex();
for(var i=0;i<listbox.getRowCount();i++){
if(num == testvalue){
//do something here
}
}
pic = _title.getValue();
_picbox.disappear(num, pic);
}

// this is in a MC called _picbox
stop();
//trace("in loadMC of picbox");
alph = 0;
function disappear(num, pic){
trace("in disappear("+num+", "+pic+")");
for(var i=0;i<_parent.listbox.getRowCount();i++){
if(num != i ){
if(this["pic_"+num]){
trace("setting "+num+" to invisible");
this["pic_"+num]._alpha = 0;
}
}
}
fadeimg(num,pic);
}

function fadeimg(num,pic){
//set the picture chosen to 100%
trace("in fadeimg("+num+", "+pic+")");
if(this["pic_"+num]){
this["pic_"+num]._alpha = 100;
fader2 = setInterval(bringin, 10, num);
}else{loadMC(num, pic)}
}
function bringin(num){
trace("in bringin("+num+")");
alph += 10;
this["pic_"+num]._alpha = alph;
if(alph >= 100){this["pic_"+num]._alpha = 100;
trace("clear interval fader2");
clearInterval(fader2);
}
}


function loadMC(num, pic){
trace("in loadMC("+num+", "+pic+")");

if(pic != ""){
trace("this visible false");
this._visible = false;
var j = num + 10;
trace("loading pic: "+pic);
this.createEmptyMovieClip("pic_"+num,j);
this["pic_"+num].loadMovie(pic, j);
preload(num);
}else{trace("pic variable isn't set :"+pic);}
}

function preload(num) {
trace("in preload("+num+")");
//preloader._visible = true;
//preloader._bar._xscale = 0;
//preloader.display.text = "0% loaded";
loadinter = setInterval(callback, 10, num);
}
function callback(num) {
trace("in callback("+num+")");
//this traces as undefined, it should have been created above in loadMC()
trace(this["pic_"+num]);
var download = this["pic_"+num].getBytesTotal();
var downloaded = this["pic_"+num].getBytesLoaded();
var percentLoaded = Math.cell(downloaded/download*100);
// preloader.display.text = percentLoaded+"% loaded";
// preloader.bar._xscale = percentLoaded;
updateAfterEvent();
trace("callback is called");
if (downloaded == download && download>0) {
//preloader._visible = false;
trace("setpicture is called");
clearInterval(loadinter);
setpicture(num, 275, 200, 0,0);
}
}

function setpicture(num, bw, bh, xp, yp){
trace("in setpicture");
var w = this["pic_"+num]._width;
var h = this["pic_"+num]._height;
var x = 0;
var y = 0;
if(w <= bw){
}else{
h = Math.round(h*bw/w);
w = bw;
}
if(h < 200){
}else{
w = Math.round(w*200/h);
h = bh;
}
if(h <= bh && w <= bw){
var center = ( bh - h)/2;
y = center;
center = (bw - w)/2;
x = center;
}
var al = 0;
with(this["pic_"+num]){
_width = w;
_height = h;
_x = xp+x;
_y = yp+y;
_alpha = 100;
}
trace("this visible true");
this._visible = true;
fader1 = setInterval(inload, 10, num);
}

function inload(num){
trace("inload alph: "+alph);
alph += 10;
this["pic_"+num]._alpha = alph;
if(alph > 80){
this["pic_"+num]._alpha = 100;
clearInterval(fader1);
}
}

Last edited by yorkeylady; 03-23-2003 at 04:49 PM.
yorkeylady is offline   Reply With Quote
Old 03-23-2003, 04:43 PM   #2
yorkeylady
Registered User
 
Join Date: Jan 2003
Posts: 397
Send a message via ICQ to yorkeylady Send a message via AIM to yorkeylady Send a message via Yahoo to yorkeylady
Default here is the fla

oops, forgot to upload this
Attached Files
File Type: zip preloadnsize.zip (72.4 KB, 154 views)
yorkeylady is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT. The time now is 03:24 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.