Hi Guys!
My name is Rick, i want to create a picture gallery using as datasource a
xml file, until now i can load each image from xml reading its path, i
create a movieclip instance and load inside the jpg file, but now i want to
create an onPress event for each picture to send popup using javascript,
i've tried with several ways but i can't make it works, just one image can
handle the onPress event, how can i create at runtime onPress events for
each of my images?
this is my code
function CargaXML(RUTA) {
// Create a new XML object.
var flooring:XML = new XML();
// Set the ignoreWhite property to true (default value is false).
flooring.ignoreWhite = true;
// After loading is complete, trace the XML object.
flooring.onLoad = function(success) {
if (flooring.firstChild.hasChildNodes()) {
var X = 0, Y = 20;
var algo,nombre,nombre2;
for (var i = 0; i<flooring.firstChild.childNodes.length; i++) {
nombre = "mc"+i; //name of new movieclip
var nextDepth = _root.spMain.spContentHolder.getNextHighestDepth();
_root.spMain.spContentHolder.attachMovie("mcImg", nombre, nextDepth,
{_x:X, _y:Y}); //mcImg is a movieclip in my library, so i create new
instance for each xml node
CARGARIMG(flooring.firstChild.childNodes[i].childNodes[0].firstChild.nodeVa lue,
flooring.firstChild.childNodes[i].childNodes[1].firstChild.nodeValue,
nombre, i, Y); // pas some
Y += 150;
}
//for
}
//if
_root.spMain.vScrollPolicy = "on";
};
//function
// Load the XML into the flooring object.
flooring.load(RUTA); //RUTA has the xml path
}
function CARGARIMG(Nombre, whichImage, mc, i, Y) {
if (Nombre != "Ninguna") {
loadMovie(whichImage, mc); //here i load the jpg image
// then i create a text field for an image title
var texto = "texto"+i;
createTextField(texto, getNextHighestDepth(), 0, Y+100, 300, 30);
eval(texto).multiline = true;
eval(texto).text = Nombre;
eval(texto).autoSize = "center";
mc.onPress(){trace(Nombre);} // mc has the new movieclip instance, i also
tried with eval(mc).onPress(){trace(Nombre);} but nothing works, just the
last image has attached the event =(
}
PS: im using Flash 8
Regards
Rick
flooring.onLoad = function(success) {
if (flooring.firstChild.hasChildNodes()) {
you can just do
flooring.onLoad = function(success) {
if (success) {
you'll need to create a button on top of your image. This for me is most
easily done with a predefined custom class, and on the instantiation of your
image(movieclip) you can define the button actions contained in the movie clip.
make sense?
HmcH
-----------------------------------------------Reply-----------------------------------------------
okidoi Mr Helpy!
let me try with this
just one more question, the button should be created at runtime or inside my
movieclip?
Regards
Rick
"Mr Helpy mcHelpson" <webforumsu@macromedia.com> escribi en el mensaje
news:f46tjk$lg1$1@forums.macromedia.com...
> flooring.onLoad = function(success) {
> if (flooring.firstChild.hasChildNodes()) {
> you can just do
> flooring.onLoad = function(success) {
> if (success) {
> you'll need to create a button on top of your image. This for me is most
> easily done with a predefined custom class, and on the instantiation of
> your
> image(movieclip) you can define the button actions contained in the movie
> clip.
> make sense?
> HmcH
thats up to personal preference, make sure you assign the actions to the button AFTER the button is created (procedurally).
-----------------------------------------------Reply-----------------------------------------------
okidoki!!
Thanks a lot!!
"Mr Helpy mcHelpson" <webforumsu@macromedia.com> escribi en el mensaje
news:f46vs6$ob0$1@forums.macromedia.com...
> thats up to personal preference, make sure you assign the actions to the
> button AFTER the button is created (procedurally).