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
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
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
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 .
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); };
[quoted text, click to view] > 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); > }; >
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>
[quoted text, click to view] >preloadJPG (params[0], eval(params[1]), params[2]);
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); }
[quoted text, click to view] Jack. wrote: >>preloadJPG (params[0], eval(params[1]), params[2]); > > > 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); > }
there you go , great , good thing in flash - many ways to one goal. -- Regards urami_* <no> http://flashfugitive.com/ </no>
Don't see what you're looking for? Try a search.
|