Solved

easing in a text area

Posted on 2003-12-05
29
313 Views
Last Modified: 2010-04-03
i want to make a text area that moves with easing, i will be using pixel fonts so it needs to move on whole pixel coordinates. At the moment i'm using a scrollbar to move it but this could just as easily be buttons. I know that i need to place the text area inside an mc and target this mc but beyond that i'm stumpted, any help would be much appreciated.
0
Comment
Question by:supDawg
  • 14
  • 12
29 Comments
 
LVL 9

Expert Comment

by:OBCT
ID: 9887195
Give your mc an instance name like textMC or something relevant like that.
Then click the mc and give it these actions:

onClipEvent (enterFrame) {
     this._x += 1;
}

This will move your mc along the x scale at 12 pixels a second (if you are using the frame rate of 12 per second)
If this isn't exactly what you want, please explain in more detail what you are trying to achieve.

Cheers

-OBCT
0
 

Author Comment

by:supDawg
ID: 9888091
i also want it to ease to a stop.
0
 

Author Comment

by:supDawg
ID: 9888100
i want it to scroll like a normal text area but with a smooth easing to a start and stop. It could either be controlled by a scroller or by two buttons depending on what i better/easier to implement.
0
 
LVL 9

Expert Comment

by:OBCT
ID: 9888107
Try this:

onClipEvent (load) {
      _x = 0;
      div = 5;
}

onClipEvent (enterFrame) {
      endX = -500
      _x += (endX-_x)/div;
}

If you want it to move on the press of a button then use this code:

onClipEvent (load) {
      _x = 0;
      div = 5;
}

onClipEvent (enterFrame) {
      _x += (endX-_x)/div;
                mybutton.onRelease = function () {     //mybutton is the instance name of your button
                endX = -500;
                }
}

If you need anymore help just ask

Cheers

-OBCT
0
 

Author Comment

by:supDawg
ID: 9888140
so how would this work, a text area placed inside an mc and what controls the scroll up and down, could it be a dynamic text area with a scrollbar?

The second set of code, would this just be placed on the mc, how could i send it back up again?
0
 
LVL 9

Expert Comment

by:OBCT
ID: 9888156
Yes you could use a scrollbar, that should be fine.
You would place the code on the mc in the main scene, and to send to mc back to its original position you will need to add a button with the instance name of button2 for example, so your overall code should look something like this:

 Comment from OBCT
Date: 12/06/2003 04:20PM EST
 Your Comment  

Give your mc an instance name like textMC or something relevant like that.
Then click the mc and give it these actions:

onClipEvent (enterFrame) {
     this._x += 1;
}

This will move your mc along the x scale at 12 pixels a second (if you are using the frame rate of 12 per second)
If this isn't exactly what you want, please explain in more detail what you are trying to achieve.

Cheers

-OBCT

 
Comment from supDawg
Date: 12/06/2003 11:28PM EST
 Author Comment  

i also want it to ease to a stop.

 
Comment from supDawg
Date: 12/06/2003 11:30PM EST
 Author Comment  

i want it to scroll like a normal text area but with a smooth easing to a start and stop. It could either be controlled by a scroller or by two buttons depending on what i better/easier to implement.

onClipEvent (load) {
     _x = 0;
     div = 5;
}

onClipEvent (enterFrame) {
     _x += (endX-_x)/div;
     mybutton.onRelease = function () {     //mybutton is the instance name of your button
     endX = -500;
     }
     mybutton2.onRelease = function () {
     endX = 0;
     }
}
 
 
0
 
LVL 9

Expert Comment

by:OBCT
ID: 9888161
sorry i copied too much.
This should be your end code:

onClipEvent (load) {
     _x = 0;
     div = 5;
}

onClipEvent (enterFrame) {
     _x += (endX-_x)/div;
     mybutton.onRelease = function () {     //mybutton is the instance name of your button
     endX = -500;
     }
     mybutton2.onRelease = function () {
     endX = 0;
     }
}
0
 

Author Comment

by:supDawg
ID: 9888198
sorry but can you just give me the full code for doing it with 2 buttons, b1 and b2, i'm a bit confused by looking at the two different ways. Thanks.
0
 
LVL 9

Expert Comment

by:OBCT
ID: 9888228
onClipEvent (load) {
     _x = 0;
     div = 5;
}

onClipEvent (enterFrame) {
     _x += (endX-_x)/div;
     b1.onRelease = function () {     //b1 is the instance name of your button
     endX = -500;                          //Sets the position you want your mc to go to
     }
     b2.onRelease = function () {     //b2 is the instance name of your button
     endX = 0;                              //Sets the position to go back to where it started
     }
}
0
 

Author Comment

by:supDawg
ID: 9888245
can i make it ease back up aswell, not necessarily back to the top straight away? and will this work with pixel fonts?
0
 
LVL 9

Expert Comment

by:OBCT
ID: 9888261
Where exactly do you want it to ease to? Like specific co-ordinats.
As for the pixel fonts, I'm not sure. It should work ok but again I'm not sure.
0
 

Author Comment

by:supDawg
ID: 9888275
just ease back up a few pixels and slow down, move just like a normal text area basically but with easing. that what i want it to do in both directions, it will probably have to move a bit more than a normal text block to see the easing.

Thanks a lot.
0
 
LVL 9

Expert Comment

by:OBCT
ID: 9888350
With the code I've givin you, that will move your mc 500 pixels to the right, then 500 pixels to the left depending on which button you click.
It does ease over then slow down to a stop. All you need to do is change the pixels to suit your needs.
If you want the mc to move up and down rather than left and right, just change all the "x" in the code to "y".
Just play around with the div if you want to change the speed.
0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 

Author Comment

by:supDawg
ID: 9888427
this is the code i'm trying on an mc that contains a dynamic text area. i have two buttons on the stage with the mc, called b1 and b2, the text comes in scrolling from the bottom of the stage to the top. It only shows a small amount of  the text, part of the first paragraph.

this is the script:

onClipEvent (load) {
     _y = 400;
     div = 5;
}

onClipEvent (enterFrame) {
     _y += (endY-_y)/div;
     b1.onRelease = function () {     //b1 is the instance name of your button
     endY = -500;                          //Sets the position you want your mc to go to
     }
     b2.onRelease = function () {     //b2 is the instance name of your button
     endY = 0;                              //Sets the position to go back to where it started
     }
}


0
 

Author Comment

by:supDawg
ID: 9888438
the text area is 247 wide by 373 high.
0
 
LVL 9

Expert Comment

by:OBCT
ID: 9888465
Using this type of coding is alot of trail and error. Sometimes you have to keep playing with things until it works out.

onClipEvent (load) {
     _y = 400;             //This is where you want the mc to sit on the y scale (Keep in mind, flash thinks the top of your mc is where that little ball in the mc sits.)
     div = 5;                // This is speed of the easing (2 for very fast, 20 for very slow) you can use any number
}

onClipEvent (enterFrame) {
     _y += (endY-_y)/div;
     b1.onRelease = function () {     //b1 is the instance name of your button
     endY = 0;
//This will bring your movie clip to bring your movie clip to the top of the stage. This means that everything from the top of your mc down, the user will be able to see.
     }
     b2.onRelease = function () {     //b2 is the instance name of your button
     endY = 400;                              //Sets the position to go back to where it started
     }
}
0
 

Author Comment

by:supDawg
ID: 9888468
the fla is here if you could take a look at it please
www.confuzeddesign.co.uk/checker/test.fla

thanks.
0
 
LVL 9

Expert Comment

by:OBCT
ID: 9895705
Sorry it's been so long since I posted a comment, I don't use the computer much on weekends.
I had a look at your fla, but the only way I can really do anything is if you tell me the exact co-ordinats you want everything to move, when etc etc etc
Once you tell me those things, we'll figure out how to fix this :)

Cheers

-OBCT
0
 

Author Comment

by:supDawg
ID: 9895915
well basically its like this, the size of the text area, 247 by 373 i always want to be visible. i want the text to begin from the top showing as much as the text area will allow, after each click of the buttons i want the text to move down 3 or 4 pixels and ease into position.
Let me know any other details that you need.

Thanks.
0
 
LVL 9

Expert Comment

by:OBCT
ID: 9896297
Well I've had a look and tried out about one thousand differents ways of coding it but I just cannot get the text to ease.
I came pretty close, but without being able to mesure the orginal position of the scroll variable theres nothing that I can do.
I'll try and explain what I mean a bit better.
We were working on this formula to make the text ease:
_y += (endY-_y)/div;
So when a button is pressed, it sets the "endY" variable to -150 for example, so every pixel the text moves, the slower it goes until it comes to a complete stop.
To get the text itself to scroll we would need to use something like this:
_root.mc.text.scroll +=3
Now that will scroll the text 3 lines down. The first part of that evaluation (_root.mc.text.scroll) is a function. When 3 is added on, flash basically says "Move this (_root.mc.text) down 3 lines."
On the first formula, the first part (_y) is a co-ordinate rather than a function.
Without having an original co-ordinate, there is no way we can execute the rest of the evaluatioin.
Trying to use the first formula with the second function, we would be asking something like this:
_root.mc.text.scroll += (endY-_root.mc.text.scroll)/div;       That will not work out because flash will think we are trying to turn a function into a formula, if thats makes any sense.
That's the bit where I have no idea about.
I'm very sorry I couldn't fix this for you. Pehaps another expert will come along and help you out.
All the best.

Cheers

-OBCT
0
 

Author Comment

by:supDawg
ID: 9896395
thanks for all the help anyway. I'll let you know if i can solve it.
0
 
LVL 9

Accepted Solution

by:
OBCT earned 125 total points
ID: 9976528
I figured it out :D
After hours of stuffing around I found a way to do it using a mask and a bit of coding.
I uploaded the fla to my web server for you to look at.
http://www.wren-intermedia.com/ee/easing_textScroller.fla     <--- This is for Flash MX 2004
http://www.wren-intermedia.com/ee/easing_textScrollerMX.fla <--- This is for Flash MX

Cheers

-OBCT
0
 
LVL 9

Expert Comment

by:OBCT
ID: 10035397
supDawg,

Please post a comment back to let me know how you are going with your project or close this question.

Cheers

-OBCT
0
 

Author Comment

by:supDawg
ID: 10057897
Sorry man, just back at my pc after an extended xmas period!.

The scroller u have provided works well but not for pixel fonts which is what i use. i'm tempted to splash out on the ultimate scroller, http://www.flashloaded.com/ultimate.php?id2=  , unless you've had any further success as this concept is something i would like to extend to mc's etc.

Thanks for the time and help all the same.
0
 

Expert Comment

by:super_cat
ID: 10057940
The only draw back to the ultimate scroller is that its not free. But if you have some spare money then its the way to go! The scroller I made was only good for static text where as the ultimate scroller can contain pixel fonts (which is what you want), pictures and all the other things that I'm sure you've read about.
You'll save yourself alot of time and stress using this program. I probably should have pointed it out on my first post.
Anyway, if you need anymore help with anything just let me know.

Cheers

-OBCT
0
 
LVL 9

Expert Comment

by:OBCT
ID: 10057951
Sorry, my sister left EE opened and I accidently made a post in her name.
0
 
LVL 9

Expert Comment

by:OBCT
ID: 11005641
supDawg,

Please post a comment or close this question.

Cheers

-OBCT
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

This is intended to introduce all collision detection principles in flash, their strengths, weaknesses and workarounds. The main method for Collision Detection in flash is using hitTestObject. But unless you'll be pushing rectangular shapes without …
The last time I worked with Flash and Socket connections was in AS1. A recent project required flash connecting to a Socket, and sending receiving information - we figured it would be easy enough - we all know about the socket policy documents and c…
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.
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.

743 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now