Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 06-14-2005, 07:08 AM   #1
diciccod
Registered User
 
Join Date: Jun 2005
Location: Michigan State U
Posts: 68
Default Add onSomething to Array MovieClip

i would like to add button functionality to a movieclip stored in an array
the image loads fine in the final product but i cant get any onRollOver or onPress to work.

ActionScript Code:
var buttonarray:Array=new Array(); var xspot = 0; for(var i = 0; i<=4; i++) {      buttonarray[i] = createEmptyMovieClip("movieclip"+i,this.getNextHighestDepth);      loadMovie("bg.jpg",_root["movieclip"+i]);      buttonarray[i]._yscale = 100;      buttonarray[i]._xscale = 100;      buttonarray[i]._x = xspot;      buttonarray[i].onPress = function() {          trace("ihopethisworks");          }      xspot += 10; } trace(buttonarray);
diciccod is offline   Reply With Quote
Old 06-14-2005, 07:52 AM   #2
agent81
member
 
Join Date: Jan 2003
Location: Melbourne
Posts: 518
Default

wait untill the loading has begun, to assign events to your button, or create another movie inside the button, and load the image into that.

(loadMovie replaces the current movie with the loaded movie, therefore resetting the events attached to it)
agent81 is offline   Reply With Quote
Old 06-14-2005, 07:55 AM   #3
diciccod
Registered User
 
Join Date: Jun 2005
Location: Michigan State U
Posts: 68
Default

what do u mean wait until the loading has begun.. i see that it replaces the clip, so how do i refer to the new loaded clip to assign a button handler to
diciccod is offline   Reply With Quote
Old 06-14-2005, 09:00 AM   #4
diciccod
Registered User
 
Join Date: Jun 2005
Location: Michigan State U
Posts: 68
Default

Ok, i did what u said and i made a movieclip to handle the button events on the outside. And your right it does allow me to click and roll over. But now i can't load more than one picture? Everytime it goes through the loop it seems to erase the picture and clip before it because i am only getting the last picture and clip it calls me at the last x location

ActionScript Code:
var xspot = 0; for(var i = 1; i<=4; i++) {      createEmptyMovieClip("movieclipholder"+i,this.getNextHighestDepth); //Creates the holder      _root["movieclipholder"+i].createEmptyMovieClip("movieclip"+i,this.getNextHighestDepth); //Creates the picholder inside the clipholder      loadMovie("photoalbum/bullfrog111704/thumbs/"+i+".jpg",_root["movieclipholder"+i]["movieclip"+i]); //Adds the pic to the inside picholder      _root["movieclipholder"+i]._x = xspot; // Just moves the clipholder's x so they arent over eachother      _root["movieclipholder"+i].onPress = function() { // Sets up btn function on clipholder           trace("why is there only one picture!");           trace(this);          }          xspot += 100;         }
diciccod is offline   Reply With Quote
Old 06-14-2005, 09:04 AM   #5
pajaro
Registered User
 
Join Date: Jun 2005
Posts: 8
Default

(loadMovie replaces the current movie with the loaded movie, therefore resetting the events attached to it)

well, I think that onClipEvent(load) event does not get replaced
pajaro is offline   Reply With Quote
Old 06-14-2005, 09:13 AM   #6
diciccod
Registered User
 
Join Date: Jun 2005
Location: Michigan State U
Posts: 68
Default

are you just saying that to respond to what agent said? because i cant see how it would tie in with my case
diciccod 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 09:23 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.