all groups > flash actionscript > march 2004 >
You're in the

flash actionscript

group:

Passing a mc instance name to function dynamically



Passing a mc instance name to function dynamically quadrant6
3/8/2004 11:32:40 PM
flash actionscript: I have 3 mc's on the stage called 'frame1', 'frame2', and
'frame3'.

I'm trying to pass the mc instance name to a function dynamically:

The variable 'file' is a number (1,2 or 3)

function checkFile(file){
...lots of code here..

loadPreview("frame"+file);
}


// load image
function loadPreview(frame){
trace(frame); (### ths traces frame+number i.e 'frame3' correctly so the
following should load to frame3 on the stage but doesn't?)

frame.createEmptyMovieClip("pic_mc", 2);
frame.pic_mc.loadMovie(filepath);
frame.onEnterFrame = function(){
frame._width = 138;
frame._height = 112;
}
}


Re: Passing a mc instance name to function dynamically Jack.
3/8/2004 11:38:43 PM
try -
loadPreview(this["frame"+file]);

function loadPreview(frame){
trace(frame); // output should be _level0.frame1
};
Re: Passing a mc instance name to function dynamically KnowMind
3/9/2004 2:52:22 PM
Try this...

theName="frame"+file;
theName=theName.toString() ;

loadPreview(theName);
}

--KM

[quoted text, click to view]

AddThis Social Bookmark Button