Hi, i posted this thread recently on this board but only ended up with half a solution. Duncanhall helped me out big time but we never quite solved the problem:
Duncanhall helped me create a script that when a button is pressed, fades in a white box…loads a new jpeg in a container clip underneath the white box…and when that is finished loading…the white box fades out again…revealing the image. I am basically creating photogallery with this effect. I know there are tutorials that do this with xml etc. but i was hoping to do something from scratch without xml if poss. ANYWAY the script worked fine but what i now need to do is, rather than apply this code to every button, set up a script that can perform the same action every time but just replace the image.ID with the corresponding button number. ANY IDEAS? below is the original script:
[FONT=Courier New][LEFT][COLOR=#808080]//IMPORTS[/COLOR]
[COLOR=#0000ff]import[/COLOR] mx.[COLOR=#000080]transitions[/COLOR].[COLOR=#000080]Tween[/COLOR];
[COLOR=#0000ff]import[/COLOR] mx.[COLOR=#000080]transitions[/COLOR].[COLOR=#000080]easing[/COLOR].;
[COLOR=#808080]//VARS*[/COLOR]
[COLOR=#000000]var[/COLOR] button_[COLOR=#000080]1[/COLOR]tween:[COLOR=#0000ff]Object[/COLOR];
[COLOR=#000000]var[/COLOR] container_mcl:[COLOR=#0000ff]MovieClipLoader[/COLOR] = [COLOR=#000000]new[/COLOR] [COLOR=#0000ff]MovieClipLoader[/COLOR]COLOR=#000000[/COLOR];
[COLOR=#000000]var[/COLOR] mcl_listener:[COLOR=#0000ff]Object[/COLOR] = [COLOR=#000000]new[/COLOR] [COLOR=#0000ff]Object[/COLOR]COLOR=#000000[/COLOR];
[COLOR=#808080]//EVENTS[/COLOR]
button[COLOR=#000080]1[/COLOR].[COLOR=#0000ff]onRelease[/COLOR] = [COLOR=#000000]function[/COLOR]COLOR=#000000[/COLOR]:V[COLOR=#0000ff]oid[/COLOR] [COLOR=#000000]{[/COLOR]
button_[COLOR=#000080]1[/COLOR]_tween = [COLOR=#000000]new[/COLOR] Tween[COLOR=#000000]([/COLOR][COLOR=#0000ff]this[/COLOR].[COLOR=#0000ff]_parent[/COLOR].[COLOR=#000080]white_block[/COLOR], [COLOR=#ff0000]“alpha"[/COLOR], Strong.[COLOR=#000080]easeInOut[/COLOR], [COLOR=#000080]0[/COLOR], [COLOR=#000080]100[/COLOR], [COLOR=#000080]30[/COLOR], [COLOR=#000000]false[/COLOR][COLOR=#000000])[/COLOR];
button[COLOR=#000080]1[/COLOR]_tween.[COLOR=#000080]onMotionFinished[/COLOR] = [COLOR=#000000]function[/COLOR]COLOR=#000000[/COLOR]:[COLOR=#0000ff]Void[/COLOR] [COLOR=#000000]{[/COLOR]
load_external_imageCOLOR=#000000[/COLOR];
[COLOR=#000000]}[/COLOR]
[COLOR=#000000]}[/COLOR]
mcl_listener.[COLOR=#0000ff]onLoadProgress[/COLOR] = [COLOR=#000000]function[/COLOR][COLOR=#000000]([/COLOR]target_mc:[COLOR=#0000ff]MovieClip[/COLOR], loadedBytes:[COLOR=#0000ff]Number[/COLOR], totalBytes:[COLOR=#0000ff]Number[/COLOR][COLOR=#000000])[/COLOR]:[COLOR=#0000ff]Void[/COLOR] [COLOR=#000000]{[/COLOR]
[COLOR=#000000]var[/COLOR] percentage:[COLOR=#0000ff]Number[/COLOR] = [COLOR=#0000ff]Math[/COLOR].[COLOR=#0000ff]round[/COLOR][COLOR=#000000]([/COLOR]COLOR=#000000[/COLOR] * [COLOR=#000080]100[/COLOR][COLOR=#000000])[/COLOR];
[COLOR=#0000ff]trace[/COLOR] [COLOR=#000000]([/COLOR]percentage + [COLOR=#ff0000]”% loaded"[/COLOR][COLOR=#000000])[/COLOR];
[COLOR=#000000]}[/COLOR]
mcl_listener.[COLOR=#0000ff]onLoadComplete[/COLOR] = [COLOR=#000000]function[/COLOR]COLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]
button_[COLOR=#000080]1[/COLOR]_tween = [COLOR=#000000]new[/COLOR] Tween[COLOR=#000000]([/COLOR]target_mc.[COLOR=#0000ff]_parent[/COLOR].[COLOR=#000080]white_block[/COLOR], [COLOR=#ff0000]"_alpha"[/COLOR], Strong.[COLOR=#000080]easeInOut[/COLOR], [COLOR=#000080]100[/COLOR], [COLOR=#000080]0[/COLOR], [COLOR=#000080]30[/COLOR], [COLOR=#000000]false[/COLOR][COLOR=#000000])[/COLOR];
[COLOR=#000000]}[/COLOR]
[COLOR=#808080]//FUNCS[/COLOR]
[COLOR=#000000]function[/COLOR] load_external_imageCOLOR=#000000[/COLOR]:[COLOR=#0000ff]Void[/COLOR] [COLOR=#000000]{[/COLOR]
container_mcl.[COLOR=#0000ff]loadClip[/COLOR][COLOR=#000000]([/COLOR][COLOR=#ff0000]“yourExternalImage.jpg”[/COLOR], container_mc[COLOR=#000000])[/COLOR];
[COLOR=#000000]}[/COLOR]
[COLOR=#808080]//RUN![/COLOR]
white_block.[COLOR=#0000ff]_alpha[/COLOR] = [COLOR=#000080]0[/COLOR];
container_mcl.[COLOR=#0000ff]addListener[/COLOR]COLOR=#000000[/COLOR];
[COLOR=#0000ff]stop[/COLOR]COLOR=#000000[/COLOR];
[/LEFT]
[/FONT]
and here is the loop script duncanhall came up with…but however many traces i used i couldnt find the problems or make it work!:
you could try something like this:
ActionScript Code:
[FONT=Courier New][LEFT][COLOR=#808080]/*****************
IMPORTS
*****************/[/COLOR]
[COLOR=#0000ff]import[/COLOR] mx.[COLOR=#000080]transitions[/COLOR].[COLOR=#000080]Tween[/COLOR];
[COLOR=#0000ff]import[/COLOR] mx.[COLOR=#000080]transitions[/COLOR].[COLOR=#000080]easing[/COLOR].;
[COLOR=#808080]/*****************
VARS
/[/COLOR]
[COLOR=#000000]var[/COLOR] button_tween:[COLOR=#0000ff]Object[/COLOR];
[COLOR=#000000]var[/COLOR] container_mcl:[COLOR=#0000ff]MovieClipLoader[/COLOR] = [COLOR=#000000]new[/COLOR] [COLOR=#0000ff]MovieClipLoader[/COLOR]COLOR=#000000[/COLOR];
[COLOR=#000000]var[/COLOR] mcl_listener:[COLOR=#0000ff]Object[/COLOR] = [COLOR=#000000]new[/COLOR] [COLOR=#0000ff]Object[/COLOR]COLOR=#000000[/COLOR];
[COLOR=#000000]var[/COLOR] number_of_images:[COLOR=#0000ff]Number[/COLOR] = [COLOR=#000080]50[/COLOR];
[COLOR=#808080]/
EVENTS
*****************/*[/COLOR]
mcl_listener.[COLOR=#0000ff]onLoadProgress[/COLOR] = [COLOR=#000000]function[/COLOR][COLOR=#000000]([/COLOR]target_mc:[COLOR=#0000ff]MovieClip[/COLOR], loadedBytes:[COLOR=#0000ff]Number[/COLOR], totalBytes:[COLOR=#0000ff]Number[/COLOR][COLOR=#000000])[/COLOR]:[COLOR=#0000ff]Void[/COLOR] [COLOR=#000000]{[/COLOR]
[COLOR=#000000]var[/COLOR] percentage:[COLOR=#0000ff]Number[/COLOR] = [COLOR=#0000ff]Math[/COLOR].[COLOR=#0000ff]round[/COLOR][COLOR=#000000]([/COLOR]COLOR=#000000[/COLOR] * [COLOR=#000080]100[/COLOR][COLOR=#000000])[/COLOR];
[COLOR=#0000ff]trace[/COLOR] [COLOR=#000000]([/COLOR]percentage + [COLOR=#ff0000]"% loaded"[/COLOR][COLOR=#000000])[/COLOR];
[COLOR=#000000]}[/COLOR]
mcl_listener.[COLOR=#0000ff]onLoadComplete[/COLOR] = [COLOR=#000000]function[/COLOR]COLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]
button_tween = [COLOR=#000000]new[/COLOR] Tween[COLOR=#000000]([/COLOR]target_mc.[COLOR=#0000ff]_parent[/COLOR].[COLOR=#000080]white_block[/COLOR], [COLOR=#ff0000]“alpha"[/COLOR], Strong.[COLOR=#000080]easeInOut[/COLOR], [COLOR=#000080]100[/COLOR], [COLOR=#000080]0[/COLOR], [COLOR=#000080]30[/COLOR], [COLOR=#000000]false[/COLOR][COLOR=#000000])[/COLOR];
[COLOR=#000000]}[/COLOR]
[COLOR=#808080]/*****************
FUNCS
*****************/[/COLOR]
[COLOR=#000000]function[/COLOR] initiate_button_eventsCOLOR=#000000[/COLOR]:[COLOR=#0000ff]Void[/COLOR] [COLOR=#000000]{[/COLOR]
[COLOR=#0000ff]for[/COLOR][COLOR=#000000]([/COLOR][COLOR=#000000]var[/COLOR] i:[COLOR=#0000ff]Number[/COLOR]=[COLOR=#000080]0[/COLOR]; i<number_of_images; i++[COLOR=#000000])[/COLOR] [COLOR=#000000]{[/COLOR]
[COLOR=#000000]var[/COLOR] targetButton_mc:[COLOR=#0000ff]MovieClip[/COLOR] = [COLOR=#0000ff]this[/COLOR][COLOR=#000000][[/COLOR][COLOR=#ff0000]"button”[/COLOR]+i[COLOR=#000000]][/COLOR];
targetButton.[COLOR=#000080]imageID[/COLOR] = i;
targetButton_mc.[COLOR=#0000ff]onRelease[/COLOR] = [COLOR=#000000]function[/COLOR]COLOR=#000000[/COLOR]:V[COLOR=#0000ff]oid[/COLOR] [COLOR=#000000]{[/COLOR]
button_tween = [COLOR=#000000]new[/COLOR] Tween[COLOR=#000000]([/COLOR][COLOR=#0000ff]this[/COLOR].[COLOR=#0000ff]_parent[/COLOR].[COLOR=#000080]white_block[/COLOR], [COLOR=#ff0000]"_alpha"[/COLOR], Strong.[COLOR=#000080]easeInOut[/COLOR], [COLOR=#000080]0[/COLOR], [COLOR=#000080]100[/COLOR], [COLOR=#000080]30[/COLOR], [COLOR=#000000]false[/COLOR][COLOR=#000000])[/COLOR];
button_tween.[COLOR=#000080]onMotionFinished[/COLOR] = [COLOR=#000000]function[/COLOR]COLOR=#000000[/COLOR]:[COLOR=#0000ff]Void[/COLOR] [COLOR=#000000]{[/COLOR]
[COLOR=#000000]var[/COLOR] image_to_load:[COLOR=#0000ff]String[/COLOR] = [COLOR=#ff0000]“image”[/COLOR]+[COLOR=#0000ff]this[/COLOR].[COLOR=#000080]obj[/COLOR].[COLOR=#000080]imageID[/COLOR]+[COLOR=#ff0000]".jpg"[/COLOR];
[COLOR=#0000ff]this[/COLOR].[COLOR=#000080]obj[/COLOR].[COLOR=#0000ff]_parent[/COLOR].[COLOR=#000080]container_mcl[/COLOR].[COLOR=#0000ff]loadClip[/COLOR][COLOR=#000000]([/COLOR]image_to_load, [COLOR=#0000ff]this[/COLOR].[COLOR=#000080]obj[/COLOR].[COLOR=#0000ff]_parent[/COLOR].[COLOR=#000080]container_mc[/COLOR][COLOR=#000000])[/COLOR];
[COLOR=#000000]}[/COLOR]
[COLOR=#000000]}[/COLOR]
[COLOR=#000000]}[/COLOR]
[COLOR=#000000]}[/COLOR]
[COLOR=#808080]/*****************
RUN, *****!
*****************/[/COLOR]
white_block.[COLOR=#0000ff]_alpha[/COLOR] = [COLOR=#000080]0[/COLOR];
container_mcl.[COLOR=#0000ff]addListener[/COLOR]COLOR=#000000[/COLOR];
[COLOR=#0000ff]stop[/COLOR]COLOR=#000000[/COLOR];
[/LEFT]
[/FONT]