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

flash actionscript

group:

asfunction + prototype , please assist


asfunction + prototype , please assist Mabel Lynx
4/10/2004 6:18:45 PM
flash actionscript: Hello Group

Could you please assist me in combining Asfunction with MovieClip.prototype ?

I have simple prototype for loading external content .
Try to recycle my preloader because i have lots of content to load .
SWF and JPG files.

I get it all working very well but than I wanted to add asfunction
to call that prototype so I could also load stuff from click in dynamically
loaded
text .

I manage to get the Asfunction working but I can't manage to use the
Asfunction to
call the prototype and pass parameters to it .

The prototype :

MovieClip.prototype.preloadJPG = function(jpg, trgt, clr) {
_global.preloaderCount ++;

this.createEmptyMovieClip("preldr" + _global.preloaderCount, 100 +
_global.preloaderCount);
var mc = this["preldr" + _global.preloaderCount];

mc.createTextField("statusText" + _global.preloaderCount, 100, trgt._x,
trgt._y, 150, 40);
var tf = mc["statusText" + _global.preloaderCount];

tf.type = "dynamic";
tf.selectable = false;
tf.textColor = clr;
style = new TextFormat();
style.font = "Verdana";
style.size = 11;
tf.setNewTextFormat(style);

trgt.loadMovie(jpg);

mc.onEnterFrame = function() {
this.prcnt = Math.floor((trgt.getBytesLoaded()/trgt.getBytesTotal())*100);
if(!isNan(this.prcnt) && trgt.getBytesTotal() > 50){
tf.text = this.prcnt+"% loaded";
this.clear();
with (this) {
lineStyle(.25, clr, 100);
moveTo(trgt._x - 3,trgt._y + 17);
lineTo(trgt._x + 102, trgt._y + 17);
lineTo(trgt._x + 102, trgt._y + 33);
lineTo(trgt._x - 3, trgt._y + 33);
lineTo(trgt._x - 3, trgt._y + 17);
endFill();
}
with (this) {
beginFill(clr, this.prcnt);
lineStyle(.25, clr, this.prcnt);
moveTo(trgt._x,trgt._y + 20);
lineTo(trgt._x + prcnt, trgt._y + 20);
lineTo(trgt._x + prcnt, trgt._y + 30);
lineTo(trgt._x, trgt._y + 30);
lineTo(trgt._x, trgt._y + 20);
endFill();
}
}else{
tf.text = "0% loaded";
}
if(this.prcnt == 100 && trgt.getBytesTotal() > 50){
mc.removeMovieClip();
delete this.onEnterFrame;
}
}
}


Usage :

preloadJPG("FAQ_01.jpg", holderMC, 0xFFcc00);


The Asfunction :

function preloadJPG(qString) {
var params = new Array();
params = qString.split(",");
trace(params[0]);
trace(params[1]);
trace(params[2]);
}


asfunction:preloadJPG,FAQ_01.jpg,holderMC2,0xFFccFF


Could you please advice , how do I combine these two to be able to use
buttons in flash movie and dynamically loaded text links ?


thank you
best

Mabel
Re: asfunction + prototype , please assist Jack.
4/10/2004 6:33:49 PM
have you tried -

asfunction:splitParams,FAQ_01.jpg,holderMC2,0xFFccFF

function splitParams(qString) {
var params = new Array();
params = qString.split(",");
trace(params[0]);
trace(params[1]);
trace(params[2]);
preloadJPG( params[0], params[1], params[2] );
}

hth
Re: asfunction + prototype , please assist Mabel Lynx
4/10/2004 7:01:09 PM
Thank you Jack
It trace out correctly but it does not load . When try with button , the same instance loads fine . I'm not sure why .

natalia
Re: asfunction + prototype , please assist Mabel Lynx
4/10/2004 7:07:15 PM
how to change the profile in here ?
I try Natalia Mable Lynx but it comes is Mabel and I can't find options to change it .

Re: asfunction + prototype , please assist Jack.
4/10/2004 7:25:41 PM
i do not know why the code is failing for you :(
this code works OK in Flash6 -

test.html = true;
test.htmlText =
"<a href='asfunction:splitParams,FAQ_01.jpg,holderMC2,0xFFccFF'>Test</a>"

function splitParams(qString) {
var params = new Array();
params = qString.split(",");
trace(params[0]);
trace(params[1]);
trace(params[2]);
preloadJPG( params[0], params[1], params[2] );
}

function preloadJPG(a,b,c){
trace(a+" | "+b+" | "+c);
};
Re: asfunction + prototype , please assist urami_
4/12/2004 10:03:54 AM


[quoted text, click to view]


Hi there Jack

You will need to eval your movie clip when call from asfunction because the preloadJPG require a
movie clip reference , not a string.

While using eval("HolderMC2")it will return reference to the movie clip HolderMc2 if the mc exists.

preloadJPG (params[0], eval(params[1]), params[2]);



--

Regards


urami_*



<no>
http://flashfugitive.com/
</no>

Re: asfunction + prototype , please assist Jack.
4/12/2004 12:26:05 PM
[quoted text, click to view]

Thanks again urami ;)
another method would be to reference the movieclip within the function,

MovieClip.prototype.preloadJPG = function(jpg, trgt, clr) {
ref = this[trgt];
ref.loadMovie(jpg);
}
Re: asfunction + prototype , please assist urami_
4/13/2004 2:14:37 AM


[quoted text, click to view]

there you go , great , good thing in flash - many ways to one goal.



--

Regards


urami_*



<no>
http://flashfugitive.com/
</no>

AddThis Social Bookmark Button