You have a couple of options:
You could add an optional parameter to the function that handles the click,
like this:
function clickThumb(e:MouseEvent,index:int = 0):void{
}
Setting a default value for the index parameter allows the function to be
called without passing it. That's what will happen when a thumb is clicked.
When you want to call the function directly, you'd do:
clickThumb(null,image_num + 1);
In clickThumb, check whether the event object is null or not. If it's not,
do what you're currently doing. If it's null, use the index parameter as the
index into my_images.
Another thing you could do is a bit of refactoring.
Have the click handler only resolve the index and calling another function
to actually load the image.
function clickThumb(e:MouseEvent):void {
loadImage(e.target.name);
}
function loadImage(index:int):void {
if (my_full_images[index] == undefined){
var full_url = my_images[inde...@full;
... etc ...
}
Then, from your other button's handler, call loadImage(image_num + 1);
Cheers
Juan Pablo Califano
2009/5/23 Isaac Alves <[email protected]>
> Hello!
> In my code there's a function that shows an image on the screen (or load
> the
> image and show a progress bar) that is called by clicking on a thumbnail,
> and uses a parameter [e.target.name] refering to the property "name" of
> the
> thumbnail clicked, which is an integer. The thumbnails are placed inside
> the
> cointaner_mc MovieClip.
>
> container_mc.addEventListener(MouseEvent.CLICK, clickThumb);
>
> function clickThumb(e:MouseEvent):void{
> if (my_full_images[e.target.name] == undefined){
> var full_url = my_images[e.target.nam...@full;
>
> etc...
>
> but I want to call this function by clicking on a button, which would need
> to pass another type of parameter, in this case, a variable which refers to
> the number of the image displayed on the screen plus one.
>
> I tried this:
>
> clickThumb(image_num + 1)
>
> But it doesn't work, I get the following error:
>
> 1067: Implicit coercion of a value of type Number to an unrelated type
> flash.events:MouseEvent.
>
> How could I call the function clickThumb and make it use "image_num + 1"
> instead of "e.target.name" ?
>
> Could I dispatch the event (MouseEvent.CLICK, clickThumb), passing this
> value "image_num + 1" ?
>
> Thanks in advance !!
> Isaac
> _______________________________________________
> Flashcoders mailing list
> [email protected]
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders