Jump to content
Search Community

AS3_Learning_Curve

Members
  • Posts

    5
  • Joined

  • Last visited

Everything posted by AS3_Learning_Curve

  1. Carl, I thank you for your time and efforts in making it clearer to me many thanks. If I wished to have the following in the xml Earth 1 Star1 150 Could you please let me know the correct way to call group 1 star span figure. Would it be trace(planetsXML..group1.item[0].span); Thanks.
  2. I'm just testing out loadermax and I can get images loading no problem at all. I wish to load some nodes from an xml file into memory and assign the values of the xml file into variables. This is what I have so far. //create a LoaderMax named "mainQueue" and set up onProgress, onComplete and onError listeners var queue:LoaderMax = new LoaderMax({name:"mainQueue", onProgress:progressHandler, onComplete:completeHandler, onError:errorHandler}); //append several loaders queue.append( new XMLLoader("planets.xml", {name:"xmlDoc", noCache:1}) ); //start loading queue.load(); function progressHandler(event:LoaderEvent):void { trace("progress: " + event.target.progress); } function completeHandler(event:LoaderEvent):void { trace(event.target + " is complete!"); } I can get the xml file to load and the progress handler says it has loaded fine. Now here comes the million dollar question. Home do I then load the access the loaded xml file to put a node into a variable. Lets say for instance that I wish to put the node 250.0 into avariable distance. Sorry to ask such fundamental question but this would allow a me to continue with my project. As you can guess I wish to populate some variables with distances of planets etc. A simple example would be great with how to access the node within the xml and trace out the value. Any input would be great. Thanks people. This is a sample of my xml file named planets.xml <?xml version="1.0" encoding="UTF-8" ?> Test Xtml Mars 250.0 Miles Many thanks.
  3. Sorry to be so vague Carl. The technical side of things is getting in the way of my art for the project. Greensock though is a god send, what a product. I tried the no cache and indeed now the image refreshes whoppee. Basically the work is for a school, I wish to have several buttons along the bottom of the screen. Each that will load up a different image from around the world. The images are web cam that the addresses don't change and the file names stay the same. It is a matter of clicking a button and the image appears. I would love it to be work like this. If the user clicks one of the buttons then the appropriate image loads and refreshes. If however the image is loaded and left running then after 5 minutes the image is automatically refreshed anyway. This way if the children leave it alone then the image will be current all day. I'm sure doing this will take me days and if someone has some similar code that I could cobble together then please do speak up it would make y life a lot easier at this point in time . To add more complexity I wish to have an image appear if for some reason the image not exits. Also is there a way to monitor if a file does not load for individual files? Say if an italian web cam fails I can put up an italian flag, german fails german flag etc? I'm sure once I have this loading principle cracked then I can apply it to any asset loading into a project. It's a lot of question and I would appreciate the help. Many thanks Ade Code I used so far loading a single image. It does however now refresh using the noCache:1 as instructed. -- Frame 1 import com.greensock.*; import com.greensock.loading.*; import com.greensock.events.LoaderEvent; import com.greensock.loading.display.*; //create a LoaderMax named "mainQueue" and set up onProgress, onComplete and onError listeners var queue:LoaderMax = new LoaderMax({name:"mainQueue", onProgress:progressHandler, onComplete:completeHandler, onError:errorHandler}); //append several loaders //queue.append( new XMLLoader("xml/data.xml", {name:"xmlDoc"}) ); queue.append( new ImageLoader("http://www.campaniameteo.it/webcam/mercogliano/current.jpg", {name:"photo1", estimatedBytes:2400, container:this, alpha:0, noCache:1, width:640, height:480, scaleMode:"proportionalInside"}) ); //queue.append( new SWFLoader("swf/child.swf", {name:"childClip", estimatedBytes:3000, container:this, x:250, autoPlay:false}) ); //queue.append( new MP3Loader("mp3/audio.mp3", {name:"audio", repeat:2, autoPlay:true}) ); //prioritize the loader named "photo1" LoaderMax.prioritize("photo1"); //same as LoaderMax.getLoader("photo1").prioritize(); //start loading queue.load(); function progressHandler(event:LoaderEvent):void { trace("progress: " + event.target.progress); } var image:ContentDisplay = LoaderMax.getContent("photo1"); function completeHandler(event:LoaderEvent):void { TweenLite.to(image, 1, {alpha:1, y:0}); trace(event.target + " is complete!"); } function errorHandler(event:LoaderEvent):void { trace("error occured with " + event.target + ": " + event.text); } Frame 30 //PAUSE TIMER TO GO BEHIND VISUAL TIMER stop(); trace("paused"); var millis_NATURECAM3:Number=30000; var Tim_NATURECAM3:Timer = new Timer(millis_NATURECAM3, 1); Tim_NATURECAM3.addEventListener(TimerEvent.TIMER, playit_NATURECAM3); function playit_NATURECAM3(e:TimerEvent):void { play(); } Tim_NATURECAM3.start(); //Timer End trace("play"); Frame 35 LoaderMax.getContent("photo1").loader.unload(); Frame 40 gotoAndPlay(1);
  4. Carl, I wondered if you have any ideas here to my scenario. I have a web cam image running it timers for 5 minutes and then restarts then timeline and loadermax. I use the LoaderMax.getLoader("photo1").unload(); to unload the image. It appears however that the image doesn't change until I shut down flash and then restart the web cam swf? Is there something I must do in order to flush out the image and have loadermax re-initialise / load the image again?. Also is there a way of telling if an item fails to load what that item is ?. I wish to have a list page upon starting the swf that lists all the external swf to be loaded. If it fails I wish to display say a cross to let the user know that something is wrong and the file does not exist or has something wrong with it. Is this possible? Regards Ade
  5. Hey there people, Please help a complete as3 learner here in figuring out the basics. I have used the example code import com.greensock.*; import com.greensock.loading.*; import com.greensock.events.LoaderEvent; import com.greensock.loading.display.*; //STAGE ALIGNMENT AND POSITIONING FUNCTION stage.align = StageAlign.TOP_LEFT; stage.scaleMode = StageScaleMode.NO_SCALE; stage.dispatchEvent(new Event(Event.RESIZE)); //create a LoaderMax named "mainQueue" and set up onProgress, onComplete and onError listeners var queue:LoaderMax = new LoaderMax({name:"mainQueue", onProgress:progressHandler, onComplete:completeHandler, onError:errorHandler}); //append several loaders //queue.append( new XMLLoader("xml/data.xml", {name:"xmlDoc"}) ); //queue.append( new ImageLoader("img/photo1.jpg", {name:"photo1", estimatedBytes:2400, container:this, alpha:0, width:250, height:150, scaleMode:"proportionalInside"}) ); queue.append( new SWFLoader("test.swf", {name:"childClip", estimatedBytes:3000, container:this, x:250, autoPlay:false}) ); queue.append( new SWFLoader("test2.swf", {name:"childClip2", estimatedBytes:3000, container:this, x:250, autoPlay:false}) ); //queue.append( new MP3Loader("mp3/audio.mp3", {name:"audio", repeat:2, autoPlay:true}) ); //prioritize the loader named "photo1" //LoaderMax.prioritize("photo1"); //same as LoaderMax.getLoader("photo1").prioritize(); //start loading queue.load(); function progressHandler(event:LoaderEvent):void { trace("progress: " + event.target.progress); } function completeHandler(event:LoaderEvent):void { var image_mc:ContentDisplay = LoaderMax.getContent("childClip2"); // PLACE IT ON STAGE image_mc.x = 0; image_mc.y = 100; addChild(image_mc); trace(event.target + " is complete!"); } function errorHandler(event:LoaderEvent):void { trace("error occured with " + event.target + ": " + event.text); } My project is timeline based. I can get the external swf files loaded and even add a child to the stage (as above). Then is I wish to add and remove children from the loaded files elsewhere on the timeline. How would I go about adding a new child and removing one. I come more from an art background so this is very confusing indeed. I tried addChild(image_mc); removeChild(image_mc); but it gives me "Access to undefined property image_mc" Basically I would love to have a list of external swf files that load at the beginning of the fla. These could then be added and removed as I wish throughout my project. If this is not the best way to achieve this then please let me know. Also is there a way of telling if a specific swf has failed to load?. This way I may be able to replace the failed swf with an alternative graphic. Sorry for the bundle of question but I have a project working in the old way. I just thought that using loadermax could centralise some of the process. Any ideas? Regards Ade
×
×
  • Create New...