Web Design and Development Forums

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.


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

Welcome to Webforumz.com.
Register Now Register now!

Reply
 
LinkBack Thread Tools Rate Thread
Old Mar 25th, 2008, 19:31   #1 (permalink)
Reputable Member
 
Join Date: May 2005
Location: Sheffield
Posts: 107
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?
Andy K is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old Mar 26th, 2008, 10:11   #2 (permalink)
Moderator
 
marSoul's Avatar
 
Join Date: Sep 2007
Location: Tehran - Iran
Age: 28
Posts: 367
Blog Entries: 2
Send a message via MSN to marSoul Send a message via Yahoo to marSoul
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

Datis Design Website
Datis Design Weblog
marSoul is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old Mar 26th, 2008, 11:50   #3 (permalink)
Reputable Member
 
Join Date: May 2005
Location: Sheffield
Posts: 107
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, 1 views)
File Type: txt text.txt (35 Bytes, 1 views)
Andy K is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old Mar 26th, 2008, 19:03   #4 (permalink)
Moderator
 
marSoul's Avatar
 
Join Date: Sep 2007
Location: Tehran - Iran
Age: 28
Posts: 367
Blog Entries: 2
Send a message via MSN to marSoul Send a message via Yahoo to marSoul
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

Datis Design Website
Datis Design Weblog
marSoul is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old Mar 26th, 2008, 19:13   #5 (permalink)
Reputable Member
 
Join Date: May 2005
Location: Sheffield
Posts: 107
Re: LoadVariables from text file into Actionscript.

So do I need to load the variables and call them from inside the same function?
__________________
Graphic Allies www.graphicallies.com | Marvelhouse www.marvelhouse.com
Andy K is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old Mar 26th, 2008, 21:09   #6 (permalink)
Moderator
 
marSoul's Avatar
 
Join Date: Sep 2007
Location: Tehran - Iran
Age: 28
Posts: 367
Blog Entries: 2
Send a message via MSN to marSoul Send a message via Yahoo to marSoul
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

Datis Design Website
Datis Design Weblog
marSoul is offline  
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
Rate This Thread
Rate This Thread:

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
Creating a log file (text file) and an XML file using XSL kdelacruz XML, RSS & Atom 1 Nov 4th, 2006 21:12
Is it possible to use an external text file for a variable AdRock JavaScript Forum 2 Sep 15th, 2006 17:25
Writing to a text file Gurpreet82 ASP Forum 0 Mar 15th, 2006 15:57
Text file download harlekin ASP Forum 2 Dec 5th, 2005 18:23
_root.loadVariables burbie Flash & Multimedia Forum 1 Nov 28th, 2005 10:03



Latest Updates

All Points SEO Security Advisory - CHECK YOUR SITE NOW!

Creative Coding :: February 2008

Webforumz is sponsored by: WESH UK Web Hosting
All times are GMT. The time now is 11:44.

Sleep Study Scoring :: Free Bet :: Website Templates :: Online Betting :: Bookmakers :: Funny Quotes :: Internet Recruitment Software :: Microsoft CRM Experts :: Online Casino :: Decorated Christmas Trees :: Midwife Forums :: Football Betting :: Ecommerce Software :: Web Hosting :: Football Stats :: Dry Cleaning Collection :: xtreme wales - extreme clothing :: Apuestas :: Sharepoint Consultants :: Website Optimisation :: Office Clearance London :: Sharepoint Experts :: Sports Betting :: Casino :: Website Templates :: Web Design Development India :: Online Gambling

Powered by: vBulletin Version 3.7, Copyright ©2000 - 2008, Jelsoft Enterprises Limited.
© 2003-2008 Webforumz.com : All Rights Reserved
Search Engine Friendly URLs by vBSEO 3.2.0 RC6


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 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59