| Ultrashock Forums
• Buttons to switch between clips |
|||
![]() |
||||
| Search this Thread | Thread Tools | Display Modes |
|
|
|||||||||||||||||||||||||
![]() |
Ultrashock Member Comments:
|
2009-06-27
#2 |
||
|
|
2009-06-27
#3 |
||
|
Thanks Jase! I will try to explore base on your reply. If you could prepare a FLA file for reference, that would be great to me.
|
|
|
2009-06-27
#4 |
||
|
Hi Jase, I still cannot figure out how to do that. I'm just a beginner. Could you please explain a little bit more in detail like which layer I should put what... etc. Appreciate your great help! kklui. |
|
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|



3 comments
| 108 views



Linear Mode
overview:
You are going to make a movieClip symbol that fades another movieClip in and out by adjusting the _alpha property of the embedded image.
Then, in another movieClip, you will make the buttons for each image you want to substitute for the fade effect.
When a button is clicked, the fading movieClip fades the image out and tells the parent object to load a new image. The parent object then loads the new image from the library and fades the image to 100 %.
the Actionscript you could use would be something like:
function buildImages() {
//create an array of images whose Linkage ID you setup in advance
this.imageList=new Array();
//each image should be named "image_n" where "n" is a number from 0 to the total number of images (5 in this example);
var imageCount:Number=5;
for (var i=0;i<imageCount;i++) {
this.imageList.push("image_"+i);
}
this.imageHolder=this.createEmptyMovieClip("imageHolder", this.getNextHighestDepth());
this.imageHolder.controller=this;
this.buildButtons();
}
function buildButtons() {
/*assume that you have a movieClip object with an embedded button and a text Field.
The text field's variable property is set to "label" and given the instance name "label_txt".
The button object is given an instance name of "btn";
*/
var imageCount:Number=this.imageList.length;
var buttonHolder:MovieClip=this.createEmptyMovieClip("buttonHolder", this.getNextHighestDepth());
for (var i=0;i<imageCount;i++) {
var label:String = i.toString();
var nm:String = "button_"+i;
var dp:Number=buttonHolder.getNextHighestDepth();
var ini:Object={label:label, id:i, controller:this};
var mc:MovieClip=buttonHolder.attachMovie("imageButton", nm, dp, ini);
mc.btn.onRelease=function () {
this._parent.controller.showImage(this._parent.id);
}
this.showImage(0);
}
public function showImage(id:Number) {
this.imageHolder.nextID=id;
this.imageHolder.onEnterFrame=function () {
this.image_mc._alpha--;
if (this.image_mc._alpha<=0) {
this.image_mc._alpha=0;
delete this.onEnterFrame;
this.controller.loadImage(this.nextID);
}
}
public function loadImage(id:Number) {
var lnk:String = this.imageList[id];
var mc:MovieClip=this.imageHolder.image_mc;
removeMovieClip(mc);
var mc:MovieClip=this.imageHolder.attachMovie(lnk, "image_mc", 100, {_alpha:0});
this.imageHolder.onEnterFrame=function () {
this.image_mc._alpha++;
if (this.image_mc._alpha>=100) {
this.image_mc._alpha=100;
delete this.onEnterFrame;
}
}
}
This is kinda rough code and I should spend some time to explain it better, but I have to run. Hopefully this will get you started and I can answer any questions you have. If you are more of a beginner at Flash than this, let me know and I will try to put a file together for you.
Hope this gets ya started,
Jase