This is Interesting: Free Magazines for Graphics designers and webmasters
Home > Archive > Flash Site Design > February 2007 > Two things:
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
| Enemy13 2007-02-05, 10:14 pm |
| The first of the two problems (more of a lack of creativity than problem) I'm
having is with my scrollbar:
I have a scrollbar that works when scrolling a movieclip of a fixed length.
Unfortunatly, what I wish to scroll is a dynamic text field whose length will
vary. I can get it to work with simple scroll buttons, but i really like the
whole bar thing.
I am trying to keep the website as dynamic as possible, so i need the
scrollbar to just figure out how long the external text file is and go from
there. Is this possible, or am i just going to have to find another way of
doing this. The code i have currently is a bit too long to post, if anyone has
some time they'd like to waste on me then i would gladly send it to you.
Next problem:
I have an empty movie clip on the stage that is a certain size, a size i want.
I am importing into it a picture that is considerably larger than that certain
size. I wish to resize the aforementioned picture so that it the size of the
movie clip prior to the loading of the external image. I have tried to do this
two different ways (both of which you can see at the bottom of the message) and
no, i don't run them at the same time.
In the code, flyerLoader_mc is the movieclip that i am loading the image into,
"flyer/1.jpg" is the the image, and extBar_mc is my preloader bar. Both sets of
code are probably not working for the same reason, i just can't figure the
reason, or more importantly, a way to fix it.
Thanks a lot for even reading this collossal post.
Any help will be greatly appreciated.
-Sean
// THE FIRST WAY \\
flyerLoader_mc.loadMovie("flyers/1.jpg",flyerLoader_mc);
var myInterval:Number = setInterval (flyerLoad, 10);
function flyerLoad() {
var current = flyerLoader_mc.getBytesLoaded();
var total = flyerLoader_mc.getBytesTotal();
var getpctLoaded:Number = Math.round((current/total)*100);
extBar_mc._xscale = getpctLoaded;
if(current >= total){
//resize it
flyerLoader_mc._width = 205;
flyerLoader_mc._height = 314.9;
clearInterval (myInterval);}
extBar_mc._visible = false;
}
//THE SECOND WAY\\
var flyerLoader:MovieClipLoader = new MovieClipLoader();
var flyerListener:Object = new Object();
flyerLoader.addListener(flyerListener);
flyerLoader.loadClip("flyers/1.jpg",flyerLoader_mc);
flyerListener.onLoadProgress =
function(flyerLoader_mc:MovieClip,bytesLoaded,bytesTotal) {
var pctLoaded:Number = Math.round(bytesTotal/bytesTotal*100);
extBar_mc._visible = true;
extBar_mc._xscale = pctLoaded;
if (bytesLoaded >= bytesTotal){
extBar_mc._visible = false;
//resize it
flyerLoader_mc._width = 205;
flyerLoader_mc._height = 314.9;
}
}
| |
| Rob Dillon - Adobe Community Expert 2007-02-06, 6:16 pm |
| Hi Sean,
You can use the maxscroll property of a dynamic text object's text to
tell you how large the block of text is that you've loaded in.
You can use that value in your scroll bar code.
I didn't run the code below. I did mark some changes that should get
either version working for you.
>
> // THE FIRST WAY \\
> flyerLoader_mc.loadMovie("flyers/1.jpg",flyerLoader_mc);
//this line should be: flyerLoader_mc.loadMovie("flyers/1.jpg");
>
> var myInterval:Number;
// leave the first half of this line, to instantiate the interval
variable...
>
> function flyerLoad() {
> var current = flyerLoader_mc.getBytesLoaded();
> var total = flyerLoader_mc.getBytesTotal();
> var getpctLoaded:Number = Math.round((current/total)*100);
> extBar_mc._xscale = getpctLoaded;
> if(current >= total){
> //resize it
> flyerLoader_mc._width = 205;
> flyerLoader_mc._height = 314.9;
>
> clearInterval (myInterval);}
> extBar_mc._visible = false;
> }
>
// define the variable after you've written the function. The name of
the function should be in quotes...
myInterval = setInterval ("flyerLoad", 10);
------------------------
> //THE SECOND WAY\\
> var flyerListener:Object = new Object();
>
>
> flyerListener.onLoadProgress =
> function(flyerLoader_mc:MovieClip,bytesLoaded,bytesTotal) {
> var pctLoaded:Number = Math.round(bytesTotal/bytesTotal*100);
> extBar_mc._visible = true;
> extBar_mc._xscale = pctLoaded;
>
> if (bytesLoaded >= bytesTotal){
> extBar_mc._visible = false;
> //resize it
> flyerLoader_mc._width = 205;
> flyerLoader_mc._height = 314.9;
> }
> }
// move these three lines to the bottom...
var flyerLoader:MovieClipLoader = new MovieClipLoader();
flyerLoader.addListener(flyerListener);
flyerLoader.loadClip("flyers/1.jpg",flyerLoader_mc);
--
Rob
_______
Rob Dillon
Adobe Community Expert
http://www.ddg-designs.com
412-243-9119
http://www.macromedia.com/software/trial/
| |
| Enemy13 2007-02-06, 10:15 pm |
| Rob,
Thanks a lot for the suggestions. I figured out that the UIScrollBar Component
actually works for dynamic text fields. Unfortunatly, it is quite an eyesore
compared to the one i had created myself and I'm not quite sure how much effort
it would take to skin it myself.
I shall fiddle with the maxscroll property and see if i can somehow fit into
my existing code. I'm working with the _height and _y values for what i'm
scrolling, so i will probably have to rewrite quite a bit of it. Either way,
thanks for the tip; it will definitely help in the future.
Unfortunatly, i still can't get my either set of resizing code to work. Each
yields the following results (after making the adjustments you recommended):
the first way: preloading bar shows up full size and refuses to _xscale like i
tell it to, it disappears and then the image is loaded, full size (not the size
that i tell it to be).
the second way: pretty much the same thing with one cardinal difference, the
image fails to show up entirely if i leave the resizing code in! if i comment
it out, then it shows up full size. again. preloader is, again, not doing what
i tell it to.
I tried using the setSize() method (with low hopes, I must admit) to no avail.
By now, i think that it is something really stupid that i am overlooking. I've
already quintuple checked all my instance names and all the other really
obvious things that i could think of. Any other suggestions would be marvelous.
Thanks again.
-Sean
| |
| Rob Dillon - Adobe Community Expert 2007-02-07, 10:14 pm |
| Try this code. When I tested what you had, I found that you can't change
the properties of the clip in a loadProgress function. You have to wait
until the clip is inited. So use the onLoadInit function to change the
size.
------------
var flyerListener:Object = new Object();
flyerListener.onLoadProgress = function(target:MovieClip,
bytesLoaded:Number, bytesTotal:Number):Void {
var pctLoaded:Number = Math.round((bytesLoaded/bytesTotal)*100);
if (pctLoaded < 100) {
extBar_mc._xscale = getpctLoaded;
} else {
extBar_mc._visible = false;
}
}
flyerListener.onLoadInit = function(target_mc:MovieClip):Void {
flyerLoader_mc._width = 205;
flyerLoader_mc._height = 314.9;
};
var flyerLoader:MovieClipLoader = new MovieClipLoader();
flyerLoader.addListener(loadListener);
flyerLoader.loadClip("flyers/1.jpg", fadeHolder);
--------------
--
Rob
_______
Rob Dillon
Adobe Community Expert
http://www.ddg-designs.com
412-243-9119
http://www.macromedia.com/software/trial/
|
|
|
| | Copyright 2003 - 2008 forum4designers.com Software forum Computer Hardware reviews |
|