Share Posted March 19, 2011 Hi, I want to do with Loader Max a percentage of field, but get the error: This is my code without percentage of field, that function well: package Max_SWF { import com.greensock.loading.LoaderMax; import com.greensock.events.LoaderEvent; import com.greensock.loading.SWFLoader; import flash.display.MovieClip; public class LoaderMaxSWF extends MovieClip { public function LoaderMaxSWF() { var queue:LoaderMax=new LoaderMax({onProgress:progressHandler}); queue.append(new SWFLoader("contatti.swf",{onComplete:completeHandler})); queue.load(); } public function completeHandler(event:LoaderEvent):void { addChild(event.target.content); } public function progressHandler(event:LoaderEvent):void { myProgressBar.scaleX=event.target.progress; } } } Here the code with percentage of field creating error: package Max_SWF { import com.greensock.loading.LoaderMax; import com.greensock.events.LoaderEvent; import com.greensock.loading.SWFLoader; import flash.display.MovieClip; public class LoaderMaxSWF extends MovieClip { private var kbps:Number; public function LoaderMaxSWF() { var queue:LoaderMax=new LoaderMax({onProgress:progressHandler}); queue.append(new SWFLoader("contatti.swf",{onComplete:completeHandler})); queue.load(); } public function completeHandler(event:LoaderEvent):void { addChild(event.target.content); } public function progressHandler(event:LoaderEvent):void { kbps+=(event.bytesLoaded / event.loadTime) / 1024; mc_txt.text="loading"+ kbps.ToString()+"%"; myProgressBar.scaleX=event.target.progress; } } } thanks for your help milcon Link to comment Share on other sites More sharing options...
Share Posted March 20, 2011 G'day mate, What error are you getting? And just quickly glancing over your code, with this line: mc_txt.text="loading"+ kbps.ToString()+"%"; The ToString method should be .toString. ie no capital on the T mc_txt.text="loading"+ kbps.toString()+"%"; But yeah if you can post the error your getting it might help find the problem as well. Cheers -Z Link to comment Share on other sites More sharing options...
Author Share Posted March 21, 2011 thanks for your answer, but my code not function: the error is : 1119: Access of possibly undefined property bytesLoaded through a reference with static type com.greensock.events:LoaderEvent. I have also imported the all package: import com.greensock.loading.*; and I did as you told me... kbps+=Number=(event.bytesLoaded/event.loadTime)/1024; mc_txt.text="loading"+kbps.toString()+"%"; Link to comment Share on other sites More sharing options...
Share Posted March 21, 2011 try event.target.bytesLoaded Link to comment Share on other sites More sharing options...
Author Share Posted March 22, 2011 I have resolved.. thanks Carl.. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now