Avatar billede theselfimages Nybegynder
03. maj 2003 - 23:55 Der er 29 kommentarer og
1 løsning

Load textfil i MC

Kan dette lade sig gøre, hvis funktionen skal køre fra et MC? Og hvordan?

http://www.virtual-fx.net/tutorials/html/loadtextfile.htm
Avatar billede barklund Nybegynder
04. maj 2003 - 00:00 #1
Eksemplet er i Flash 4 - i Flash MX er det meget nemmere og kan sagtens køres fra et movieclip:

loading = new LoadVars();
loading.onLoad = function(s) {
    tekstfelt.text = this.variabel;
}
loading.load("foo.txt");
Avatar billede theselfimages Nybegynder
04. maj 2003 - 00:07 #2
Hmm.. jeg har dette i root

fscommand("allowscale", false);
function changeMC(mc) {
    scrollbar.button._y = 0;
    current = mc;
    scrollbar.bg.calcMCHeight();
}
changeMC("mc");
stop();

Der peger på et MC hvor et dynamisk textfelt er lavet

Kan ikke få det til at virke med at loade text ind i det.
Avatar billede barklund Nybegynder
04. maj 2003 - 00:13 #3
hvorfra skal du loade teksten og hvordan ser din tekstfil ud?
Avatar billede theselfimages Nybegynder
04. maj 2003 - 00:17 #4
Fordi det vil være langt nemmere at redigere i tekst.

Min fil hedder text.txt og ser sådan ud:
text=You can use this to allow quick text changes in Flash movies...

Meningen er at teksten trækkes på et layer og fungere sammen med scroll scriptet. Det burde virke. Hvis jeg bare vidste hvordan jeg trak teksten ind gennem et MC
Avatar billede barklund Nybegynder
04. maj 2003 - 00:30 #5
jeg spurgte ikke hvorfor :)

Men:

fscommand("allowscale", false);
function changeMC(mc) {
    scrollbar.button._y = 0;
    current = mc;
    scrollbar.bg.calcMCHeight();
    myLoad = new LoadVars();
    myLoad.onLoad = function(s) {
        _root[_root.current].text = this.text;
    }
    myLoad.load("text.txt");
}
changeMC("mc");
stop();
Avatar billede theselfimages Nybegynder
04. maj 2003 - 00:38 #6
Kait! fat det!..

Jeg har i root lagt dit script som action på frame i layer 1
Og i mit movieclip lavet et nyt layer med et dynamisk teksfelt med variablen "text" ... Det skal vel ikke ha' noget instancenavn?
Avatar billede barklund Nybegynder
04. maj 2003 - 00:39 #7
næ, ikke nødvendigvis...
Avatar billede theselfimages Nybegynder
04. maj 2003 - 00:42 #8
Hmm.. men det virker altså ikke. Ingen tekst vises.
Avatar billede theselfimages Nybegynder
04. maj 2003 - 00:43 #9
Jeg kan lægge hvad som helst andet i endnu et layer (statisk text / billede) og det virker fint med at scrolle det. Så det er altså funktionen med at trække text ind i det MC der er problemer med.
Avatar billede barklund Nybegynder
04. maj 2003 - 00:44 #10
prøv:

function changeMC(mc) {
    scrollbar.button._y = 0;
    current = mc;
    scrollbar.bg.calcMCHeight();
    myLoad = new LoadVars();
    myLoad.onLoad = function(s) {
        trace("loaded in "+this.text);
        _root[_root.current].text = this.text;
    }
    myLoad.load("text.txt");
}
changeMC("mc");
stop();
Avatar billede theselfimages Nybegynder
04. maj 2003 - 00:47 #11
Nope.. desværre..
Avatar billede theselfimages Nybegynder
04. maj 2003 - 00:48 #12
Vil du se filen?
Eller er det noget med at du ikke selv har Flash? :)
Avatar billede barklund Nybegynder
04. maj 2003 - 00:49 #13
Det er vel flash mx?

og ovenstående gav heller ingen noget trace i output vinduet?
Avatar billede theselfimages Nybegynder
04. maj 2003 - 00:53 #14
Mærkeligt.. det der komme i output vinduet er teksten fra text.txt filen!?!

Og det er MX
Avatar billede theselfimages Nybegynder
04. maj 2003 - 00:56 #15
Level #0:
Variable _level0.$version = "WIN 6,0,4,0"
Variable _level0.changeMC = [function 'changeMC']
Variable _level0.current = "mc"
Variable _level0.myLoad = [object #2, class 'LoadVars'] {
    onLoad:[function 'onLoad'],
    text:"You can use this to allow quick text changes in Flash movies without actually having to open up the Flash file.  It is nice for simple changes of paragraphs.\r\nI would not recomment using this if your text is going to need a lot of formatting, like tables and so forth.\r\nTo change the color/size of your text simply double-click your text field in the Flash movie set the color/size and that should do it!"
  }
Movie Clip: Target="_level0.scrollbar"
Variable _level0.scrollbar.current = "mc"
Movie Clip: Target="_level0.scrollbar.bg"
Variable _level0.scrollbar.bg.calcMCHeight = [function 'calcMCHeight']
Variable _level0.scrollbar.bg.y = 156.85
Variable _level0.scrollbar.bg.x = undefined
Variable _level0.scrollbar.bg.intArrowUnit = 300
Movie Clip: Target="_level0.scrollbar.button"
Button: Target="_level0.scrollbar.button.instance1"
Variable _level0.scrollbar.button.instance1.tabIndex = [getter/setter] undefined
Movie Clip: Target="_level0.scrollbar.buttonUp"
Button: Target="_level0.scrollbar.buttonUp.instance2"
Variable _level0.scrollbar.buttonUp.instance2.tabIndex = [getter/setter] undefined
Movie Clip: Target="_level0.scrollbar.buttonDown"
Button: Target="_level0.scrollbar.buttonDown.instance3"
Variable _level0.scrollbar.buttonDown.instance3.tabIndex = [getter/setter] undefined
Movie Clip: Target="_level0.mc"
Variable _level0.mc.text = "You can use this to allow quick text changes in Flash movies without actually having to open up the Flash file.  It is nice for simple changes of paragraphs.\r\nI would not recomment using this if your text is going to need a lot of formatting, like tables and so forth.\r\nTo change the color/size of your text simply double-click your text field in the Flash movie set the color/size and that should do it!"
Edit Text: Target="_level0.mc.instance4"
    variable = "text",
    text = "You can use this to allow quick text changes in Flash movies without actually having to open up the Flash file.  It is nice for simple changes of paragraphs.\r\rI would not recomment using this if your text is going to need a lot of formatting, like tables and so forth.\r\rTo change the color/size of your text simply double-click your text field in the Flash movie set the color/size and that should do it!",
    htmlText = "You can use this to allow quick text changes in Flash movies without actually having to open up the Flash file.  It is nice for simple changes of paragraphs.\r\rI would not recomment using this if your text is going to need a lot of formatting, like tables and so forth.\r\rTo change the color/size of your text simply double-click your text field in the Flash movie set the color/size and that should do it!",
    html = false, textWidth = 232, textHeight = 180, maxChars = null,
    borderColor = 0x000000, backgroundColor = 0xFFFFFF, textColor = 0x000000, border = false,
    background = false, wordWrap = true, password = false, multiline = true,
    selectable = false, scroll = 1, hscroll = 0, maxscroll = 3,
    maxhscroll = 0, bottomScroll = 10,
    type = "dynamic",
    embedFonts = false, restrict = null, length = 404, tabIndex = undefined,
    autoSize = "none",
    condenseWhite = false
Avatar billede barklund Nybegynder
04. maj 2003 - 00:58 #16
ja, det er jo også det der står i koden...

Prøv:

function changeMC(mc) {
    scrollbar.button._y = 0;
    current = mc;
    scrollbar.bg.calcMCHeight();
    myLoad = new LoadVars();
    myLoad.onLoad = function(s) {
        trace("loaded in "+_root[_root.current]);
        _root[_root.current].text = this.text;
    }
    myLoad.load("text.txt");
}
changeMC("mc");
stop();
Avatar billede theselfimages Nybegynder
04. maj 2003 - 01:00 #17
Eller UPS ... sådan her for et rent Output:

Level #0:
Variable _level0.$version = "WIN 6,0,4,0"
Variable _level0.changeMC = [function 'changeMC']
Variable _level0.current = "mc"
Variable _level0.myLoad = [object #2, class 'LoadVars'] {
    onLoad:[function 'onLoad'],
    text:"You can use this to allow quick text changes in Flash movies without actually having to open up the Flash file.  It is nice for simple changes of paragraphs.\r\nI would not recomment using this if your text is going to need a lot of formatting, like tables and so forth.\r\nTo change the color/size of your text simply double-click your text field in the Flash movie set the color/size and that should do it!"
  }
Movie Clip: Target="_level0.scrollbar"
Variable _level0.scrollbar.current = "mc"
Movie Clip: Target="_level0.scrollbar.bg"
Variable _level0.scrollbar.bg.calcMCHeight = [function 'calcMCHeight']
Variable _level0.scrollbar.bg.y = 156.85
Variable _level0.scrollbar.bg.x = undefined
Variable _level0.scrollbar.bg.intArrowUnit = 300
Movie Clip: Target="_level0.scrollbar.button"
Button: Target="_level0.scrollbar.button.instance1"
Variable _level0.scrollbar.button.instance1.tabIndex = [getter/setter] undefined
Movie Clip: Target="_level0.scrollbar.buttonUp"
Button: Target="_level0.scrollbar.buttonUp.instance2"
Variable _level0.scrollbar.buttonUp.instance2.tabIndex = [getter/setter] undefined
Movie Clip: Target="_level0.scrollbar.buttonDown"
Button: Target="_level0.scrollbar.buttonDown.instance3"
Variable _level0.scrollbar.buttonDown.instance3.tabIndex = [getter/setter] undefined
Movie Clip: Target="_level0.mc"
Variable _level0.mc.text = "You can use this to allow quick text changes in Flash movies without actually having to open up the Flash file.  It is nice for simple changes of paragraphs.\r\nI would not recomment using this if your text is going to need a lot of formatting, like tables and so forth.\r\nTo change the color/size of your text simply double-click your text field in the Flash movie set the color/size and that should do it!"
Edit Text: Target="_level0.mc.instance4"
    variable = "text",
    text = "You can use this to allow quick text changes in Flash movies without actually having to open up the Flash file.  It is nice for simple changes of paragraphs.\r\rI would not recomment using this if your text is going to need a lot of formatting, like tables and so forth.\r\rTo change the color/size of your text simply double-click your text field in the Flash movie set the color/size and that should do it!",
    htmlText = "You can use this to allow quick text changes in Flash movies without actually having to open up the Flash file.  It is nice for simple changes of paragraphs.\r\rI would not recomment using this if your text is going to need a lot of formatting, like tables and so forth.\r\rTo change the color/size of your text simply double-click your text field in the Flash movie set the color/size and that should do it!",
    html = false, textWidth = 232, textHeight = 180, maxChars = null,
    borderColor = 0x000000, backgroundColor = 0xFFFFFF, textColor = 0x000000, border = false,
    background = false, wordWrap = true, password = false, multiline = true,
    selectable = false, scroll = 1, hscroll = 0, maxscroll = 3,
    maxhscroll = 0, bottomScroll = 10,
    type = "dynamic",
    embedFonts = false, restrict = null, length = 404, tabIndex = undefined,
    autoSize = "none",
    condenseWhite = false
Avatar billede theselfimages Nybegynder
04. maj 2003 - 01:02 #18
Sorry... nu fik jeg denne...

loaded in _level0.mc
Avatar billede theselfimages Nybegynder
04. maj 2003 - 01:04 #19
Men hvis teksten står som en del af ovenstående Output, hvorfor kan jeg så ikke se det i mit scrollområde?
Avatar billede barklund Nybegynder
04. maj 2003 - 01:05 #20
det står nu, at teksten i feltet er den rigtige...

prøv at inkludere font outlinen... for det bør virke!
Avatar billede theselfimages Nybegynder
04. maj 2003 - 01:09 #21
Okay... ja.. det hjalp.. men nu står det MEGET blured trods at det er Verdana.. og det gør det faktisk ikke her...
http://www.virtual-fx.net/tutorials/html/loadtextfile.htm
Avatar billede barklund Nybegynder
04. maj 2003 - 01:10 #22
that's flash :)

du kan kun scrolle embedde tekster... og de blurer altid :(
Avatar billede theselfimages Nybegynder
04. maj 2003 - 01:16 #23
Åhhh! nej! .. intet at gøre der så?
Hmm... øv! det ser jo ud ad helvede til og ikke til at læse
Avatar billede barklund Nybegynder
04. maj 2003 - 01:16 #24
find en pixelfont (fra miniml.com) eller tilsvarende...
Avatar billede barklund Nybegynder
04. maj 2003 - 01:18 #25
men jeg kan næppe tro, at det ser ud af helvede til... jeg bruger ofte embedded verdana på mange professionelle projekter...
Avatar billede theselfimages Nybegynder
04. maj 2003 - 01:19 #26
Ok!.. tænkte godt på det.. Men tusind tak for din hjælp.
Endnu engang! DU er udholden! Kan du så poste et svar, tror du :)

Mvh.. Lars
Avatar billede barklund Nybegynder
04. maj 2003 - 01:28 #27
Yup :)
Avatar billede theselfimages Nybegynder
04. maj 2003 - 01:30 #28
Takker! Har du set en hvis hr. Filip er gået i krig med mit spørgsmål til lidt modificering af den player du hjalp mig med?
Avatar billede barklund Nybegynder
04. maj 2003 - 01:32 #29
ja, jeg er også selv ved at kigge
Avatar billede barklund Nybegynder
04. maj 2003 - 01:32 #30
og tark for point :)
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
IT-kurser om Microsoft 365, sikkerhed, personlig vækst, udvikling, digital markedsføring, grafisk design, SAP og forretningsanalyse.

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester