dcsimg
A Flash Developer Resource Site

Page 2 of 2 FirstFirst 12
Results 21 to 39 of 39

Thread: HTML in flash 8

  1. #21
    Member
    Join Date
    Oct 2005
    Posts
    31
    I noticed that this could be a dirty wourkaround for the problem.

    function selectPage(address:String) {
    _root.textHolder.condenseWhite = true;
    var myVars_lv:LoadVars = new LoadVars();
    var styles:TextField.StyleSheet = new TextField.StyleSheet();
    var txt_url:String = address;
    var css_url:String = "text/html_styles.css";
    styles.onLoad = function(success:Boolean):Void {
    if (success) {
    textHolder.styleSheet = styles;
    } else {
    trace("Style not loaded");
    }
    };
    styles.load(css_url);
    myVars_lv.onData = function(src:String):Void {
    if (textHolder.styleSheet = styles) {
    textHolder.htmlText = src;
    } else {
    textHolder.styleSheet = styles;
    textHolder.htmlText = src;
    }
    };
    myVars_lv.load(txt_url);
    }

    just re-aplying the css style if its not loaded until it is. This works fine on my server and home testing. But it could just cause a massive loop if there is an actual problem like the .css file is missing.

  2. #22
    182
    Join Date
    Dec 2005
    Location
    Manchester
    Posts
    60
    Quote Originally Posted by Avigeller
    Actually,,, why not use .html instead of .txt files,, then u could use the following code which i made into a funciton so that u can simply call any html page and run it through...

    eg... selectPage("myPage.html")

    Code:
    function selectPage(address:String) {
    	_root.textHolder.condenseWhite = true;
    	var myVars_lv:LoadVars = new LoadVars();
    	var styles:TextField.StyleSheet = new TextField.StyleSheet();
    	var txt_url:String = address;
    	var css_url:String = "html_styles.css";
    	styles.onLoad = function(success:Boolean):Void  {
    		if (success) {
    			textHolder.styleSheet = styles;
    		} else {
    			//what ever you want,,, either  a trace,, or an action etc...
    		}
    	};
    	styles.load(css_url);
    	myVars_lv.onData = function(src:String):Void  {
    	if (src != undefined) {
    	textHolder.htmlText = src;
    	} else {
    	//what ever you want,,, either  a trace,, or an action etc...
    	}
    	};
    	myVars_lv.load(txt_url);
    }
    Hope that helps
    Hi, Where would i put this code? in the text box actionscript or in the frame actionscript?

    Thanks
    Scott

  3. #23
    Senior Member
    Join Date
    Jan 2003
    Location
    New York/London
    Posts
    367
    because its a function, u cant put it anywhere,,, not sure what u mean by "in the text box actionscript" either way, i suggest u put it in a frame in the main time line,, and make sure that frame presides over the full length of your movie so it can be called from anywhere,,, ie...

    _root.selectPage(mypage.html);

  4. #24
    Senior Member
    Join Date
    Jan 2003
    Location
    New York/London
    Posts
    367
    MagicBez,

    actually I was using a loop idea, but just didnt want to confuse u with it,,,
    Code:
    function selectPage(address:String) {
    	_root.textHolder.condenseWhite = true;
    	var myVars_lv:LoadVars = new LoadVars();
    	var styles:TextField.StyleSheet = new TextField.StyleSheet();
    	var txt_url:String = address;
    	var css_url:String = "html_styles.css";
    	styles.onLoad = function(success:Boolean):Void  {
    		if (success) {
    			textHolder.styleSheet = styles;
    			myVars_lv.onData = function(src:String):Void  {
    				if (src != undefined) {
    					textHolder.htmlText = src;
    				} else {
    					selectPage(address);
    				}
    			};
    			myVars_lv.load(txt_url);
    		} else {
    			//trace("Unable to load CSS file.");
    			selectPage(address);
    		}
    	};
    	styles.load(css_url);
    }

  5. #25
    Member
    Join Date
    Oct 2005
    Posts
    31
    That seems like it should work, are you having issues with this code? It seems like a good solution to the css not loading problem.

    Edit just replaced my edited code with that, and it works fine on my movieon the server
    Last edited by MagicBez; 01-17-2006 at 03:41 PM.

  6. #26
    Senior Member
    Join Date
    Jan 2003
    Location
    New York/London
    Posts
    367
    it works good for me so far, i actually need to study for and while statements, as im sure it could be much cleaner,,,,,, i discovered that SAFARI browser, is not the best browser to test things on I spent days trying to figure out why my moviecliploader was giving me STRESSSSSS... only to see it work perfectly on all other browsers,, how SUCKY,,,

  7. #27
    182
    Join Date
    Dec 2005
    Location
    Manchester
    Posts
    60
    Hey, i know i'm being really dumb here but i just can't understand whats going on here or what to do with it. Is there anyway you could post me a zip file up please with the .fla file and the other fiels needed to have a look at this and properly understand whats going on. Sorry for being so stupid. If you could post that up though it would be amazing.

    Thanks
    Scott

  8. #28
    Member
    Join Date
    Oct 2005
    Posts
    31
    Quote Originally Posted by Avigeller
    it works good for me so far, i actually need to study for and while statements, as im sure it could be much cleaner,,,,,, i discovered that SAFARI browser, is not the best browser to test things on I spent days trying to figure out why my moviecliploader was giving me STRESSSSSS... only to see it work perfectly on all other browsers,, how SUCKY,,,
    Yeah I guess, it probably has something to do with the apple flash player being quite different to the windows one.

    Just a quick aside with the function you wrote, I tried it out quickly with a html form and the form elements like textfields and radio buttons don't show up. The text and css is all loaded but not the form fields. (Just checked and they did show if i just load the .html in safari)

    Obviously I could just make the form in flash rather than html, but i thought i would just try it out in html for fun.

  9. #29
    Senior Member
    Join Date
    Jan 2003
    Location
    New York/London
    Posts
    367
    yeah, html in dynamic text fields in flash is soooooo limited,,, HOWEVER,, u can have a form in an external swf that can be loaded via an html page into the flash ,,,

  10. #30
    Member
    Join Date
    Oct 2005
    Posts
    31
    Sound a bit long and complicated...ill just go with the flash route...seems like it would be easier to position everything nice and neatly too.

    On another aside, I tried out the www.gotoandlearn.com tutorial on skinning v2 components with respect to the scrollbar in my movie using your script. It worked perfectly with every other movie i've tried it on but not this one. Is there some reason why it wouldn't work. The scrollbar doesn't show up, almost as if it doesn't realise that the text has been loaded or something?

    Thanks in advance

  11. #31
    Senior Member
    Join Date
    Jan 2003
    Location
    New York/London
    Posts
    367
    trie to set embed Fonts to false maybe?
    either way,, just make a text box and drag a scrobbar to it instead of using a text area component...

  12. #32
    Member
    Join Date
    Oct 2005
    Posts
    31
    Nothing seemed to work at all on this one, nevermind. I do have one more quick question for you. Is there some way I can set the scrollbar to the top when the new text is loaded. Some code in the function that can be added that just makes scroll=0 or similar?

    Thanks

  13. #33
    Senior Member
    Join Date
    Jan 2003
    Location
    New York/London
    Posts
    367
    actually i read a post somewhere how to do it, but as always i forgot to make note of it, but its something that i would like to do myself,,,, so whoever finds it first,,, tells the other ok ?

  14. #34
    Member
    Join Date
    Oct 2005
    Posts
    31
    Sounds like a good deal!

  15. #35
    Member
    Join Date
    Oct 2005
    Posts
    31
    http://www.flashkit.com/board/showth...omponent+reset ? Seems like it might be the thread?

  16. #36
    Senior Member
    Join Date
    Jan 2003
    Location
    New York/London
    Posts
    367
    scroller.setScrollPosition(); // looks like this may be it,,,

  17. #37
    Member
    Join Date
    Oct 2005
    Posts
    31
    I just used

    textHolder.scroll = 1;

    seems to work fine, don't see why either wouldn't work though.

    Sweet, another little problem done!

  18. #38
    Senior Member
    Join Date
    Jan 2003
    Location
    New York/London
    Posts
    367
    im curious, does your text field show characters like or when loaded from an external html?

  19. #39
    Registered User
    Join Date
    Dec 2006
    Posts
    0
    Hey. I know this is an old thread, but I'm having issues with this. I initially set up my .fla to import a .txt file. This way:

    myData = new LoadVars();
    myData.onLoad = function(success) {
    if (success) {
    template_txt.html = true;
    template_txt.htmlText = this.content;
    }
    else {
    template_txt = "Sorry, I am currently unable to find this document";
    }}
    myData.load("template.txt");

    However, the text file displayed " and ' marks as boxes. I've got a ton of data and I don't want to have to put %22, %A0, etc in my .txt for all the stuff that shows up as boxes. So I tried this solution for loading an HTML file into my flash.

    function selectPage(address:String) {
    _root.textHolder.condenseWhite = true;
    var myVars_lv:LoadVars = new LoadVars();
    var styles:TextField.StyleSheet = new TextField.StyleSheet();
    var txt_url:String = address;
    var css_url:String = "html_styles.css";
    styles.onLoad = function(success:Boolean):Void {
    if (success) {
    textHolder.styleSheet = styles;
    myVars_lv.onData = function(src:String):Void {
    if (src != undefined) {
    textHolder.htmlText = src;
    } else {
    selectPage(address);
    }
    };
    myVars_lv.load(txt_url);
    } else {
    trace("Unable to load CSS file.");
    selectPage(address);
    }
    };
    styles.load(css_url);
    }

    I can't get it working. I'm not very good with flash, so any help would be greatly appreciated. I've got the selectPage function on my main timeline, and a call for it in an actions layer under my dynamic text field. The text field is in a movieclip, accessed via a user click on a menu. However, the text field doesn't display anything when it opens up. Not the trace, or the file. Any ideas? I am also unsure what function "textHolder" performs. I think its supposed to be an instance name, but that'd mean I need to copy this function, with a corresponding instance name, for every instance I want to call an HTML file into. Plus, I have set this name to the proper instance names and still no avail. Thanks in advance for your input. CitizenChan

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center