Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 12-14-2004, 06:40 PM   #1
bluetrane
Registered User
 
Join Date: Dec 2004
Posts: 4
Unhappy Event Handler Problem on Nested MC

I'm using the following code to dynamcially create movieclips inside another movieclip called "picStrip" from an array of JPGs:

for (var i = 0; i<imageArray.length; i++) {
var thisImage:String = "image"+i;
picStrip.createEmptyMovieClip(thisImage, picStrip.getNextHighestDepth());
eval("picStrip."+thisImage).loadMovie(imageArray[i]);
eval("picStrip."+thisImage)._x = (101*i);
eval("picStrip."+thisImage)._y = 0;
}

For some reason, I am unable to access the event handler functionality of the dynamically generated MCs:

_root.picStrip.image1.onRelease = function() {
trace("Did this work?");
}

I know my MCs exist, because I can manipulate their properties:

_root.picStrip.image1._alpha=25;


picStrip does not have any event handling on it, so that is not the issue. What am I doing wrong here? Surely there is a way to do this...

Many thanks to anyone can help!
bluetrane is offline   Reply With Quote
Old 12-14-2004, 07:21 PM   #2
Xeef
Off-Line
 
Xeef's Avatar
 
Join Date: Aug 2004
Location: Ibiza/Spain language :Hungarian/German/ abit English
Posts: 6,539
Default

hi

Hmmmm

if you load somthing in a MC all is't EVEN'T are overwriten by the loaded image
so you have to asign them after the load is COMPLETED !!!
__________________

test your self -->http://www.actionscript.org/forums/s...86&postcount=8
Xeef is offline   Reply With Quote
Old 12-14-2004, 08:04 PM   #3
bluetrane
Registered User
 
Join Date: Dec 2004
Posts: 4
Default

Xeef... thanks for trying to help. Can you be a bit more specific please? Here is my code. How would I modify it to insure that the image movieclips have all loaded? I am able to manipulate properties for the loaded MCs. Wouldn't that mean that they have loaded successfully?

//load images
var imageArray:Array = new Array();
imageArray[0] = "uploads/100012_people/100000.jpg";
imageArray[1] = "uploads/100012_people/100001.jpg";
imageArray[2] = "uploads/100012_people/100002.jpg";
imageArray[3] = "uploads/100012_people/100003.jpg";

//create clips dynamically for images
for (var i = 0; i<imageArray.length; i++) {
var thisImage:String = "image"+i;
picStrip.createEmptyMovieClip(thisImage, picStrip.getNextHighestDepth());
eval("picStrip."+thisImage).loadMovie(imageArray[i]);
eval("picStrip."+thisImage)._x = (100*i);
eval("picStrip."+thisImage)._y = 0;
}
// Click on dynamically loaded JPG movieclip...
_root.picStrip.image1.onRelease = function() {
trace("Do something here...");
};
bluetrane is offline   Reply With Quote
Old 12-14-2004, 09:02 PM   #4
Xeef
Off-Line
 
Xeef's Avatar
 
Join Date: Aug 2004
Location: Ibiza/Spain language :Hungarian/German/ abit English
Posts: 6,539
Default

PHP Code:
_root.createEmptyMovieClip("test1"1);
test1.onEnterFrame = function() {
    
trace("i am runing :) but i will by overwriten !!!");
};
//this will overwrite the onEnterFrame !!!
test1.loadMovie("http://www.macromedia.com/images/shared/product_boxes/112x112/box_studio_112x112.jpg");
/////////////////////////////////
_root.createEmptyMovieClip("test2"2);
var 
mclListener:Object = new Object();
mclListener.onLoadComplete = function(target_mc:MovieClip) {
    
// at this point the load is complited now you can give functions to it
    
target_mc.onEnterFrame = function() {
        
trace("i am runing :) ");
    };
    
// if you need DIFERENT functions on each loaded clip -->
    // either you use for each image it's own MovieClipLoader or you need complex logic 
    // which function to asign
};
var 
image_mcl:MovieClipLoader = new MovieClipLoader();
image_mcl.addListener(mclListener);
image_mcl.loadClip("http://www.macromedia.com/images/shared/product_boxes/112x112/box_studio_112x112.jpg"test2);
/////////////////
//Hmmmm some example on this 
//Will NOT work on dipher level eg. _root.Holder.My_mc in this case you woud need 
//other logic !!!
/////////////////
_root.createEmptyMovieClip("pic1"3);
_root.createEmptyMovieClip("pic2"4);
_root.createEmptyMovieClip("pic3"5);
var 
mclListener:Object = new Object();
mclListener.onLoadComplete = function(target_mc:MovieClip) {
    
target_mc.onEnterFrame _root[String(target_mc).split(".")[1]];
};
var 
image_mcl:MovieClipLoader = new MovieClipLoader();
image_mcl.addListener(mclListener);
image_mcl.loadClip("http://www.macromedia.com/images/shared/product_boxes/112x112/box_studio_112x112.jpg"pic1);
image_mcl.loadClip("http://www.macromedia.com/images/shared/product_boxes/112x112/box_studio_112x112.jpg"pic2);
image_mcl.loadClip("http://www.macromedia.com/images/shared/product_boxes/112x112/box_studio_112x112.jpg"pic3);
pic1 = function () {
    
trace("Hallo this is a test");
};
pic2 = function () {
    
trace("this is a nother test BY "+this);
};
pic3 = function () {
    
trace("this is a nother test BY "+this+" shoud by PIC3 :) ");
}; 
__________________

test your self -->http://www.actionscript.org/forums/s...86&postcount=8
Xeef 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 01:55 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.