PDA

View Full Version : dynamic movie clips and attaching AS


dke01
04-26-2004, 04:22 AM
Hi,

I open an XML file to get a list of images, which I then populate a comboBox, once the user makes a selection I load the seleteced image/jpg from the file system onto the screen. However once loaded I need to be able to add action script to that image so i can drag it, unload it, etc.

What is the best / easiest way to achive this?
can I load the image into a movieclip that contains a button?

I know the user will only select a maximum of 5 images/jpgs to load.

p.s I'm a newbie
TIA
Dave

vosgien
04-26-2004, 05:35 AM
Hi,
If you are working in MX, you can load the jpg anto an mc that is a button, using this code:

mcname.onRelease = function()
{
//code here
};

If you are working in F5, you can put an invisible button in an mc.

Cheers
Vosgien

dke01
04-26-2004, 07:16 PM
Thanks for your help but I'm still alittle lost
I am using MX

1) How do I make a mc that is a button?
2) Where do I place the "mcname.onRelease = function()"

here is what I have so far am I even loading the image correctly?
Where loadSelectedImage() is my clickHandeler for my comboBox

function loadSelectedImage()
{
trace(_level0.myCombo.getValue());

// if this is the first time through the movie:
if (!picLoaded) {
this.createEmptyMovieClip("pic1a", 1);
//pic1.attachMovie( "pic1", "pic1a", 2 );
pic1a.loadMovie( _level0.myCombo.getValue(), drop1 );

pic1a._x = 139;
pic1a._y = 140;

pic1a.onRelease = function()
{
trace("fgggggg");
};


// tell movie the picture has been loaded
picLoaded = true;

// pic1.loadjpg(_level0.myCombo.getValue());
} else {
pic1._visible = true;
}

}

vosgien
04-27-2004, 04:20 AM
Hi,
I misunderstood your original post, so just to clarify, you have a comboBox on stage with images ( presumably thumbnails ? ), a user clicks a thumbnail and you want to load a larger image into pic1a - right ?
Sorry to say that I know nothing about comboBoxes as I do not work with flash components at all, however :

function loadSelectedImage()
{
this.createEmptyMovieClip("pic1a", 1);
pic1a.loadMovie( _level0.myCombo.getValue(), drop1,{_x:139,_y:140});
}
//your button code comes outside of the load function
pic1a.onRelease = function()
{
trace(this._name)
}


I don't understand _level0.myCombo.getValue() presumably this is set once a user clicks on a thumbnail, tho' there is no reference to a jpg here at all, and what is drop1
Once you have the picture loading we can then play around with loaded = true and setting the visibility
Try the above and let me know how it goes

Vosgien

dke01
04-27-2004, 08:35 AM
Thanks you for your help I now understand how to call code for dynamic mc's

But I already figured how to achive what I wanted, by creating blank image holders to place the thumbnails into, then I just can call the AS i have already coded in them. I attached the flash file and xml file.

Dave