Solved

Import images on the fly based on value from txt file

Posted on 2003-10-27
6
178 Views
Last Modified: 2010-05-18
Hi all.

I'm looking for a solution.

I'm going to have 10 different pictures, that I'll need to import into flash based on value from txt file. So lets say I have in txt file content picture1, i need to import picture1,jpg on the fly, or if there is value in text file picture5, i need to import picture5.jpg

If I have picture1,picture5,picture6,picture8 in txt file, i need to import all pictures picture1,jpg, picture5.jpg,picture6.jpg,picture8jpg

I want to have horizontal scroll of the images, so I can see past images that were included before. And if I click on one of the images, some info sould be shown, again from txt files or another type of files HTML  lets say

Thanks in Advance

Valentin
0
Comment
Question by:valentin_v
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
6 Comments
 
LVL 22

Expert Comment

by:rascalpants
ID: 9627709
if you are looking to load images at runtime using dynamic variables, then you would just do the following:

open Notepad and copy and past the below text:

pic1=picture1.jpg&pic2=picture5.jpg&pic3=picture6.jpg&pic2=picture8.jpg&


save the file as "var.txt"


then in your Flash movie, use this code in the first frame(Assumes you have Flash MX):

myData = new LoadVars();
myData.load("var.txt?nocache=" + random(10000), myData, "POST");
myData.onLoad = function(){

for(i=0; i<4; i++){
   var img = this['myData.pic'+i];
   var con = this['myData.container'+i];
   loadMovie(img, con);
}

};


I have not tested this code, but it should be okay...   it will load the variables, and then load the jpegs into container movieclips(that you need to create either at runtime or manually) with the instance names of container1, container2, etc  etc...

have a crack at this code, and let me know what you get...


rp
0
 
LVL 22

Expert Comment

by:rascalpants
ID: 9627940
actually something more like this should work...  


myData = new LoadVars();
myData.load("var.txt", myData, "POST");
myData.onLoad = function(){

for(i=0; i<5; i++){
   var img = this['myData.pic'+i];
   var con = this['_root.container'+i];
   loadMovie(img, con);
}

};
stop();



rp
0
 

Author Comment

by:valentin_v
ID: 9628464
How to create  container movieclips at runtime.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 5

Expert Comment

by:Calron
ID: 9628736
Have a look at this tutorial which demonstrates quite nicely how to create such containers at run time.

http://www.actionscript-toolbox.com/samplemx_loadjpg.php
0
 
LVL 22

Accepted Solution

by:
rascalpants earned 500 total points
ID: 9629627
you just create an empty movieclip and give it a name like "container1"

you can put that in the same code that loads the images, but you have to do it before you reference the instance names and try to use them....


rp
0
 
LVL 22

Expert Comment

by:rascalpants
ID: 9697654
only a "B"?

:(


rp
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes a solution to a problem of subloading one movie into another when they have different SWF versions. Sometime back, I was working on an ActionScript project while I came across an interesting fact which I would like to share…
While working over numerous projects I often had the requirement for doing a screen capture in AS3.0. Unfortunately I found no "ready made" solutions in google search that suited my requirements. But I did come across some great resources which help…
In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…
The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question