Učitavanje txt u swf na webu

Pozdrav svima.
Imam sledeci problem, napravila sam test u flasu koji uvlači pitanja iz .txt fajla. Sve fiunkcioniše na hardu, ali kada ga publikujem na web ne radi. Odnosno ne mogu da povežem ta dva fajla. Stavila sam i relativnu i apsolutnu putanju do txt, ali opet ne funkcioniše. Šta grešim?
Hvala unapred.

Bez koda koji imaš nitko ti ne može pomoći. Koliko god se svi mi trudili još uvijek nismo ni do koljena vidovitom Milanu. Dakle da bi dobila pomoć pošalji kod koji imaš

Griješiš to što se na računalu korisnika koji će posjetiti tvoju web-stranicu ne nalazi ta datoteka uopće, a posve sigurno ne na tim lokacijama na disku. A čak da je nekim čudom i smjestiš, kada je pokrenut u procesu web-preglednika, Flash ne može slobodno pristupati hard-disku korisnika.

Trebaš na neki način “usaditi” svoja pitanja u Flash kao nekakav resurs (ako Flash to podržava) ili iskoristiti mehanizam koji ti Flash stavlja na raspolaganje za dohvat datoteka s poslužitelja pomoću HTTP protokola (sigurno će te netko uputiti), pri čemu moraš i tu datoteku prikladno smjestiti na web, tamo gdje si stavila HTML stranicu s ugrađenim Flashom.

Ključna riječ za google, za teorijsku podlogu: “client-server architecture”.

1- Dali se radi o ActionScriptu 2 ili AS3
2- Preporuka je koristit XML a ne TXT fajlove za import/export u SWF
3- 99% si URLrequest krivo napisao…

… iako najjednostavnije bi bilo da napises ovdje dio koda koji vadi text iz txt fajla, pa cemo ti moci pomoci :stuck_out_tongue:

Pozz

@Edit:
Evo ti jedan primjer ucitavanja vanjskog XMLa koji onda ucitava slike i text i razlicitih foldera sa servera, to je dio koda jedne galerije sto sam nedavno radio kolegi :cp:

Ovo je bitno:

[quote=""]public function startLoad():void
{
this.visible = true;
//Load in XML
[color="#FF0000"]var xmlAlbum:XMLLoader = new XMLLoader(“http://www.webmajstori.net/forum/images/Slideshow1/album.xml”);
xmlAlbum.addEventListener(LoaderEvent.COMPLETE, XMLLoaded);
xmlAlbum.load();
[/color]
}[/quote]

Evo čitave klase:

package com 
{
	import com.greensock.events.LoaderEvent;
	import com.greensock.loading.data.ImageLoaderVars;
	import com.greensock.loading.display.ContentDisplay;
	import com.greensock.loading.ImageLoader;
	import com.greensock.loading.LoaderMax;
	import com.greensock.loading.XMLLoader;
	import com.greensock.easing.*;
	import com.greensock.plugins.*;
	import com.greensock.TweenLite;
	import flash.display.DisplayObject;
	import flash.display.MovieClip;
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	import flash.media.*;
	
	public class SlideShow1 extends MovieClip
	{
		TweenPlugin.activate([GlowFilterPlugin, ColorTransformPlugin]);
		
		var myChannel2:SoundChannel = new SoundChannel();
		var mySound2:ButtonSound = new ButtonSound();
		var buttonTransform2 = new SoundTransform(0.5);
		
		private var xImgList:XMLList;
		public var thumbHolder_mc:ThumbHolder;
		public var mainHolder_mc:MainHolder;
		public var photoPreloader_mc:PhotoPreloader;
		public var slideshowBackButton_mc:SlideShowBack;
		
		var myChannel:SoundChannel = new SoundChannel();
		var mySound:CannonClick = new CannonClick();
		var buttonTransform = new SoundTransform(0.3);
		
		public function SlideShow1() 
		{
			this.x = 0;
			this.y = 0;
			this.visible = false;
			this.photoPreloader_mc.visible = false;
			thumbHolder_mc.cacheAsBitmap = true;
		}
		
		public function startLoad():void
		{
			this.visible = true;
			//Load in XML
			var xmlAlbum:XMLLoader = new XMLLoader("http://www.webmajstori.net/forum/images/Slideshow1/album.xml");
			xmlAlbum.addEventListener(LoaderEvent.COMPLETE, XMLLoaded);
			xmlAlbum.load();
		}
		
		private function XMLLoaded(e:LoaderEvent):void 
		{
			var xData:XML = e.target.content;
			xImgList = new XMLList(xData.img);
			
			//Setup a loadermax object
			var thumbLoader:LoaderMax = new LoaderMax ( { name:"thumbLoader" } );
			thumbLoader.addEventListener(LoaderEvent.COMPLETE, thumbsLoaded);
			
			//Setup variables for our ImageLoaderVars
			var nImgWidth:Number = 300;
			var nImgHeight:Number = 200;
			
			for (var i:int = 0; i < xImgList.length(); i++) 
			{
				//Dodaj dummy loadere za thumbs
				var dummy:DisplayObject = new DummyLoader();
				this.thumbHolder_mc.addChild(dummy);
				TweenLite.to(dummy, 0, {alpha:0.5} );
				dummy.x = 150+(i  * 300)+(i*5);
				dummy.y = 100;
				
				var iLoad:ImageLoader = new ImageLoader("http://www.webmajstori.net/forum/images/Slideshow1/thumbs/" + xImgList[i].@url, new ImageLoaderVars()
					.name(xImgList[i].@name)
					.width(nImgWidth)
					.height(nImgHeight)
					.smoothing(true)
					.container(thumbHolder_mc)
					.x(i * nImgWidth + i * 5)
					.scaleMode("proportionalOutside")
					.crop(true)
					.prop("index", i)
					.prop("url", xImgList[i].@url)
					.prop("title", xImgList[i].@title)
					.prop("desc", xImgList[i].@desc)
					.alpha(0)
					//.centerRegistration(true)
					)
				thumbLoader.append(iLoad);
				
			}
			thumbLoader.load();
			this.thumbHolder_mc.scrollSpeed = xImgList.length()/2.5;
		}
		
		private function thumbsLoaded(e:LoaderEvent):void 
		{
			//Setup click events for our thumbnails
			for (var i:int = 0; i < xImgList.length(); i++) 
			{
				var cdImg:ContentDisplay = LoaderMax.getContent("p" + (i + 1));
				TweenLite.to(cdImg, 1, {alpha:1, delay:(i * 0.2)} );
				cdImg.buttonMode = true;
				cdImg.addEventListener(MouseEvent.CLICK, thumbClick);
				cdImg.addEventListener(MouseEvent.ROLL_OVER, thumbOver);
				cdImg.addEventListener(MouseEvent.ROLL_OUT, thumbOut);
			}
		}
		
		private function thumbOver(e:MouseEvent):void 
		{
			myChannel2 = mySound2.play(0,0,buttonTransform2);
			TweenLite.to(e.currentTarget, 0.5, {glowFilter:{color:0xffffff, alpha:1, blurX:4, blurY:4, strength:5, quality:1} } );
		}
		
		private function thumbOut(e:MouseEvent):void 
		{
			TweenLite.to(e.currentTarget, 1, {alpha:1, glowFilter:{color:0xffffff, alpha:0, blurX:4, blurY:4, strength:5, quality:1} } );
		}
		
		private function thumbClick(e:MouseEvent):void 
		{
			var vars:Object = ImageLoader(e.currentTarget.loader).vars;
			checkOldImage(vars.index)
		}
		
		private function checkOldImage(index:Number):void 
		{
			//Check if there is already an image loaded
			if (mainHolder_mc.numChildren > 0) 
			{
				var oldClip:Sprite = Sprite(mainHolder_mc.getChildAt(0));
				TweenLite.to(oldClip, 0.5, { alpha:0, onComplete:function() { mainHolder_mc.removeChildAt(0); loadImage(index) } } )
			}else
			{
				loadImage(index);
			}
		}
		
		private function loadImage(index:Number):void 
		{
			//Postavi PhotoLoader
			photoPreloader_mc.visible = true;
			photoPreloader_mc.mainPreloaderBar_mc.width = 0;
			photoPreloader_mc.alpha = 1;
			photoPreloader_mc.x = (stage.stageWidth / 2) - 110;
			photoPreloader_mc.y = (stage.stageHeight / 2) - 140
			
			//Makni Back button
			slideshowBackButton_mc.visible = false;
			
			//Get filename
			var file:String = xImgList[index].@url;
			
			//Setup our main Image loader
			var mainLoad:ImageLoader = new ImageLoader("http://www.webmajstori.net/forum/images/Slideshow1/main/" + file, new ImageLoaderVars()
				.width(stage.stageWidth)
				.height(stage.stageHeight)
				.x(0)
				.y(200)
				.scaleMode("proportionalInside")
				.container(mainHolder_mc)
				.smoothing(true)
				.alpha(0)
				.bgColor(0x000000)
				.centerRegistration(true)
				)
				
			//Setup Event Listeners
			mainLoad.addEventListener(LoaderEvent.PROGRESS, imageProggres);
			mainLoad.addEventListener(LoaderEvent.COMPLETE, imageLoaded);
			mainLoad.load();
		}
		
		private function imageProggres(e:LoaderEvent):void 
		{
			photoPreloader_mc.mainPreloaderBar_mc.scaleX = e.target.progress;
			photoPreloader_mc.postotak_txt.text = Math.round(e.target.progress * 100) + "%";
		}
		
		private function imageLoaded(e:LoaderEvent):void 
		{
			//Makni PhotoLoader
			TweenLite.to(photoPreloader_mc, 0.3, {alpha:0, y:(photoPreloader_mc.y + 100), onComplete:function() { photoPreloader_mc.visible = false }} );
			
			var imgClip:ContentDisplay = LoaderMax.getContent(e.currentTarget.name);
			TweenLite.to(imgClip, 0, {colorTransform: { exposure:2 }} );
			TweenLite.to(imgClip, 0.5, { y:0, colorTransform: { exposure:1 }, alpha:1, ease:Cubic.easeOut } );
			myChannel = mySound.play(0,0,buttonTransform);
			imgClip.buttonMode = true;
			imgClip.addEventListener(MouseEvent.CLICK, thumbClipClick);
		}
		
		private function thumbClipClick(e:MouseEvent):void 
		{
			//Postavi Back button
			slideshowBackButton_mc.visible = true;
			
			var oldClip:Sprite = Sprite(mainHolder_mc.getChildAt(0));
			TweenLite.to(oldClip, 0.5, { alpha:0, onComplete:function() { mainHolder_mc.removeChildAt(0); } } )
		}
	}
}

Copyright © 2020 WM Forum - AboutContact - Sponsored by: Mydataknox & Webmaster.Ninja