all groups > flash actionscript > april 2006 >
You're in the

flash actionscript

group:

createEmptyMovieclip with onPress


Re: createEmptyMovieclip with onPress tralfaz
4/2/2006 12:54:02 PM
flash actionscript:
[quoted text, click to view]

You can either wait until the pictures load completely before positioning and assigning button actions, or the way I do it is to
make a double clip that allows me to position everything and assign button actions without waiting for the loading process..

mc1.mc2
mc1 is the base clip and can be used right away to set alpha, position, assign button actions
mc2 will load the image and we don't need to wait for it to finish.

// make the base clip 'box' at depth 10
this.createEmptyMovieClip("box",10);
var mc = this["box"];

//make the sub-clip 'holder' inside of the base clip at depth 11
mc.createEmptyMovieClip("holder",11);

// start loading a picture into the sub-clip
mc.holder.loadMovie("picture1.jpg");

// do anything you need to do to the base clip without waiting for the picture to load
mc.idNum = num;
mc._x = 100;
mc._y = 100;

mc.onPress = function()
{
info.text = this.idNum;
this._alpha = 30;
}

Here is an example of loading 9 thumbnail jpegs and using them (their base clips) as buttons..
http://www.kompanionkare.net/flash/buttons/imageButtons.html

tralfaz

createEmptyMovieclip with onPress Stckman
4/2/2006 4:50:08 PM
Hi. I was trying to create a series empty moviclips that i would fill with
dynamic images and then be able to click on each. (photo gallery)

I did manage to make a bunch of dynamically created movie clips. but when i
try to add a onPress to any of the dynamically created movie clips nothing
works. No hand no nothing. what am i doing wrong. i also tries this with
onRelease. onMouseUp or onMouseDown does it no matter where youclick. i want it
to work on the specifically created movieclip. any tips?

i also want to eventually createTextField underneath the picture. but right
now i just need onPress to WORK! any help would be appreciated.



//heres how i create a box ;

this.createEmptyMovieClip("imagebox01", 1);

this.imagebox01.loadMovie("http://i43.photobucket.com/albums/e359/stiqman/grdrmt
..jpg");
this.imagebox01._x = 50;
this.imagebox01._y = 100;

//here's how i ASSUME you give a onPress so the button is clickable;

this.imagebox01.onPress = function() {
getURL("http://www.yahoo.com", "_blank");
};
Re: createEmptyMovieclip with onPress w m d
4/2/2006 6:03:02 PM
I would guess that there is a problem because you are assigning the onPress
handler before the jpg finishes loading.

Try using the MovieClipLoader class -- and use the onLoadComplete event to
trigger a function that then assigns the onPress handler to the clip
Re: createEmptyMovieclip with onPress Stckman
4/2/2006 8:15:26 PM
AddThis Social Bookmark Button