Flash Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsWeb DesignFlash Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 2nd, 2003, 06:31 PM
Matt Phelps Matt Phelps is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2002
Posts: 33 Matt Phelps User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
loadmovie image from a txt file

I'm a bit puzzled on this.

I have a movieclip on the stage called mcImage and I want to load an image into it - the name of which I specify in a text file - when the clip is loaded.

The actionscript I have on this layer is:

loadVariablesNum("copy.txt", 0);
loadMovie(picture, "mcImage");

The contents of the file copy.txt is:

picture=Picture4.jpg

When I test the movie I am expecting to see the image 'Picture4.jpg' loaded in the mcImage Movieclip. Instead I get a blank movie! If I have a look at the variables (List Variables) I get:

Level #0:
Variable _level0.$version = "WIN 6,0,21,0"
Variable _level0.picture = "Picture4.jpg"
Movie Clip: Target="_level0.mcImage"

If I modify the script to:

loadMovie("Picture4.jpg", "mcImage");

...then the image displays on screen fine, but I don't want to have to specify the image name like this because I want to dynamically decide which image to display.

I'm not sure what I'm doing wrong here. I'm very new to Flash and I'm experimenting with dynamic content. Can anyone explain why what I'm doing doesn't work?

Last edited by Matt Phelps : December 2nd, 2003 at 06:34 PM.

Reply With Quote
  #2  
Old December 2nd, 2003, 06:59 PM
Tann San Tann San is offline
Gotta get to the next screen..
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Nov 2003
Location: Legion of Dynamic Discord
Posts: 4,718 Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)  Folding Points: 11326 Folding Title: Novice Folder
Time spent in forums: 3 Weeks 1 Day 12 h 58 m 9 sec
Reputation Power: 580
Facebook MySpace
Hi, I've been playing with sql lately. I had similar problems with that. This machine doesnt have flash installed or access to the sql db so I'll have to go from memory.

A couple of things that pop to mind straight away are:

try:

picture="Picture4.jpg"

in the text file. It could be that easy. Do you have other things in the text file? if so is it like this:

picture=Picture4.jpg
&name=my fav pic
&size=500x125

if so then you have to take the newline into account.

if all of that still doesnt work. try this out:

loadMovie(picture.substring(1, picture.length - 2), "mcImage");

That should chop the first and last characters off. An easy way to test all this out is to make a dynamic text box in root. Give it a variable name of picture. Then you can see exactly what is being loaded in. if you see quotes then you know that you've got to chop them off. My problem was to do with this. php was adding the quotes which made the resulting thumbnail not showup.

forgot to mention if all of that doesnt work then stick in a new variable so you have:

picture=Picture4.jpg&completed=true

then in the frame which does loadmovie have completed = false; BEFORE the load movie part. Then do a check to make sure that completed == true before loading the movie. The problem could be to do with the file name not being completely read prior to you trying to load it into the target movie.
__________________
-Tann

-Vote for your favorite ActionScript editor here.

Last edited by Tann San : December 2nd, 2003 at 07:03 PM.

Reply With Quote
  #3  
Old December 3rd, 2003, 03:04 AM
Matt Phelps Matt Phelps is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2002
Posts: 33 Matt Phelps User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
I tried all you suggested and it didn't seem to make any difference. As I say - if I check the variables I think that the picture variable is loading correctly because I can see:
Variable _level0.picture = "Picture4.jpg"

But I don't understand why this line doesn't work:
loadMovie(picture, "mcImage");

Surely this is supposed to load what is in the picture variable - in this case "Picture4.jpg" - into that movie. How can I check it's doing this?

I also should mention I don't really understand what all this 'level0' and 'root' stuff means. Could it be related? I seem to be loading the variables from Copy.txt into 'level0'. Is my mcImage movie not on level0 as well? Is that my problem?

Reply With Quote
  #4  
Old December 3rd, 2003, 03:38 AM
Tann San Tann San is offline
Gotta get to the next screen..
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Nov 2003
Location: Legion of Dynamic Discord
Posts: 4,718 Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)  Folding Points: 11326 Folding Title: Novice Folder
Time spent in forums: 3 Weeks 1 Day 12 h 58 m 9 sec
Reputation Power: 580
Facebook MySpace
Hi, try this out then:

loadMovie(_root.picture, _root.mcImage);

_root is the main movie timeline, or the top most movie (the one that is already there when you make a new flash file). _root is level0. Each movie clip etc has a level number. Higher levels go ontop of lower levels. You can get a good idea of what I mean by using the target button in the AS panel. This will show the heirarchy of your movie timeline (as long as you have instance names on things). I can rant on for ages about this so lemme know! From your ealier post it appears that both the variable and the mcImage movie are in the root.

Reply With Quote
  #5  
Old December 3rd, 2003, 10:05 AM
Matt Phelps Matt Phelps is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2002
Posts: 33 Matt Phelps User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Thanks for helping, I do appreciate it but I must be doing something really stupid! I now have:

loadVariables("copy.txt", 0);
loadMovie(_root.picture, _root.mcImage);

If I understand correctly I've asked to load the variables in "copy.txt" into level 0 (or root) and then I'm asking it to load the variable 'picture' from root into the movieclip (which is sitting on the timeline at level zero in frame one) called mcImage.

The actual result is still a blank movie. Again if I debug and check variables I get:

Level #0:
Variable _level0.$version = "WIN 6,0,21,0"
Movie Clip: Target="_level0.mcImage"


Reply With Quote
  #6  
Old December 3rd, 2003, 10:16 AM
Tann San Tann San is offline
Gotta get to the next screen..
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Nov 2003
Location: Legion of Dynamic Discord
Posts: 4,718 Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)  Folding Points: 11326 Folding Title: Novice Folder
Time spent in forums: 3 Weeks 1 Day 12 h 58 m 9 sec
Reputation Power: 580
Facebook MySpace
Hi,

loadVariables("copy.txt", _root);
loadMovie(_root.picture, _root.mcImage);

This one changed from using a level with loadvars to using _root.

If that doesnt work I'll be happy to take a look.

ps.

take the quotes out of the text file (if u put them in like i said too earlier, my bad!)

Reply With Quote
  #7  
Old December 3rd, 2003, 10:29 AM
Matt Phelps Matt Phelps is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2002
Posts: 33 Matt Phelps User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
With the code above I have:

Level #0:
Variable _level0.$version = "WIN 6,0,21,0"
Variable _level0.picture = "Desk.jpg"
Movie Clip: Target="_level0.mcImage"

Looks like the variable picture has the right data in it but for some reason it won't upload it to the movieclip? I've attached the fla file for you to look at - AS is on layer 1.

The text file (which lives in the same folder as the fla file) just has:

picture=Desk.jpg

and is called 'copy.txt'. I've added them all in the zip file.

cheers
Attached Files
File Type: zip dynamicimage.zip (40.9 KB, 244 views)

Reply With Quote
  #8  
Old December 3rd, 2003, 11:01 AM
Tann San Tann San is offline
Gotta get to the next screen..
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Nov 2003
Location: Legion of Dynamic Discord
Posts: 4,718 Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)  Folding Points: 11326 Folding Title: Novice Folder
Time spent in forums: 3 Weeks 1 Day 12 h 58 m 9 sec
Reputation Power: 580
Facebook MySpace
Hi, all done.

The problem was with the text file variable. Even though I tripple checked it didnt have a newline etc at the end flash still thought there was one. To fix it I capped the end with another variable.

picture=pic2.jpg&done=true

something like that anyways. we dont really care about done its just there to terminate the picture var.

edit-> I removed dynamicimage.zip as I reached my attachment quota, ask and I will post it again.

Last edited by Tann San : June 15th, 2004 at 04:27 AM.

Reply With Quote
  #9  
Old December 3rd, 2003, 11:55 AM
Matt Phelps Matt Phelps is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2002
Posts: 33 Matt Phelps User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Did you have to change anything in the FLA file? I'm using the one you uploaded but it seems the same? I changed my own copy.txt as you suggested, capped it with another variable but I still get nothing on the screen.

Reply With Quote
  #10  
Old December 3rd, 2003, 12:12 PM
Tann San Tann San is offline
Gotta get to the next screen..
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Nov 2003
Location: Legion of Dynamic Discord
Posts: 4,718 Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)  Folding Points: 11326 Folding Title: Novice Folder
Time spent in forums: 3 Weeks 1 Day 12 h 58 m 9 sec
Reputation Power: 580
Facebook MySpace
Hi, ok well I used the button you had in the library. I attached the code and it didnt work still. After a while I realised the capping thing. I moved loadVariables into the first frame so that it had a chance to complete before the button could be clicked. Sometimes with large data it can take a while to read in. I think if you use it before its finished you get incomplete data.
That could still be a problem here later on, but this should do for now.

So back to the stuff:

In _root -> frame 1:
loadVariables("copy.txt", _root);

That loads the text file variables into the root.

on (release) {
mcImage.loadMovie(picture, 0);
}

The button code changed slightly. What happens now is that the movie is loaded into mcImage level 0. Its basically the same thing. I'm not sure if changing it would have any effect because I did it before noticing the newline issue.

Are you sure you got the image names right? you know originally you were saying Picture4.jpg and then the one you sent me was Desk.jpg?

ummm...ok if your using my file how come it doesnt work? Does the swf file I sent work?

Inside the text file:

picture=Desk.jpg&done=true

did you get the & sign in there? that seperates variables.

Reply With Quote
  #11  
Old December 3rd, 2003, 12:19 PM
Matt Phelps Matt Phelps is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2002
Posts: 33 Matt Phelps User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Image names are a bit difference but only because I was trying a different image. The zip file you uploaded seems to have the same files unmodified that I uploaded myself? Did you re-upload my original zip file or a new one?

Reply With Quote
  #12  
Old December 3rd, 2003, 12:26 PM
Tann San Tann San is offline
Gotta get to the next screen..
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Nov 2003
Location: Legion of Dynamic Discord
Posts: 4,718 Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)  Folding Points: 11326 Folding Title: Novice Folder
Time spent in forums: 3 Weeks 1 Day 12 h 58 m 9 sec
Reputation Power: 580
Facebook MySpace
Hi, maybe I uploaded the wrong one. Didnt think I did but here it is again. I checked this one and it is definately the one I modded.
Attached Files
File Type: zip dynamicimage.zip (41.9 KB, 281 views)

Reply With Quote
  #13  
Old December 3rd, 2003, 12:31 PM
Matt Phelps Matt Phelps is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2002
Posts: 33 Matt Phelps User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Ah! Now it works! Thanks a million! Is it possible to get it to load the image when the movieclip runs rather than have to have someone press a button?

Reply With Quote
  #14  
Old December 3rd, 2003, 12:32 PM
Tann San Tann San is offline
Gotta get to the next screen..
Dev Shed Demi-God (4500 - 4999 posts)