SitePoint Sponsor |
|
User Tag List
Results 1 to 8 of 8
-
Jul 24, 2002, 03:51 #1
- Join Date
- May 2001
- Location
- From Where???
- Posts
- 65
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Can't get dynamically loaded text to animate!
Hi all,
I am having trouble trying to animate my dynamically loaded text in flash MX. I have used some action script which calls the .txt file and loads it in a text field, this is the only way I know how to do it. The only problem is I can't turn the text field into a symbol as when I do this the flash movie won't load the text anymore. I have tried to assign a path but I think I am not doing it correctly. I also tried to place the action script which loads the text into the symbol itself then place the symbol onto the main timeline but this also has not worked.
I'm not sure what else to do. All I really want to be able to do is apply some alpha transitions to the text field so that it loops smoothly, also I would like to apply some animation effects to it.
Is there a way to achieve this? I hope so.
thanks in advance to anyone who can help with this.
MD Geist"My lyrics are encrypted in Hieroglyphic scriptures so you can picture this.....I make my point like a pyramid"
-
Jul 24, 2002, 04:54 #2
Download this-
http://www.flashswami.com/downloads/text_dup.zip
I did it in Flash 5 quite awhile ago so (assuming you use the new LoadVars() function) some of it won't be relevant- the bit you need is the code that uses a for loop to spit out the text into seperate movieclips.
have alook, see if its any help and if it isn't we'll go through it.FlashSwami //Flash & server side fun
DotDragNet //General web help
[>Now available for freelance web work<]
-
Jul 24, 2002, 05:50 #3
- Join Date
- May 2001
- Location
- From Where???
- Posts
- 65
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Thanks flashswami,
I'll get started on it.
NIce one
MD Geist"My lyrics are encrypted in Hieroglyphic scriptures so you can picture this.....I make my point like a pyramid"
-
Jul 24, 2002, 07:24 #4
- Join Date
- May 2001
- Location
- From Where???
- Posts
- 65
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Hi flashswami,
I tried and failed misserably, I could'nt figure out which part of the code to put into my movie and where.
The bit that I think I need is the part which put's the text into a movie clip, this would mean that I could maipulate the movie clip with alpha tweens etc, and thus animate the text. If it is possible for you isolate in your code exactly how it put's the dynamic text into a movieclip, I would really appreciate it, I apologise, I'm just a novice at this programming stuff. Hopefully one day I'll be answering some of these questions.
Thanks in advance
MD Geist"My lyrics are encrypted in Hieroglyphic scriptures so you can picture this.....I make my point like a pyramid"
-
Jul 24, 2002, 08:41 #5
You're absolutley correct- always make anything that you need to manipulate a movieclip- that way you have control over it.
OK, what this script does is to take a dynamically loaded word and make it animated by splitting the word into an array and then feeding each element of this array into a movieclip of its own. So we start off with a text file like so-
Code://should say hello here but sitepoints editor is truncating it myWord=h:e:l:l:o
Code://hides the seed clip _root.text_mc._visible=false; //loads in and deals with the loaded text loadVarsText = new loadVars(); loadVarsText.load("mytext.txt"); loadVarsText.onLoad = function(success) { if (success) { //do something } else { //do something else } }
Now, note the very top line of code. What this does is to hide the 'template' movieclip- this movieclip is what will get duplicated with each duplication storing one letter from the text.
Okay, now its time to replace the 'do something' bits with real code-
Code://hides the seed clip _root.text_mc._visible=false; //loads in and deals with the loaded text loadVarsText = new loadVars(); loadVarsText.load("mytext.txt"); loadVarsText.onLoad = function(success) { if (success) { //creates a new array textHolder= new Array(); //splits the variable 'myWord' defined in your text file textHolder = _root.myWord.split(":"); //sets x to have a value of the same number of items in the new array x=textHolder.length; //a for loop that duplicates the movieclip called 'text_mc' //and pushes each letter into the dynamic text box in each //duplicated clip for (i=0; i<=x; i++) { _root.text_mc.duplicateMovieClip ("letter_"+i, i); _root["letter_"+i].input = textHolder[i-1]; //spaces them out evenly, one on top of the other if (i != 1) { _root["letter_"+i]._y = _root["letter_"+(i-1)]._y+_root["letter_"+(i-1)]._height+10; } } } else { //do something else } }
Post back if its still not happening for youFlashSwami //Flash & server side fun
DotDragNet //General web help
[>Now available for freelance web work<]
-
Jul 25, 2002, 03:34 #6
- Join Date
- May 2001
- Location
- From Where???
- Posts
- 65
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I still does'nt appear to be working, I keep receiving this message in the output box:
Scene=Scene 1, Layer=Layer 1, Frame=1: Line 2: Statement must appear within on/onClipEvent handler
_root.text_mc._visible=false;
Scene=Scene 1, Layer=Layer 1, Frame=1: Line 4: Statement must appear within on/onClipEvent handler
loadVarsText = new loadVars();
Scene=Scene 1, Layer=Layer 1, Frame=1: Line 5: Statement must appear within on/onClipEvent handler
loadVarsText.load("load_text.txt");
Scene=Scene 1, Layer=Layer 1, Frame=1: Line 6: Statement must appear within on/onClipEvent handler
loadVarsText.onLoad = function(success) {
At the moment I have assigned the script to the instance of the movieclip on the main movie timeline, as in my movie I do not have a button to activate the function, I just need it to start automatically. It's saying I need to use the onClipEvent handler, but I'm not sure how I should implement it within the code, syntax wise, I tried to just put the onClipEvent handler at the beginning of your code but flash was having none of it. Could you show me the correct syntax, or maybe I'm putting the code in the wrong place.
Thanks for your help with this.
MD Geist"My lyrics are encrypted in Hieroglyphic scriptures so you can picture this.....I make my point like a pyramid"
-
Jul 27, 2002, 00:05 #7
Apologies- there was an error in my code- here's teh correct code-
Code:loadVarsText.load("mytext.txt"); loadVarsText.onLoad = function(success) { if (success) { //creates a new array textHolder= new Array(); //splits the variable 'myWord' defined in your text file textHolder = this.myWord.split(":"); //sets x to have a value of the same number of items in the new array x=textHolder.length; //a for loop that duplicates the movieclip called 'text_mc' //and pushes each letter into the dynamic text box in each //duplicated clip for (i=0; i<=x; i++) { _root.text_mc.duplicateMovieClip ("letter_"+i, i); _root["letter_"+i].input = textHolder[i-1]; //spaces them out evenly, one on top of the other if (i != 1) { _root["letter_"+i]._y = _root["letter_"+(i-1)]._y+_root["letter_"+(i-1)]._height+10; } } } else { trace("nope"); } } stop();
http://www.flashswami.com/downloads/...c_text_gen.zipFlashSwami //Flash & server side fun
DotDragNet //General web help
[>Now available for freelance web work<]
-
Aug 8, 2002, 09:17 #8
- Join Date
- May 2001
- Location
- From Where???
- Posts
- 65
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Sorry for not replying sooner,
Thanks for the help flashswami, I've got this
sorted now.
Thanks again for all the help
MD Geist"My lyrics are encrypted in Hieroglyphic scriptures so you can picture this.....I make my point like a pyramid"
Bookmarks