Could someone please post the final fla as i can’t ge this to work for some reason.
Great! setting the variable with _root.x works and solves that problem.
However, checking when the border is the same size as the picture (taking account of the added width) is being problematic. I also have a less than elegant way of checking - but works sort of!
I have the following code in a separate MC with two frames to create a loop. Frame 2 is empty and Frame 1 has the following:
[AS]
if ((_root.border._width>(_root.picture._width+39)) &&
(_root.border._height>(_root.picture._height+39))) {
_root.picture._visible = 1;
_root.textBox._visible = 1;
}
[/AS]
I have tried to put this on the border MC but it doesn’t work.
One problem is that == doeszn’t work in the above script - any suggestions? The use of ‘>’ is not ideal and not accurate enough with the timing in making the picture visible.
Frame loops are for Flash 4
onClipEvent(enterFrame) is Flash 5 and Flash MX on a movie clip.
this.onEnterFrame = function() {//code here} is Flash MX on a frame.
As for why == doesn’t work, it is because you are using the easing equation and the numbers you get by dividing by the speed aren’t going to be exactly equal to the end number.
Maybe try working with Math.floor(), Math.round(), or Math.ceil() to round the number appropriately and possibly fix that problem.
I came up with this for someone at actionscript.org the other day. It was used for scaling fading but still using the easing equation and deletes the onEnterFrame command appropriately (man was that a task). It could be used just for scaling as well though with a little editing (removing anything dealing with alpha)
[AS]MovieClip.prototype.initiateFader = function(inOrOut, finalX, finalY, finalA, speed) {
this.onEnterFrame = function() {
if (inOrOut == “fadeOut”) {
this._xscale += (finalX-this._xscale)/speed;
this._yscale += (finalY-this._yscale)/speed;
this._alpha += (finalA-this._alpha)/speed;
this.xs = Math.floor(this._xscale);
this.ys = Math.floor(this._yscale);
this.af = Math.floor(this._alpha);
} else if (inOrOut == “fadeIn”) {
this._xscale += Math.ceil((finalX-this._xscale)/speed);
this._yscale += Math.ceil((finalY-this._yscale)/speed);
this._alpha += Math.ceil((finalA-this._alpha)/speed);
this.xs = Math.ceil(this._xscale);
this.ys = Math.ceil(this._yscale);
this.af = Math.ceil(this._alpha);
}
trace(this.xs+" : “+this.ys+” : "+this.af);
if (this.xs == finalX && this.ys == finalY && this.af == finalA) {
trace(“transition complete”);
this._xscale = finalX;
this._yscale = finalY;
this._alpha = finalA;
delete this.onEnterFrame;
}
};
};
HitArea.onRollOver = function() {
this.initiateFader(“fadeOut”, 75, 50, 50, 6);
};
HitArea.onRollOut = function() {
this.initiateFader(“fadeIn”, 100, 100, 100, 6);
};[/AS]
Thank you - I will go away and play around with the script you have kindly provided - but I might be back!!
As for the loop - yep - soooo flash 4 - but because I recently upgraded I am learning loads ( this thread alone has made me really try and get to grips with the scripting believe it or not)
As for the == , your explanation makes perfect sense!
Osc
Hi again!
Because the macromedia gallery example does not have a preloader - I tried to adapt the scripts from earlier in this thread to make a pseudo back and forward button - it works - I can easily go back and forward - but the preloader part does not work.
Is it possible to have an if within if???
This is the back button example… the _root.b variable is set by the first thumbnail that is pressed - ie so when I delete 1 from n, it will call the previous sibling in the script.
[AS]
on (release)
{
if ((n>0) && (n<=3)) {
var n = ((_root.b–)-1);
trace("n "+n)
this.createEmptyMovieClip(“preloader”,1000
_root.picture.picture2.loadMovie(pictures.childNodes[0].childNodes[n].attributes[“jpegURL”]);
picture._visible = false;
loadBar._visible = 1;
textBox._visible = false;
preloader.onEnterFrame = function() {
var l = picture.getBytesLoaded();
var t = picture.getBytesTotal();
var getPercent = l/t;
loadBar._width = getPercent*100;
if (l>0 && l>=t) {
trace(“loaded back”);
textBox.picTitle =
pictures.childNodes[0].childNodes[n].childNodes[0].nodeValue;
picture._visible = 1;
textBox._visible = 1;
loadBar._visible = false;
_root.x = picture._width;
_root.y = picture._height;
delete this.onEnterFrame;
}
}
}
[/AS]
[AS]delete this.onEnterFrame;[/AS]
It stopped working because you made it stop running
Hey All,
This is a very useful thread and I have done a little tweak allowing the loading of random images…(I know, simple stuff!)
All I was wandering is what would I have to tweak in order to have the loaded image/movieclip fade gradually using actionscript.
stop();
footers = 6;
randomnumber = Math.ceil(Math.random()footers)
this.createEmptyMovieClip(“preloader”, 1000);
this.createEmptyMovieClip(“container”, 1001);
container.loadMovie(randomnumber add “.jpg”);
container._visible = false;
preloader.onEnterFrame = function() {
var l = container.getBytesLoaded();
var t = container.getBytesTotal();
var getPercent = l/t;
loadText = Math.round(getPercent100)+"%";
loadBar._width = getPercent*100;
if (l>0 && l>=t) {
container._visible = 1;
delete this.onEnterFrame;
play();
}
};
I know I would have to change _visible to _alpha and maybe use a onEnterFrame command to increase the _alpha - but I am stuck!
Any help would be greatly appreciated!
mecha
Hello!
Having got everything to work so far - I seem to have stumbled on an even more elementary problem. The script that you have been helping with works great if the buttom is on the main stage - however, if I try and button the AS in a button in another MC, it doesn’t work.
In other words, the picture MC is placed on the main stage, I then have an MC1 with an MC2 within it. The buttons are on MC2 - however, it doesn’t work…
even this doesn’t work:
[AS]
_root.picture.picture2.loadMovie(pictures.childNodes[0].childNodes[1].attributes[“jpegURL”]);
[/AS]
Surely the _root takes care of the path??
Osc
Got it to work - and yes it was obvious - I had forgotten to add the _root to the path for the xml file, and not just the picture MC!!
Osc
just reading through some posts and … what happened lostinbeta. you seem so bitter now. sniffle i miss the old ‘happy to help’ beta
*Originally posted by shuga *
**just reading through some posts and … what happened lostinbeta. you seem so bitter now. sniffle i miss the old ‘happy to help’ beta **
I’m still that guy… sometimes (-:
I think here I was just reaching my limit on preloader questions, it’s been built up over the past few weeks after mass amounts of preloader questions via the forum, my PM Inbox, and my e-mail. But now I think I am better, as my footer states I don’t accept Flash questions in my PM Inbox (defeats the entire purpose of the forum) and I am now officially retired from preloader questions, there is most likely nothing someone can ask about preloaders that they can’t find on the forum by searching by now.
Hello guys! I was following your post, but i got lost.
Because my images are in .swf and not jpeg. and also I am a Flash Newbie.
Is there a way to create thesame thing? that when you click on the button, it shows the preloader first before it displays the image to an empty movieclip on another .swf, before it loads to the main movie.
I try another way of creating it but I think its a bit daft. I try adding a preloader on one images, but it doesnt work. the loading animation is still there visible and keeps on playing so i decided to stop. And oh yah… because i had 38 images i think it will take me ages to finish this project.
this might help you what i meant to do. heres the add of my site.
www.metalgurl.tk
noticed the gallery, if you had a DSL connection you’ll be alright, but how about our Dial UP friend?
Your help are always appreciated. thanks!
hmm, i am trying your code and i get NAN and then it jumps to 100% and the loadbar as well. Your code is just on the root, right???
Hmm… I don’t get the ‘yourImage.jpg’. How does this work exactly – if you’re loading dynamic information into a movieclip? For example - using an infinite menu and XML, it loads jpegs with various names which change, how can we pin it down to 'yourImage.jpg"? I’m confused I think.
Basically, I want there to be a pre-loader that appears as my dynamic jpeg or SWF is being loaded. I tried the above code, no luck.
Thanks for any info!
-md