LoadVariables from text file into Actionscript.

This is a discussion on "LoadVariables from text file into Actionscript." within the Flash & Multimedia Forum section. This forum, and the thread "LoadVariables from text file into Actionscript. are both part of the Design Your Website category.


 Subscribe in a reader

Go Back   Webforumz.com > Main Forums > Design Your Website > Flash & Multimedia Forum

Notices




Reply
 
LinkBack Thread Tools
  #1  
Old Mar 25th, 2008, 19:31
Reputable Member
Join Date: May 2005
Location: Sheffield
Posts: 107
Thanks: 0
Thanked 0 Times in 0 Posts
Post LoadVariables from text file into Actionscript.

Im loading variables in from a text file which looks like this...

variable1=hello&bigimage=main-graphic.jpg&title01=rebrand


This works fine, I can add a variable to a dynamic text field by adding

_root.variable1 ...... in the textfields' Properties Var: field.


However I want to use variables in ActionScript as a normal variable. i have tried this...

Code: Select all
 
loadVariablesNum("title.txt", 0);
 
myVar = _root.variable1;
 
trace(myVar);
BUT it returns as 'undefined' ............ So, how can I get the variables into ActionScript usage?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote

  #2  
Old Mar 26th, 2008, 10:11
Reputable Member
Join Date: Sep 2007
Location: Tehran - Iran
Age: 29
Posts: 434
Blog Entries: 2
Thanks: 7
Thanked 7 Times in 7 Posts
Re: LoadVariables from text file into Actionscript.

I write a tutorial about loading links from an external text file :
http://blog.datisdesign.com/2008/02/...file-in-flash/

maybe this can help you
If it didnt please attach your fla file...
__________________
Designing For Communicating
Website : http://www.datisdesign.com
Weblog : http://blog.datisdesign.com

Last Blog Entry: Throughout IRAN (Dec 10th, 2007)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3  
Old Mar 26th, 2008, 11:50
Reputable Member
Join Date: May 2005
Location: Sheffield
Posts: 107
Thanks: 0
Thanked 0 Times in 0 Posts
Re: LoadVariables from text file into Actionscript.

Tried the method in your Tutorial and it gave the same outcome.

I have attached a flash movie with both methods, and text.txt file containing the variables.

trace(_root.varTwo) comes back as undefined, but the value appears in a dynamic text field, therefore the variables are loading in ok, just not usable in code.

I want to use the variables in actionscript because..... you may notice varTwo=filename.jpg ........ I want to reference filenames in the actionscript so i can load external images dynamically without hardcoding them into flash.
Attached Files
File Type: fla test.fla (41.5 KB, 3 views)
File Type: txt text.txt (35 Bytes, 3 views)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4  
Old Mar 26th, 2008, 19:03
Reputable Member
Join Date: Sep 2007
Location: Tehran - Iran
Age: 29
Posts: 434
Blog Entries: 2
Thanks: 7
Thanked 7 Times in 7 Posts
Re: LoadVariables from text file into Actionscript.

The reason for that is the variable you are calling is inside function scope and available only in function scope, not outside that, so you get undefined when you call it
__________________
Designing For Communicating
Website : http://www.datisdesign.com
Weblog : http://blog.datisdesign.com

Last Blog Entry: Throughout IRAN (Dec 10th, 2007)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #5  
Old Mar 26th, 2008, 19:13
Reputable Member
Join Date: May 2005
Location: Sheffield
Posts: 107
Thanks: 0
Thanked 0 Times in 0 Posts
Re: LoadVariables from text file into Actionscript.

So do I need to load the variables and call them from inside the same function?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #6  
Old Mar 26th, 2008, 21:09
Reputable Member
Join Date: Sep 2007
Location: Tehran - Iran
Age: 29
Posts: 434
Blog Entries: 2
Thanks: 7
Thanked 7 Times in 7 Posts
Re: LoadVariables from text file into Actionscript.

It traces undefined because trace will run before the function is called, one way is to add another frame to your timeline and there trace your variable and you will get the result.
__________________
Designing For Communicating
Website : http://www.datisdesign.com
Weblog : http://blog.datisdesign.com

Last Blog Entry: Throughout IRAN (Dec 10th, 2007)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Grabbing text from a file schmoose JavaScript Forum 2 Apr 6th, 2008 16:16
Creating a log file (text file) and an XML file using XSL kdelacruz Other Programming Languages 1 Nov 4th, 2006 21:12
Writing to a text file Gurpreet82 Classic ASP 0 Mar 15th, 2006 15:57
Text file download harlekin Classic ASP 2 Dec 5th, 2005 18:23
_root.loadVariables burbie Flash & Multimedia Forum 1 Nov 28th, 2005 10:03


All times are GMT. The time now is 02:13.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42