first time - link to frame

  • SpooF
  • ٩๏̯͡๏۶
  • Bronze Member
  • User avatar
  • Posts: 3422
  • Loc: Richland, WA

Post 3+ Months Ago

okay, i want to make a simple flash page, and all i need to know is how to script this. i want to have buttons on the side (links) that when you click it goes to a frame with the text on it. how do i set this up? and what code do i use on the links to get to that frame.
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • digitalMedia
  • a.k.a. dM
  • Genius
  • User avatar
  • Posts: 5149
  • Loc: SC-USA

Post 3+ Months Ago

Assuming this is from a frame script:

To go to a a frame 10 in the Flash presentation:
Code: [ Select ]
myButtonInstance.onPress = function{
   gotoAndStop(10);
}
  1. myButtonInstance.onPress = function{
  2.    gotoAndStop(10);
  3. }


To go to the Frame labeled "Ten" in a Flash presentation:
Code: [ Select ]
myButtonInstance.onPress = function{
   gotoAndStop("Ten");
}
  1. myButtonInstance.onPress = function{
  2.    gotoAndStop("Ten");
  3. }


To target a HTML frame in a FRAMESET:
Code: [ Select ]
myButtonInstance.onPress = function{
   getURL("myWebPage.htm", "myTargetFrame");
}
  1. myButtonInstance.onPress = function{
  2.    getURL("myWebPage.htm", "myTargetFrame");
  3. }
  • SpooF
  • ٩๏̯͡๏۶
  • Bronze Member
  • User avatar
  • Posts: 3422
  • Loc: Richland, WA

Post 3+ Months Ago

alright thanks, do you know how to display a txt doc in a frame? so like you dont have to edit the flash everytime you want to edit text?
  • Chris-Duff
  • Student
  • Student
  • User avatar
  • Posts: 99
  • Loc: Scotland

Post 3+ Months Ago

You will need to have a dynamic text field, call it " scroller " for ex, make sure that in the properties you select " multiline". Also put a "ScrollBar Component beside your text field

let's say that your text is called " text.txt". The first line of your text must start by " var1= blah blah blah !!!! " Var1 = is important as it is the variable that you will be calling.

the action script on the action layer will be: (copy and paste it)

Code: [ Select ]
loadVarsText = new LoadVars();
loadVarsText.load("text.txt");
//assign a function which fires when the data is loaded:
loadVarsText.onLoad = function(success) {
    if (success) {
        trace("done loading");
        //Now that we know the data is loaded,
        //set the text content of the Text Field
        //with the instance name "scroller" equal to the
        //contents of the variable
        scroller.text = this.var1;
    } else {
        trace("not loaded");
    }
};
  1. loadVarsText = new LoadVars();
  2. loadVarsText.load("text.txt");
  3. //assign a function which fires when the data is loaded:
  4. loadVarsText.onLoad = function(success) {
  5.     if (success) {
  6.         trace("done loading");
  7.         //Now that we know the data is loaded,
  8.         //set the text content of the Text Field
  9.         //with the instance name "scroller" equal to the
  10.         //contents of the variable
  11.         scroller.text = this.var1;
  12.     } else {
  13.         trace("not loaded");
  14.     }
  15. };

Hope this help
  • SpooF
  • ٩๏̯͡๏۶
  • Bronze Member
  • User avatar
  • Posts: 3422
  • Loc: Richland, WA

Post 3+ Months Ago

im getting this error iguess this is what it is...

Quote:
Scene=Scene 1, Layer=content, Frame=5: Line 5: Statement must appear within on/onClipEvent handler
loadVarsText = new LoadVars();

Scene=Scene 1, Layer=content, Frame=5: Line 6: Statement must appear within on/onClipEvent handler
loadVarsText.load("text.txt");

Scene=Scene 1, Layer=content, Frame=5: Line 8: Statement must appear within on/onClipEvent handler
loadVarsText.onLoad = function(success) {
  • Chris-Duff
  • Student
  • Student
  • User avatar
  • Posts: 99
  • Loc: Scotland

Post 3+ Months Ago

If you want give me an email address and I'll send you an .fla
  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13502
  • Loc: Florida

Post 3+ Months Ago

Quote:
Statement must appear within on/onClipEvent handler


That means you placed the actions right on a movielip without wrapping them inside of an event.
Code: [ Select ]
on(release){
  loadVarsText = new LoadVars();
  loadVarsText.onLoad = function(success) {
   //place this functons actions here.
  }
  loadVarsText.load("text.txt");
}
  1. on(release){
  2.   loadVarsText = new LoadVars();
  3.   loadVarsText.onLoad = function(success) {
  4.    //place this functons actions here.
  5.   }
  6.   loadVarsText.load("text.txt");
  7. }


Or you can move that to a timeline wrapped inside of a function that can be easily called from anywhere. (you can wrap a function on a movieclip as well but it won't exist until the event wrapped around it is fired)
Code: [ Select ]
function loadIt(source, destination){
  toLoad = new LoadVars();
  toLoad.onLoad = function(success){
   success ? destination.text=this.var1 : destination.text="No Response";
   delete this;
  }
  toLoad.load(source);
}

// If called on a button,
on(release){
  _root.loadIt("text.txt", _root.scroller.text);
}
// or maybe,
on(press){
  _root.loadIt("text.txt", this._parent.container.scroller.text);
}
  1. function loadIt(source, destination){
  2.   toLoad = new LoadVars();
  3.   toLoad.onLoad = function(success){
  4.    success ? destination.text=this.var1 : destination.text="No Response";
  5.    delete this;
  6.   }
  7.   toLoad.load(source);
  8. }
  9. // If called on a button,
  10. on(release){
  11.   _root.loadIt("text.txt", _root.scroller.text);
  12. }
  13. // or maybe,
  14. on(press){
  15.   _root.loadIt("text.txt", this._parent.container.scroller.text);
  16. }
  • SpooF
  • ٩๏̯͡๏۶
  • Bronze Member
  • User avatar
  • Posts: 3422
  • Loc: Richland, WA

Post 3+ Months Ago

  • Chris-Duff
  • Student
  • Student
  • User avatar
  • Posts: 99
  • Loc: Scotland

Post 3+ Months Ago

Posted..
  • DRAGON-MAN
  • Born
  • Born
  • DRAGON-MAN
  • Posts: 1

Post 3+ Months Ago

HI :D :D :D :D :o :evil: :twisted:
  • emella
  • Born
  • Born
  • emella
  • Posts: 1

Post 3+ Months Ago

I was reading this and was wondering how to use the loadvars.text script above to load my xml document instead.
I already have xml loading but I want to do it from a movie clip.
I made the movie clip and mistakenly applied the get xml code directly to it, without having added the loadvars-- which took me to this posting-- very helpful. I just now added that code to my movieclip above the get .xml function. Of course, it doesn't work yet and needs tweaking. Here is what I have, with no errors but also not working: (might I mention that it's on a movie clip, not a button, so I'm not sure how that changes on(release), maybe onLoad?


Code: [ Select ]
on(release){
  loadVarsText = new LoadVars();
  loadVarsText.onLoad = function(success) {
   //place functons here.
     //Create the XML Object
myXML = new XML()
myXML.ignoreWhite = true
//Load XML file
myXML.load("preferences.xml");
//Make a reference to current timeline
myXML.ref = this
// Parse XML and fetch
myXML.onLoad = function(succes){
    if(succes){
        var root = this.firstChild
        nodes = root.childNodes
        for(var i=0; i<nodes.length; i++) {        
            this.ref["Title_txt"+i].text = nodes[i].attributes.name
            subnodes = nodes[i].childNodes
            this.ref["Comments_txt"+i].text = subnodes[0].firstChild.toString()
            this.ref["holder_mc"+i].loadMovie(subnodes[1].firstChild.toString())
        }
    } else         trace("Error loading XML document")
    }
;stop()
     
  }
  loadVarsText.load("text.txt");
}
  1. on(release){
  2.   loadVarsText = new LoadVars();
  3.   loadVarsText.onLoad = function(success) {
  4.    //place functons here.
  5.      //Create the XML Object
  6. myXML = new XML()
  7. myXML.ignoreWhite = true
  8. //Load XML file
  9. myXML.load("preferences.xml");
  10. //Make a reference to current timeline
  11. myXML.ref = this
  12. // Parse XML and fetch
  13. myXML.onLoad = function(succes){
  14.     if(succes){
  15.         var root = this.firstChild
  16.         nodes = root.childNodes
  17.         for(var i=0; i<nodes.length; i++) {        
  18.             this.ref["Title_txt"+i].text = nodes[i].attributes.name
  19.             subnodes = nodes[i].childNodes
  20.             this.ref["Comments_txt"+i].text = subnodes[0].firstChild.toString()
  21.             this.ref["holder_mc"+i].loadMovie(subnodes[1].firstChild.toString())
  22.         }
  23.     } else         trace("Error loading XML document")
  24.     }
  25. ;stop()
  26.      
  27.   }
  28.   loadVarsText.load("text.txt");
  29. }
  • IceCold
  • Guru
  • Guru
  • User avatar
  • Posts: 1254
  • Loc: Ro

Post 3+ Months Ago

you don't necessary need to place all your code in the same function.
You can use on(release) to load the vars text, and onLoad jump to another frame where you place the xml parsing code.
i.e.: in frame 3 place a: stop();
code on the button:
Code: [ Select ]
on(release){

  loadVarsText = new LoadVars();

  loadVarsText.onLoad = function(success) {
   if (success)
    gotoAndPlay(4);
  }
}
  1. on(release){
  2.   loadVarsText = new LoadVars();
  3.   loadVarsText.onLoad = function(success) {
  4.    if (success)
  5.     gotoAndPlay(4);
  6.   }
  7. }

in frame 4:
load the xml

Post Information

  • Total Posts in this topic: 12 posts
  • Users browsing this forum: No registered users and 10 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.