View Full Version : new to flash 2004 mx
Hi, i new to flash mx. i nid to do a project on a marquee. can anyone tell mi where to find tutorials on making the marquees?
Thanks:)
Medyman
03-19-2008, 11:20 AM
Hi, i new to flash mx. i nid to do a project on a marquee. can anyone tell mi where to find tutorials on making the marquees?
Thanks:)
http://www.tutorialized.com/view/tutorial/Scrolling-Marquee/11281
Here's (http://www.googleguide.com/) a guide to Google, while you're at it. It's a very useful tool..learn to use it!
Hi orginally i was saying i was doing a marquee. sorry, i doing an image marquee the software i am using is flash mx professional 2004. Any help will be greatly appericated...
i was going to attach the file for reference, but can`t because it doesn`t support .rar files.
:(
Thanks in advance
djr33
03-24-2008, 11:09 AM
That isn't really defining anything, by adding the word "image". I suppose you mean it isn't text scrolling, but an image sliding?
You can use tweens for that, and just loop it. I don't expect it would be that difficult.
Anyway, there should be enough tutorials out there-- again, use google.
Now, in terms of the file, which would indeed be helpful, you can use another format including zip (basically a more compatible version of .rar, and you can create that with basically any software that will let you create .rar), or you could just do a screencapture of your trouble and we can view it quickly and help, IF that is enough information.
I be using actionscript to create the marquee.
i tried doing the marquee by reading up the stuffs etc. attached below is the source code which i written. On the surface its looks fine but the marquee could not display all the pictures i put in another folder. The
In the meantime while waiting for your replys i going to keep trying where i went wrong or i need to add in more codes
cheers :)
Medyman
03-25-2008, 04:17 AM
Hmm....
Your ActionScript seems waaaaaaay too complicated. I'd recommend the start over from scratch approach.
Sometimes when I code myself into a hole, I just put it aside and come back to it. A fresh mind goes a long way.
In any case, check out the "scrolling thumbnail panel" video tutorial at www.gotoandlearn.com.
That might fit the bill quite nicely. Otherwise, attach your .fla.
Thanks for the advice.. i get back to you if i have a problems. :D
haha i found my mistake already
function startScrolling()
{
logos_mc.x--;
if(logos_mc._x<=-(logos_mc._width/10))
if logos_mc._x=5;
}
when i change the 10 to 2, the whole thing work perfectly, can anyone tell mi tell mi y?
Thanks :D
:confused:
Hi can anyone explain y i help my number,the program work perfectly???
Medyman
04-01-2008, 02:59 PM
That would have to depend on your setup. It's a conditional statement so for it to to trigger the events attached to it, it has to be rendered true.
I can't tell directly what actions this conditional triggers from your snippet, so it's hard to tell you why.
But I think this snippet is related to resetting the scroller when it goes too far to the left. What I suspect is that you have a fairly large image/movieclip in relation to the stage.
Say, your logo_mc's width is 100 pixels. Your conditional statement would then be testing to see if the logo_mc's x position is at -10. If it is, then it would reset it to 3. If you have a large image in relation to the stage, that conditional is going to be met pretty quickly. Since you say that your code didn't work before and changing this fixed it, I suspect that your image/mc might have been very close to 10 pixels over the left side of the stage (either due to it's entire size or positioning at the beginning of the movie). You're resetting to 3, so that might be it. So, if you have a frame rate of anything greater than 13, you're not going to get much movement -- the higher the frame rate, the less you'll see (even though the code is executing...just too quickly to catch)
Now, with the same example, changing it to 2 now makes the conditional statement test for -50. This is a far larger scrolling distance. Because of the application here, I suspect logo_mc to be fairly large in width. So, that test value is probably fairly high giving you plenty of room to scroll before the conditional triggers.
Hope that explains it :)
Hi medyman,
if i understand wrongly, i gt 2 lines of codes which is like this
// increase loadedImages by .5 and not 1 because the images are being loaded twice otherwise, it will double.
loadedImages += 0.5;
if (loadedImages == totalImages)
{
replaceMCs();
}
// decrease totalimages by .5 and not 1 because the images are being loaded twice otherwise, it will double.
totalImages -= 0.5;
if (loadedImages == totalImages)
{
replaceMCs();
}
Do u mean this 2 statements influence the the number i asked u abt??
:)
Medyman
04-02-2008, 02:56 AM
No, the number of images in the marquee don't necessarily make a difference to the width of the marquee.
If you have ten images that are 10px wide or one image that's 100px wide, it's the same thing to Flash.
The numbers you asked about are in direct result of the width of the logo_mc and it's position relative to the left edge of the stage.
Rockonmetal
04-02-2008, 03:13 AM
If it helps at all... Maybe your just going for the multiple effects flash can put on a marquee... But HTML has a simple marquee code and it works nicely. its really simple tag too... You would nevr guess the name of it... Its called
<marquee>Text images and other junk</marquee>
You can edit the speed and stuff... Theres a whole reference page here on it:
http://www.htmlcodetutorial.com/_MARQUEE.htmlhttp://It a couple pages but they are down to the point, give you the code and make everything make sense...
Hopes it helps even though your looking for a way to do it in flash which I don't know how todo...
Medyman
04-02-2008, 03:32 AM
If it helps at all... Maybe your just going for the multiple effects flash can put on a marquee... But HTML has a simple marquee code and it works nicely. its really simple tag too... You would nevr guess the name of it... Its called
<marquee>Text images and other junk</marquee>
You can edit the speed and stuff... Theres a whole reference page here on it:
http://www.htmlcodetutorial.com/_MARQUEE.htmlhttp://It a couple pages but they are down to the point, give you the code and make everything make sense...
Hopes it helps even though your looking for a way to do it in flash which I don't know how todo...
An option, if you're not a stickler for usability or compliance. For your <marquee> tag users though, I think there are some plans to add marquee tags into CSS 2 specifications.
Plus, I think the OP is using images...by marquee I'm assuming he/she means a scrolling panel.
Thanks for the tip Rockonmetal. but i could only do it in flash :(
medyman, thanks for the solution, i still quite a greenhorn to flash so i might have to trouble u for a little longer .Hope u dun mind helping out for a little longer :D
Medyman
04-02-2008, 06:15 PM
medyman, thanks for the solution, i still quite a greenhorn to flash so i might have to trouble u for a little longer .Hope u dun mind helping out for a little longer :D
Bring it on! I don't mind at all. I'm glad to help. This forum (read Blizzard) helped me get my start in Flash, so I'm just returning the favor.
If I minded helping people out, I wouldn't visit these forums, lol.
Oh bother, now my project nid to auto-resize all the images into a standardized size.
Any tips on how to do it..
Medyman
04-03-2008, 02:42 PM
Are you resizing the image within some type of animation? If not, then you should probably resize the images before you bring them into Flash.
Resizing an image in Flash will:
1) Bloat your file size
2) Not have the best results -- distorted/pixelated
If you are going to resize, you should use a high quality .png to achieve the best possible results.
Look into McTween for AS 2.0 and Tweener for AS 3.0 to create the animation.
Let me know if you need any help with this.
hi medyman , the logos dimensions are all 150 by 126, i suppose there should be no problems. But when i put it in the marquee the the logos with juz the words will be short in height, i suppose my task nw is to make the words to be as tall as the other logos with images. I try using websites with resizing softwares, but without any success.
attached are 2 images juz for reference, in case u not too sure wat i toking abt :o
Hi, here a screenshot i took. spend some time looking for a bmp converter :D
Medyman
04-04-2008, 03:03 AM
Hi, here a screenshot i took. spend some time looking for a bmp converter :D
I see what you mean. I really don't think that looks bad though. I'd opt for keeping the logos at their original dimensions in lieu of resizing them to fix an arbitrary size.
I see two problems here.
1) The logotypes (text logos) don't have a set height for the type. So if you were to resize them, you wouldn't know what to resize them to (unless you use transparent .pngs with all white space trimmed).
2) I'm not sure if your marquee can handle elements of variable width. I forget if you're bringing the images in dynamically or if they're hard-coded into the .swf.
If having a uniform size is important to you, I'd suggest doing it external of Flash. Yes, it means extra work but that's the only way to achieve a professional result.
If you still want to do it within Flash, here's the basic syntax with mc_tween.
#include "mc_tween2"
logo_mc.yScaleTo(percentage, time(in sec), animation type);
or
#include "mc_tween2"
logo_mc.resizeTo(width, height, time, animation type);
Using only the first will give you a distorted image. You'll also have to use xScaleTo if you want to maintain the proportions.
erm, should be hard coded i tink? cos i onli use the action frame to do the whole marquee. the timeline etc i 'not allowed' to use it. Then the program i wrote will find the images folder & the .txt file. personally i feel its looks okie without resizing, can`t realli imagine wat some of the images will look like after re-sizing. feel kind of odd
Medyman
04-04-2008, 03:46 AM
erm, should be hard coded i tink? cos i onli use the action frame to do the whole marquee. the timeline etc i 'not allowed' to use it. Then the program i wrote will find the images folder & the .txt file. personally i feel its looks okie without resizing, can`t realli imagine wat some of the images will look like after re-sizing. feel kind of odd
By hard-coded I mean are the images within the .swf or are bringing them in from an external source. Since you're talking about .txt file etc..., I'm guessing the latter.
And I have to agree that it looks fine. It would be much easier (and better quality) to edit the images external to flash. That's what I would do, at least.
Hi, the code u gave mi i nt too sure how to use & insert, mind explaining wat is the syntax & animation type means? :confused:
i attached it juz in case u dun understand. Realli sorrie for replying so fast :o
Yea. I`m bringing them frm an external source. well i nid to check if i`m allowed to change the images sizing using other software instead of of using coding to control. The chances is i hav to use codes to control them. Zzz
Medyman
04-04-2008, 04:00 AM
That screenshot is impossible to read, lol.
But first, have you installed mctween? If you haven't that's the first step (link is below).
As far as the syntax, i'll let the original author explain it to you. It'll probably make more sense with examples etc... on his site.
http://hosted.zeh.com.br/mctween/
btw...why wouldn't you be able to edit the images using image authoring software. Resizing shouldn't be protected under any type of copyright. If it is, then you'd be violating that by doing it by code as well. The problem arises when you edit the contents, not it's dimensions. But it depends on your source, I suppose.
The resizing images was someting i thought out of. :) My teacher only tell to make the images the same height and he gone for the weekend.. Anw, there an interesting website u recommend. the images i will ask him on monday abt the resizing methods.
btw, the 2 lines of codes u gave, i tink the 2nd one is better since the percentage looks harder
Is my example correct? Erm, the animation type is a must? since i already hav my marquee moving at this present time & must move at a constant pace.
Sorrie in advance abt bomarding u with so much qns at one time
#include "mc_tween2"
logo_mc.resizeTo(100, 100, 10, easeInQuad);
Medyman
04-04-2008, 12:22 PM
Oh I see.. I didn't realize this was for school. I thought maybe the people that own the images had restrictions on you to not resize. It makes sense now.
You're AS is close...but the animation type goes in quotes.
#include "mc_tween2"
logo_mc.resizeTo(100, 100, 10, "easeInQuad");
Yes, the animation type is required. If you don't want any type of easing, you should use "linear" as the animation type -- this in effect doesn't apply any easing.
With that code, you're resizing the image to 100px by 100px over 10 seconds. If you use this in your application, you'll probably want to make the time really small (like .01 seconds) so it happens right away.
The benefit of the percentage is that you can maintain an aspect ratio without doing the math. For example, your logos (at least the examples you posted here) are 150px by 126px. If you resize to 100 x 100...the proportions will be all off and the image will look skewed. But if you resize the x-axis and y-axis by 10%, then the proportions are kept in line. You could also just do the math and use resizeTo() as well -- which is what I usually do because you're right, it is easier than messing with percentages.
Hi, okie i put the quotes on the animation type already. But when i run it, there is an error. (Error opening include file mc_tween2: File not found.) #include "mc_tween2". Do i nid to declare in the beginning? Or i nid to do someting to it?
Medyman
04-07-2008, 04:25 AM
Sorry, that was my mistake...i forgot the extension.
It should be
#include "mc_tween2.as"
If that doesn't work, make sure you downloaded and installed (http://hosted.zeh.com.br/mctween/downloads.html) it.
ya, i download the extension file manager for flash mx on fri alr. Or should i dl for flash5 instead? Another thing is, as i can scroll down there r some installation file, do i dl the newest ver? Erm, medyman btw i suddenly realise the image size is also the background size (white background) right? so we should not be able to change the interior (wording /images ) using normal means. If i wrong to say tt, pls correct mi cos i still fuming abt y i cannot change the size :D .
Okie, anw be4 u reply i dl the newest ver . the program can accept tiz piece of new information so is able to run, but its seems to hav no effect. Perhaps u might hav some more tricks up your sleeve
Hi, al`right.. I FINALLY know wat the requirement for tiz project. My teacher wants me to do a mouseover the marquee & when click 1 of image will go to a website. so for example 40 images 40 websites.... The website muz b in the same file as the .txt which stores de images.
btw medyman, the auto-resize I dun nid it alr. he change his mind again. Always at the minute... :mad:
Okie for nw, i better go read up on mouseover...
Medyman
04-07-2008, 12:52 PM
Ahh, well let me know if you need any more help.
A quick tip: You don't really want a mouseover, you want to click on image and go to a website, right? So you'll want to use [movieclip].onRelease
a mouseover is done with [movieclip].onRollOver but that would mean that you would go to the website just but mousing over the image, not actually clicking
Erm if its a mouseover too. Cos the marquee nid to stop when the cursor is in the marquee. I was tinking abt using javascript for the txt file ( putting all the website address in there) & saving as .txt files. Then the mouseover in actionscript.
can it be done saving the website address in .txt file & not .html file?
:D
Medyman
04-08-2008, 03:16 AM
Erm if its a mouseover too. Cos the marquee nid to stop when the cursor is in the marquee. I was tinking abt using javascript for the txt file ( putting all the website address in there) & saving as .txt files. Then the mouseover in actionscript.
can it be done saving the website address in .txt file & not .html file?
:D
Yes, of course. Or, if you want to simplify it further, use XML (don't know if you're allowed to do this for your project).
XML is SUPER SUPER easy. A txt file might be harder.
You'll have to use the same process you're using with the images to bring in the text (the links will have to be in the same order as the images) and then pass that value into getURL()
To be honest, I've never worked with importing data from .txt files. I've found that method to be a little bit more labor intensive and more error prone (maybe it's just my implementation).
I always use XML for this kind of thing.
medyman, thanks for your suggestion abt using xml file but my teacher say NO XML FILE, U WILL CONFUSE YOURSELF & OTHERS. U R SUPPOSED TO USE ONLI A .txt file. gt a big dressing down. i dun realli get it nw. y he say xml will confuse people?
Medyman
04-08-2008, 12:18 PM
medyman, thanks for your suggestion abt using xml file but my teacher say NO XML FILE, U WILL CONFUSE YOURSELF & OTHERS. U R SUPPOSED TO USE ONLI A .txt file. gt a big dressing down. i dun realli get it nw. y he say xml will confuse people?
I don't know either. I think XML is more straightforward.
The thing with text files is, it doesn't have a set structure in the same way XML does. I suppose you could define a certain separation character/string. So, for example: imagePath and imageLink. From there, you will be able to divide the whole string into an array in ActionScript.
With XML, you would have a string like this
<img path="path/to/image" link="http://www.link.com" />
and you could easily parse any/all of the attributes, without having to deal with arrays and all that.
I guess text files are a more "basic" structure and might be better from you to learn from (at least in your teacher's eyes). I build these sorts of applications to go live on the web and I don't usually manage them. So, I need the most user friendly way possible for my clients to change things. But in the end, my clients are only dealing with a CMS...I create the XML via PHP. But since XML has a defined structure, it's easy to create via PHP.
ic.xml sure looks easier. :) my marquee is juz for the school intranet. So mayb i do not nid to do till so professional. Erm do u noe how to do it in .txt file? The linking of websites . :D
I read frm online, its says juz putting a | den type the website down, it should work
Medyman
04-09-2008, 01:15 AM
ic.xml sure looks easier. :) my marquee is juz for the school intranet. So mayb i do not nid to do till so professional. Erm do u noe how to do it in .txt file? The linking of websites . :D
I read frm online, its says juz putting a | den type the website down, it should work
Yea, that's the general idea. It doesn't have to be a |...it can be anything as long as it is consistent.
I haven't so much as even looked at working with text files in Flash. I learned XML to begin with and have stuck with it.
Okie thanks. Let mi solve the .txt thing 1st. after i done with tt den i let u noe. Still hav some qns to bother u :p
erm, i try using typing the mouseover by reading up on the tutorial. but it did not work.
Can guide mi? :)
hi, juz a qns. even i gt the linking between the URL & the marquee. if i juz click the marquee will it work if i nv do the mouseover functions etc?
Medyman
04-11-2008, 03:36 AM
hi, juz a qns. even i gt the linking between the URL & the marquee. if i juz click the marquee will it work if i nv do the mouseover functions etc?
Hmm, I think I understood that. If you could, try to keep away from the shorthand...I'm not very good at deciphering Internet-speak, :)
The "click" event and "mouseover" event are for different purposes entirely. If you're asking if you can use the in conjunction, then yes, you can.
For example, I'm sure you've seen flash effects where you mouse over a link of some kind and the color changes or a glow appears, etc. That's using the onMouseOver event call. The onRelease event is fired when you click on something and then release.
If you're linking to something, you want to use the onRelease.
for example:
logo_mc.onRelease = function() {
getURL("site", target, method);
}
the target and method aren't required.
Sorrie for the short-forms :p. okie, i try understand this 2 lines. the 1st line is talking about the cursor or mouse, den 2nd is about the url etc.
so if i wan the marquee to stop moving when the cursor is touching it, after the line on the onRelease then i add codes to set it?
Another thing is, the get url part mayb i dun require? since i linking from a txt file. ( though i haven`t found someting in the web which can link both my txt & url together yet) :(
few days never ask u stuff in forum, suddenly alot to ask again :D
Medyman
04-11-2008, 06:08 PM
Even if you're brining in the URL from a text file, you'll need the getURL. The getURL is what creates the link.
Take basic HTML for example, your link is like this:
<a href="http://www.website.com">Text</a>
The URL that you're bringing in is the http://www.website.com part. You still need to tell flash that this is a link and not just a regular string (in HTML you need the <a> tag to tell the rendering engine that it's a link). Just typing www.website.com in an HTML won't produce a link.
So, what you'll have to do is to bring in the value from the .txt file, store it in a variable (let's call it earl for example purposes). Then, your AS will look like this:
logo_mc.onRelease() {
getURL(earl);
}
As for stopping the marquee, you're making it move with a setInterval so you can clear it with a clearInterval onMouseOver and then reset the setInterval onMouseOut.
okie, thanks for the tips, i go read up on it nw :) erm, mind if i post my codes step by step ?? :P
erm the marquee will stop when the mouse is over it but if the mouse is taken off after that should the marquee will continue from where it was stop, should i still use setInterval?
logos_mc.onRelease = function() {
logos_mc._x = 0;
myInterval = setInterval(moveLogos, 500);
};
this will reset the marquee when clicked, so if i going to pause the marquee while the cursor is over it, i need to input the function mouse() etc?
Thanks for answering my doubts :D
Medyman
04-14-2008, 04:51 PM
okie, thanks for the tips, i go read up on it nw :) erm, mind if i post my codes step by step ?? :P
No, not at all. Go right ahead.
erm the marquee will stop when the mouse is over it but if the mouse is taken off after that should the marquee will continue from where it was stop, should i still use setInterval?
Well, the function that you're calling with the setInterval (if memory serves) is constantly subtracting 1 pixel every second (or whatever your interval is). So if you use clearInterval, it will stop that function from being called.
That means, the marquee will stop at that point.
Then, onMouseOut, set the interval again calling the same function. So, when you mouse off, the marquee starts at the same point again.
I would think that's the behavior you want instead of resetting it every time you mouse over it.
logos_mc.onRelease = function() {
logos_mc._x = 0;
myInterval = setInterval(moveLogos, 500);
};
this will reset the marquee when clicked, so if i going to pause the marquee while the cursor is over it, i need to input the function mouse() etc?
Not quite sure what you mean here. Yes, that function will reset the _x position because you have logos_mc._x=0;. If you don't want it to reset, just remove that part.
For your situation, do something like this.
logo_mc.onMouseOver() {
clearInterval(myInterval); // This clears the Interval, and stops the scrolling
}
logo_mc.onMouseOut() {
myInterval = setInterval(moveLogos, 500); // This sets it again and resumes scrolling
}
hmm something is wrong somewhere i suppose,because when i put the code in, nothing happens , juz saw the hand* cursor when pointed at the marquee. mayb i need to declare the interval time etc at the start of the sctipt? because when i put the code in, nothing happens.
logos_mc.onRelease = function()
{
myInterval = setInterval( moveLogos,500)
};
logo_mc.onMouseOver()
{
clearInterval(myInterval); // This clears the Interval, and stops the scrolling
}
logo_mc.onMouseOut()
{
myInterval = setInterval(moveLogos, 500); // This sets it again and resumes scrolling
}
Medyman
04-15-2008, 01:22 AM
Hmm...
Can you zip up your project files and upload them to mediafire (http://www.mediafire.com)or something so that I can have a look?
Post the link here when you're done.
thanks medy for taking up so much of your time, i add in some stuff if you dun mind can help mi take a look too? Thanks again
http://www.mediafire.com/?ammfikzto12
Medyman
04-15-2008, 12:57 PM
Ahh, I see what the problem was. You switched the function and variables names on me! :D
Delete the onMouseOver, onMouseOut, onRelease functions you have towards the end of the AS. And replace with this:
// mouse events
// clearInterval onRollOver
logos_mc.onRollOver = function() {
clearInterval(scroll_int);
trace("Stopping the marquee");
}
// re-setInterval onRollOut
logos_mc.onRollOut = function() {
scroll_int = setInterval(startScrolling, 15);
trace("Ok, start again.");
}
I put in traces so you can see what's going on, they're not necessary.
On another note, I'm not sure if you realize or not that onMouseOver and onMouseOut are not AS2 mouse actions. There are such calls in AS3, but not in AS2 (at least, as far as I know). In AS2 you have to use onRollOver and onRollOut for those instances.
Lastly, if you don't mind me asking, why are you being forced to do this the hard way? I suppose it's a learning exercise, but there are tons of simpler ways to do this. Using the native Tween class in Flash MX 2004, you can cut down the code for the scrolling bit to three lines (minus the include statements). Using a public class like McTween or Tweener, you can cut all of your scrolling AS to one line. With XML, you can cut down your data importing in almost half. I don't mean to degrade your techniques in anyway. They're all valid and important that you know the basics. But I find this way to be harder, that's all. It's more of a headache than it's worth (IMHO).
erm, i went to my school library to borrow a book on flash mx professional, xml sure looks easy*. But i still do not know why he wanted mi to do it in .txt file. I went to some other forums to take a look, some of their projs must also be done without xml, but other file types other den .txt. :)
huh, onMouseover etc is as3 word? I seriously thought its an as2 word, cos the book i borrowed have the word inside. Oh the word is OnClipEvent (mouseMove), is that veri different from OnRollOver.
al`right its works veri nicely, i let him take a look later.Thanks :D. erm, as for the last part the URL, do i nid to change someting to it?
I read from the book, its taking content from external file, there stll the getURL() method though
Medyman
04-16-2008, 02:57 AM
erm, i went to my school library to borrow a book on flash mx professional, xml sure looks easy*. But i still do not know why he wanted mi to do it in .txt file. I went to some other forums to take a look, some of their projs must also be done without xml, but other file types other den .txt. :)
huh, onMouseover etc is as3 word? I seriously thought its an as2 word, cos the book i borrowed have the word inside. Oh the word is OnClipEvent (mouseMove), is that veri different from OnRollOver.
al`right its works veri nicely, i let him take a look later.Thanks :D. erm, as for the last part the URL, do i nid to change someting to it?
I read from the book, its taking content from external file, there stll the getURL() method though
Did you have a link programmed in the example you sent me? I didn't see anything related to the linkage. You'll have to do the same thing you did with the image paths.
1. Parse the .txt file
2. Assign the links to the respective logo
3. set the onRelease event with a getURL
Again, you have to use getURL. Just because you associate a link with a movieclip, doesn't mean it will automatically link to it. Look at my analogy between HTML and AS for a refresher.
On a more general note, there are pretty limited ways of communciated externally to Flash. These include
1) Text Files
2) XML
3) PHP (perhaps other server side languages)
4) Javascript
5) FlashVars
The last three are usually used in unison. Going back and forth between PHP and Flash can get really old, really fast. What I usually do is output XML from PHP...this opens up a whole host of possibilities such as Content Management systems, et. al.
I use FlashVars a lot for things like FLV players and that kind of thing. That way, I can just parse whatever the URL is from the HTML/PHP output instead of having things preplanned (i.e. in text files).
Erm, ya i put the link inside in the txt file called website, because i thought the website nid to be in another folder. I juz checked it out with my teacher. the start/stop is done, he quite pleased & the website url should be in the same file as logos :D Thanks alot okie, i go read the getURL() methods & onRelease 1st, try writing it out then if have some parts i dun get it i check up with with again :p.
1 more thing, since i nid to click the image to link to a website, do i nid to input code to the mouse click ?Though i can`t find anyting about in the book :confused:
i tried looking up on loadVariables() , loadVars() since its where it start to load the external data into flash. do u tink i nid to wrote my code from that part?
logos_mc.onRelease = function() {
getURL();
}
i juz sort of guessed it :p frm the advice u gave
Medyman
04-16-2008, 12:51 PM
i tried looking up on loadVariables() , loadVars() since its where it start to load the external data into flash. do u tink i nid to wrote my code from that part?
logos_mc.onRelease = function() {
getURL();
}
i juz sort of guessed it :p frm the advice u gave
Yeah, that's the right function. But you need a parameter inside the function to tell it where to link to.
getURL() by itself doesn't do anything. That's like saying <a href="#"> in HTML.
getURL takes three parameters -- one required, two optional. They are:
1) The actual url you want to link to
2) method, for forms in flash
3) target frame
You only need to concern yourself with the first.
So, what you need to do is in the same loop that you parsed the first text file, you'll have to parse the URLs that you want to link to.
Then dynamically set the onRelease for each logo using the following function:
logo_mc.onRelease = function() {
getURL(linkURL);
}
where linkURL is a variable containing the URI string for that particular logo. This is something you have to create, it's not a system variable or anything.
erm, i abit confused at the moment, but i try learn as fast as i can while u guide mi along :)
logo_mc.onRelease = function() {
getURL(linkURL);
}
the following code i put it around the middle of the script where the parsing of the text file containing the name of the images right?
The "linkURL", do i for example write ("linkhttp://www.google.com") ?If i guess correctly isn`t the website written in the .fla instead of the text file.
someting i quite puzzled it that, when i try putting the getURL() code below
this code. when i open the list variables, the linking of the websites cannot be done( i know the reason), but why is that only the last pic of the marquee moving onli?
// mouse events
// clearInterval onRollOver
logos_mc.onRollOver = function() {
clearInterval(scroll_int);
trace("Stopping the marquee");
}
// re-setInterval onRollOut
logos_mc.onRollOut = function() {
scroll_int = setInterval(startScrolling, 15);
trace("Ok, start again.");
}
Medyman
04-16-2008, 04:40 PM
logo_mc.onRelease = function() {
getURL(http://www.google.com);
}
That would be the code if you wanted to link to Google. The reason I used a variable (linkURL) is because assigning a variable is an easier way to go than to create individual onRelease functions for each logo.
Using the code above (at top of this post), will link ALL of your logos to google. You want different URLs for each logo, so you need to bring them in from the text file (the same way you brought in the image paths).
I'm not sure what you mean by your last problem. If only the last MC is stopping/starting onRollOver, then you're probably setting those functions outside of the loop.
(You should beg your boss/instructor let you use XML, lol. Stupid text files).
k,thanks. so i try typing onRelease, getURL() around the last line of the following code
logoList.load("logo.txt");
Though i did try yesterday(half of the day trying putting it after the rollOver function & half the day trying to put it at the above code) , nothing realli works till yesterday. :(
putting it there, the whole marquee gone blank. omg
As for the begging part medy, eh lets see, i still gt 3 weeks to a month ( actual is 5wks) before i need to submit this project, but i still got a report & presentation slides to do, a weekly progression report using (dreamweaver or frontpage to do) . Dun think he let mi off so easy for the time being.Unless if he gives some hints or some solutions to it but he might want me to further improve the marquee:eek: ( which means HELP MEDYMAN, i gt another interesting* problem for u to help to solve!!! :D) lol
hey if anyone gt an idea, pls feel free to say , u can upload my marquee at http://www.mediafire.com/?ammfikzto12
Medyman
04-17-2008, 05:03 AM
Wow, that many weeks for this project? No wonder he's not letting you take the easy way out. :D
Ok, so I see that you're probably getting frustrated with my why don't you switch to XML responses. Don't blame ya. The truth is, I just haven't worked with .txt files/loadVars. Though, I should still know how to do the basics. I just haven't had reason to learn though.
See, text files are useful when you're creating dynamic blocks of text. They're not as useful for multiple data objects, like in this case. For a scrolling image panel, you *SHOULD* really be using XML. It's like if you had a car, why would you use a horse and buggy?
Now, with that said, this is how I would code this kind of thing (kind of). First the AS, then the explanation.
var images:Array = [];
var urls:Array = [];
var lv:LoadVars = new LoadVars();
var lv2:LoadVars = new LoadVars();
lv.onData = function(src:String) {
images = src.split("\r\n");
}
lv2.onData = function(src:String) {
urls = src.split("\r\n");
loadImages();
}
lv.load("images.txt");
lv2.load("urls.txt");
function loadImages() {
for (i=0;i<images.length-1;i++) {
duplicateMovieClip(logo, "logo"+i, i);
var logo:MovieClip = eval("logo" + i);
logo.id = i;
logo._x = i*126;
logo.thumb.loadMovie("images/"+images[i]);
logo.onRelease = function() {
trace(urls[this.id]);
}
}
}
Now, I didn't make it scroll because you have that part down. As a point of fact, you could slim down that scrolling function too, it's overly complicated for no real benefit.
My code uses two text files (this is how your sample was, so I kept it). It probably easier this way anyway, than getting too much into regex. Up till line 16 is a slimmed down version of what you already had. I've repeated it twice (once for each text file) -- with different variables, of course.
Next is the only function I used. Now, I got lazy here a little and used duplicateMovieClip instead of creating totally empty ones. One my stage I have one movieclip (size doesn't matter). That movieclip has an instance name of logo. Inside logo is another movieclip called thumb.
I chose to do it this way, because it gets to be a main to create MCs within MCs via actionscript and them tracking them all. You need to have two, because mouseEvents won't work with just one. I won't get into the technicals of why. I suspect you know about this because you were using the 2 mc technique before.
So anyway, I have that MC on the stage. Then I'm using duplicateMovieClip to duplicate it as many times as needed (based on how many entries are in the text file). I then set that MC equal to a variable (through the eval() method) so that I can perform actions with it. Next, I set an arbitrary id to the MC so that I can access the index within the onRelease function. Then, I set the width.
Lastly, I import the image/logo and set an onRelease event. As I said, you can't access the index of the for loop within the onRelease event, so that's why I set the id which is equal to the index.
In the code above, I used a trace (because it's really annoying testing with actual links popping up). Replace the trace with getURL and all should work.
Your task now, is to implement the scroll in all of this.
That was a pretty horrid explanation. Let me know what questions you have. I would post my example source but I have Flash CS3, so you won't be able to open it...sorry.
lol medy, wth you can complete the whole marquee in half the length (of even lesser) of wat i did. :eek:. actually i still searching if the way he wanted me to do, is that even possible :confused:. because, i be wondering, this program might be used by people who know nothing about flash. ( if they wan add stuff to the marquee, they just need to add the .jpg in the image folder, write the name down in the image,txt& url for the url.txt)
erm, (eval) what that? btw, i just need to copy & paste the whole as , copy & paste the image folder to the file i saving, change the .txt name inside the script to fit my txt right. okie, if i still on the right track.. :) erm some of the code you used quite similar to this site. lol
http://www.kirupa.com/developer/mx2004/external_array.htm
but when i run it, the whole screen become blank. Honestly, he gave me this project ( someone who stop mid-way, i continue from where it was so its quite erm complicated,) now the understanding is getting better, reading the reference book, while trying out :)
i change the "images"& "urls" names to my orginal name
lv.load("images.txt");
lv2.load("urls.txt");
Medyman
04-17-2008, 12:08 PM
lol medy, wth you can complete the whole marquee in half the length (of even lesser) of wat i did.
Well, it's not doing the same thing as you have. In your code, you have a lot checks for contingencies. I find them to be a bit overkill. Such as making sure the .jpg is lowercase and some other things. If it's a concern for you, then you might want to add those parts back in. If not, there is no point in bloated code.
The biggest thing as the loop to create the images. Waaay too much going on there. It's a lot simpler than that. You mention that you picked this up half way. I'm thinking now that whoever started the code might be new to Flash or something. 1) They chose text files and 2) the code is overlycomplicated (a true sign of someone learning, lol. god knows I've been guilty of it myself).
because, i be wondering, this program might be used by people who know nothing about flash. ( if they wan add stuff to the marquee, they just need to add the .jpg in the image folder, write the name down in the image,txt& url for the url.txt)
Yea, that's possible. That's what I just created. If you add a new image to the images folder, add the image name in images.txt and the url in url.txt than it should update more automatically.
Now, back to my praise for XML. If this is for someone else and you can't be sure of their technical skills. Then it'll be less headache with XML. The reason? With text files, whoever is using this will have to make sure that the images and urls are in order. Meaning, if the image is the 4th one in the list and they accidentally put the URL on the 5th line. That messes everything up. With XML, there is no such issue.
erm, (eval) what that?
A special trick ;). What the eval function does is allow you to access the properties of whatever you're evaluating through a variable. It acts like a psuedo-array. It's not really an array, but it acts like it. So, if I say eval("logo"+i), then within the variable I assign, it holds logo1, logo2, logo3, logo4 (how many ever the loop is creating). So, I can do things to ALL the logos with one line of code instead of (like your code does) loop through for each action.
some of the code you used quite similar to this site. lol
http://www.kirupa.com/developer/mx20...rnal_array.htm
Yeah, that might be a good resource for you too look at. It's doing the same thing essentially, except with PHP. My use of the variable lv is just a common naming convention (stands of loadVars), so if you see that elsewhere it doesn't necessarily mean in the same thing.
but when i run it, the whole screen become blank.
Did you add the clip to the stage as I described?
i change the "images"& "urls" names to my orginal name
Yup, that's all you need to do. Be careful that you don't change the variable names. You only need to change the lv.load and lv2.load statements. Not every instance of the work images and/or urls.
You wouldn't have access to Flash 8 by any chance, would you? If you did, I'd send you what I made. I can't create anything less than Flash 8.
lol medy, the fact is that my course of study is not programming, though i had learnt c++, c#, html for awhile in school.haha. the code i think lets just leave it for now( though it means u write for nothing, hope you dun curse mi :D ) but i still read it up & save a copy so as not to waste your time in writing ;)
Now, back to my praise for XML. If this is for someone else and you can't be sure of their technical skills. Then it'll be less headache with XML. The reason? With text files, whoever is using this will have to make sure that the images and urls are in order. Meaning, if the image is the 4th one in the list and they accidentally put the URL on the 5th line. That messes everything up. With XML, there is no such issue
well, before i left school todae, my teacher ask "so how the url" i told him,eh just the rollOver only the url is sooo hard, can i use xml den :D. well, he replied abit odd though, "no, kind of complicated" den mumble something to himself. god knows what he thinking of.
Did you add the clip to the stage as I described?
what clip??
You wouldn't have access to Flash 8 by any chance, would you? If you did, I'd send you what I made. I can't create anything less than Flash 8.
I would love to take a look at wat you have done on flash 8 that will be quite hard. though my school (IT side) did have flash 8, the department (enggineering) that i am under only have the version i using now(not the worst, 1 of my freind using flash mx) Though i learnt flash just for this project, i am slowly getting interested to this, the syntax sure look easier than c# for starter.
A last note for now, :( back to finding txt file to link. (our forum messages are getting longer by the day)
cheers.
ps: just looking our old posts, posted by rockonmetal, well i already did it all in javascript orginally, but the marquee when it scroll to the end will have a big gap(someting my teacher do not want to see) & the coding was like waaaay more diffucult than actionscript So that time, just to be safe, i go with flash, well another dead end for now( hope it wun stay that way for much longer)
Medyman
04-17-2008, 03:50 PM
This clip.
Next is the only function I used. Now, I got lazy here a little and used duplicateMovieClip instead of creating totally empty ones. One my stage I have one movieclip (size doesn't matter). That movieclip has an instance name of logo. Inside logo is another movieclip called thumb.
I chose to do it this way, because it gets to be a main to create MCs within MCs via actionscript and them tracking them all. You need to have two, because mouseEvents won't work with just one. I won't get into the technicals of why. I suspect you know about this because you were using the 2 mc technique before.
So anyway, I have that MC on the stage. Then I'm using duplicateMovieClip to duplicate it as many times as needed (based on how many entries are in the text file). I then set that MC equal to a variable (through the eval() method) so that I can perform actions with it. Next, I set an arbitrary id to the MC so that I can access the index within the onRelease function. Then, I set the width.
You're free to use the code that you have. Just know that it'll probably double in size to do the URL bit, if you can do it at all.
If I were you, I'd just start over. Use the bit I posted for the loadVars. Use this tutorial (http://gotoandlearn.com/player.php?id=25) for the loading. You'll finish in a few hours, instead of wasting more time trying to get a piece of code with some bad logic to work properly.
I know it feels awkward to abandon something you've been working on for so long, but you can seriously be done in one hour. And then spend the rest of your weeks making it better, adding more features etc...
You'll end up with a 10x better product and cleaner, more efficient code.
Sidenote: You've exhausted all the help that I can give on your current code. To be brutally honest, parts of it make me cringe at it's inefficiencies. And if you don't want to change it, than I'm going to say the same thing over and over again (swtich to XML, lol :D). I'm not saying this out of spite or anything...quite the contrary. Just I don't want to keep repeating myself.
hmm, i could start over after all. lol, but meaning i have to ask you about what each of your lines mean :D & i seems quite free* for now.So, its means i building the whole marquee from the ground with new improved version.
Thanks medyman.
when i run it returned error open
Error opening URL "file:///C|/DOCUME%7E1/hyk/LOCALS%7E1/Temp/images.txt"
Error opening URL "file:///C|/DOCUME%7E1/hyk/LOCALS%7E1/Temp/urls.txt"
just to be on the safe side, i changed my text files names to fill the script you written
One my stage I have one movieclip (size doesn't matter). That movieclip has an instance name of logo. Inside logo is another movieclip called thumb.
erm, medy you put pics in the stage? Did i told you, i done all the stuff just by writing in the actions frame, no using of timeline etc.
You'll end up with a 10x better product and cleaner, more efficient code.
better product i not too sure, but at least i`m sure it be clearer & cleaner.
(with guidence & help from you medyman) :D
Sidenote: You've exhausted all the help that I can give on your current code. To be brutally honest, parts of it make me cringe at it's inefficiencies. And if you don't want to change it, than I'm going to say the same thing over and over again (swtich to XML, lol ). I'm not saying this out of spite or anything...quite the contrary. Just I don't want to keep repeating myself.
lol, the cringe part actually i got same feelings, (some of the code i dun even know wat its it even used for i.e ( why the marquee need to have 2 for loops) ) as for changing to xml, its not i do not want to change, its just that its not under my control ( if xml, i might be done in a day & say hey teacher your marquee is done, what do you still wan me to do)
hey, the website you gave when i unzip through winrar had an error ( is the program removed) ?
ps: medyman loves xml but hates text files ( right?) :D
Medyman
04-18-2008, 03:00 AM
It's better to ask and learn than to work off someone else's code. This way you'll know it for later and understand it. So, if you need to edit it in the future, you're well prepared.
As for the clip on the timeline. As I said, I got lazy. You could do it via actionscript. I was just trying to show the basic technique so I didn't bother. It's only like 2 more lines of code, though. :D
It's not that I hate text files, either. They have their use. If you were making a website and there was an "About Me" section that needed to be dynamic, text files would be better. With XML you would need to deal with CDATA etc.. for that. A pain!
But when you have one instance that needs multiple data points, it's inefficient to go through multiple files. I mean, think about it. Wouldn't you rather just enter something like this:
<logo src="logo.jpg" url="http://www.google.com" />
I think that's more intuitive. Plus, the end-user doesn't have to open up two different files. I think there is a lot of room for error in that whole everything has to be in the same order bit.
As for your first line, by all means, ask away. I'm more than happy to answer questions, any questions. I just don't want to condone inefficient coding practices. I'm a standards nerd, I'll admit it :D
As for the clip on the timeline. As I said, I got lazy. You could do it via actionscript. I was just trying to show the basic technique so I didn't bother. It's only like 2 more lines of code, though.
so you mean i do not need to do anyting right? just copy & paste the code you gave onto the actions frame. I very sorry to ask such a beginner question :o , i think you know by now, i start from mid-way so i erm never tried doing a whole new flash document by myself, pls dun be shocked :p
hmm, the errors i post in the last juz* i was wondering what could have caused it( any suggestions)?
It's better to ask and learn than to work off someone else's code. This way you'll know it for later and understand it. So, if you need to edit it in the future, you're well prepared.
well i will spend the weekend studying the whole code properly, then i ask you if i want to clariy any doubts( provided i be able to complete it by todae)
Medyman
04-18-2008, 03:24 AM
1. No, you'll need to edit my code to get everything off of the timeline. I only add one clip, so it's not like EVERYTHING is on the timeline.
To get my code to work, do this:
1. Create a rectangle
2. Hit F8 & save the rectangle as a movieclip
3. Give it an instance name of "thumb"
4. Select it and hit F8 again
5. Save it as a movieclip
6. Give it an instance name of logo
That will get my code to work.
If you're starting over with my code as a basis, then I suggest you do it that way first. And then once you're comfortable with the code, create the moviclip dynamically.
The errors from you previous post tell me that you haven't saved your .fla. Save it in the same folder as are your text files.
Error opening URL "file:///D|/new/New%20source/urls.txt"
what does this means??
very sorry to ask again, :o. i save it in the folder as the text file, with images & url file. Erm, so drawing a rectangle is nothing right( since i never put effects etc) cos i need to do the whole marquee in as.
Don`t strangle me medyman. lol, though i can understand the reason if you realli did that :D
very sorry to ask again, :o. i save it in the folder as the text file, with images & url file. Erm, so drawing a rectangle is nothing right( since i never put effects etc) cos i need to do the whole marquee in as, & the program i using now do not have a rectangle.
Don`t strangle me medyman. lol, though i can understand the reason if you realli did that :D
After drawing it, i need to paste the whole code in action movieclip right?
Argh, he keep saying its very easy, since i could take the names from the text file, the URL will be using the same method
( the marquee was done with xml prevously like u suggested, but he say the stuff go mixed up in the xml, though i do not have a single idea what he was saying about)
Medyman
04-18-2008, 12:41 PM
lol. Stop saying that I'll strangle you. I'm not that violent, I promise. ;)
It's my fault for not explaining it correctly.
1. The clip on the stage is just a blank rectangle (you can make it whatever shape, color, dimension, it doesn't matter). It serves as a container to hold the logo image. We only need one on the stage. Then, through AS, we replicate it as many times as we need.
Again, I suggest you get the code working this way first. And then create that clip on the stage via AS. Otherwise, it gets complicated.
2. Once you have that clip created...Copy and paste my actionscript on a frame, not a movieclip. The actions should go on the timeline. So do this:
Create a new layer.
Rename it to actions and lock it.
Click on the first frame of that layer and paste in the AS.
If you still can't get, let me know. I'll see if I can track down someone with Flash 8 to convert my example to MX2004 for you.
okie, i read through your last 2 posts very carefully. :) erm, i might sounds like half hearted, but i feel my teacher is like giving a hint somewhere or somehow. since he say i could transfer the names then the URL should be fine (add some stuff in). anyway, i try your code 1st, if it is up& working i show him. If he is alright with it, then i can ask more guidence from you :p ( i still wondering why when i keep saying xml he kept on laughing) wth.
If you still can't get, let me know. I'll see if I can track down someone with Flash 8 to convert my example to MX2004 for you
Seriously, i very grateful for your help,i still have some way to go. you really go out of the way to help a newbie like me :D
Thanks alot
Medyman
04-20-2008, 03:39 AM
Guess what?
We just got a client that wants the same exact thing for this website. Our dev team wants to use text files because XML would be extra overhead to create with the CMS.
So, I made something almost identical to what you're looking for.
I asked someone to convert it to MX 2004. If they come through, I'll post it for you.
Guess what?
We just got a client that wants the same exact thing for this website. Our dev team wants to use text files because XML would be extra overhead to create with the CMS.
Oh realli? what a small world after all :). hey may i know why xml will be extra overhead? (though its abit unrelated)
So, I made something almost identical to what you're looking for.
I asked someone to convert it to MX 2004. If they come through, I'll post it for you.
Thanks in advance medy, i be looking forward for your good news & thanks again for the conversion. :D
ps: Pls help me thanks the person/s for the conversion. ;)
Medyman
04-21-2008, 01:14 PM
So, they came through. Here (http://www.mediafire.com/?c431r11kxje) is the file in MX2004. I zipped up my image sources and text files too, so you don't need to change anything to see it work. Hopefully it works, I can't test it but I assume it does.
Now let me first say that this only a proof of concept. It's not the finished product. There is still some optimizing to do. I could shave some more coding off and I probably will before we launch it.
You'll have to mouse over the intro graphic to initiate the clips. As you'll see the intro graphic is on the stage because there is no use in coding it dynamically. Sometimes just adding it to the stage is the smartest thing. I'm also using a preloader, so I have that in the library, but not on the stage.
You can get rid of both the preloader and the intro graphic and it will still work as intended (with some minor changes to the AS).
I tried to "comment" where I could. Let me know where you have questions.
As far as you other question...XML overhead. It's just the way our CMS is set up. XML would require a whole new template within the CMS to output it. A text file can be output-ed within what's already been done because it doesn't require any extra formatting. So the dev team made the decision to do it that way. With that said, an XML template wouldn't really be that much overhead. It doesn't really matter though. The end user won't be editing the text file or a XML document (if we were go to that route) manually, so no harm. In this application, text files are just as easy to plug in as XML files. If the end-user were editing the text files herself, there is no way I would use text files--I'd go with XML. It's just more intuitive.
Medyman
04-22-2008, 03:32 AM
So for now, it should be able to work nicely. right? If it can work nicely. i need to input the mouseover for the mouse, delete the stuff & introducation from the stage right?
eh medy, i open & test the program already, gt a few questions. the preloader is the mascots right? Then when i run it, the pictures did not show up(the only thing i saw were black images loading* and moving) & when i click the pics the output shows the website names
Hey..
No, the preloader isn't the mascots. The preloader is an animation that plays right after you you mouseover the mascots. It's a circle that spins.
I have it coded to just trace the URL when you click it. You have to replace the trace with a getURL for it to work.
If you want to remove the mascots and the preloader, just remove all the references to it. Then call the loadContainers() function in the onData event of the 2nd text file (lv2).
Also delete the _alpha statements in the main for loop. You should be good to go.
eh medy, do you mind changing the codes instead of just guiding me along?? I have some problems trying to understand what you are trying to tell me . :o Your comments are so hilarous :D But it gets to the point easily.
I have it coded to just trace the URL when you click it. You have to replace the trace with a getURL for it to work.
I can click to the websites already.
I love the animation very much :D very nicely done.
where the _alpha btw, is this the one??
symbol.alphaTo(100, .5, "easeOutQuad", delay);
1 more thing medy, can lv& lv2 vars be put in the same text file? If i not wrong i required to do it
var images:Array = []; // stores symbol image file names
var urls:Array = []; // stores associated website URIs
var lv:LoadVars = new LoadVars();
var lv2:LoadVars = new LoadVars();
lv.onData = function(src:String) {
images = src.split("\r\n");
}
lv2.onData = function(src:String) {
urls = src.split("\r\n");
}
lv.load("logos.txt");
lv2.load("urls.txt");
Medyman
04-22-2008, 07:41 PM
Hmm...
I'm a bit busy for the next couple days so I don't know about altering the code but this should make it work:
1) Delete everything on the stage.
2) Change
lv2.onData = function(src:String) {
urls = src.split("\r\n");
}
to
lv2.onData = function(src:String) {
urls = src.split("\r\n");
loadContainers();
}
That'll fix it.
You'll also want to delete these lines, but it's not necessary for it to work:
var loading:MovieClip = panel["symbol"+i]["thumb"].createEmptyMovieClip("loading", i);
// Oh, it's loading!? Why didn't you tell me. Attach the preloader animation
panel["symbol" +i]["thumb"]["loading"].attachMovie("loading", "loading", i);
If you notice, the images show up in order, seperated by .1 seconds. If you want to get rid of that. Delete
// Set _alpha properties to 0 so we can control when things are shown; looks more organized
panel["symbol"+i]._alpha = 0;
panel["symbol"+i]["thumb"]["image"]._alpha = 0;
Also, it is possible to make everything in one file. Experiment with the split() method.
Thanks alot, i go try out i was reading your codes to find out what does the "thumb" & "panel" used for. lol, there no use for it since you say i do not nid it :p
spilit() method, ok i go check it up. Thanks for the tip :D
1) Delete everything on the stage.
Eh, can i delete the layers visual&credits? is that the same thing as deleting the things on the stage?
Medyman
04-23-2008, 03:09 AM
Thanks alot, i go try out i was reading your codes to find out what does the "thumb" & "panel" used for. lol, there no use for it since you say i do not nid it :p
spilit() method, ok i go check it up. Thanks for the tip :D
Eh, can i delete the layers visual&credits? is that the same thing as deleting the things on the stage?
Yes, deleting the visuals layer is the same thing. The credits layer has nothing on it anyway, so that doesn't matter.
I'm a little confused by your first comment. The thumb and panel do a lot! The panel is the container clip. All of the logos are inside the panel movieclip. The scrolling function actually just movies the panel from left to right.
The thumb movieclip is the MC that the actual image loads in to.
:eek: I never once thought the panel& thumb will be SO important, thanks for enlightening me. Hmm, i read flash mx bible, but I dun realli see Panel & thumb while reading the part on movie clip. Are they classes or objects. :p
I'm a little confused by your first comment. The thumb and panel do a lot! The panel is the container clip. All of the logos are inside the panel movieclip. The scrolling function actually just movies the panel from left to right.
Medyman
04-23-2008, 03:54 AM
:eek: I never once thought the panel& thumb will be SO important, thanks for enlightening me. Hmm, i read flash mx bible, but I dun realli see Panel & thumb while reading the part on movie clip. Are they classes or objects. :p
Oh, I see why you were confused. They're not native Flash objects! They're movieclips I created using the createEmptyMovieClip() method. panel and thumb are instance names.
Panel is the container that holds all of the logos. To get the scroll, I use MC Tween to move the panel left and right.
Inside panel are a bunch of movieclips called symbol1, symbol2, symbol3, etc...
Inside the symbols there is the thumb movieclip. The image loads inside the thumb.
You can't load images into the symbol movieclip because once you load something into it, you basically overwrite it. So, mouse events won't register with it and we need it to link to a website.
oic, the marquee i had orginally had a createEmptyMovieClip() method . This part i understand. The mc_tween was what you told me to download. Yea get a much clearer understanding of the codes. and thanks for clearing the thumb& panel.
Eh medy, something is wrong somewhere. First, i deleted all the layers expect the "actions" layer. Secondly, I deleted the extra* code which u told mi to. When i run, nothing comes out( just to be safe, i also copy 1 url address to the logos.txt)
mascots.onRollOver = lightUp;
function lightUp() {
mascots.beibei.colorTo(0x4f96c4, .5, "easeOutQuad");
mascots.jingjing.colorTo(0x70c63d, .5, "easeOutQuad");
mascots.huanhuan.colorTo(0xff000e, .5, "easeOutQuad");
mascots.yingying.colorTo(0xfd7100, .5, "easeOutQuad");
mascots.nini.colorTo(0x008536, .5, "easeOutQuad");
mascots.blurTo(15,2,.5, "easeInOutQuad", .25);
mascots.alphaTo(0, .5, "linear", .25, function() {
loadContainers();
this.swapDepths(this._parent.getNextHighestDepth()); this.removeMovieClip();
The hightlight text was the one i deleted, since its was used for the mascots. :)
// Set _alpha properties to 0 panel["symbol"+i]._alpha = 0;
panel["symbol"+i]["thumb"]["image"]._alpha = 0;
why do i need to delete this line medyman? i thought this line is the postioning of the slider of the images???
I also goggle on stuff such as getBounds,roundedXSlideTo in case they might turn out to be as3 codes, but they can be used for as2. hmmm, strange very strange. Had the MC_tween2 installed too( is that an as3 code)? :p
My last qns for the day medy :D, just to check it out, i copy my files, text files etc into the the .fla & delete your logo text etc (in short exchanging*)
But when i run the program there is an error ( the only different i feel was my pics were in .jpg & yours were in gif)
Medyman
04-23-2008, 01:30 PM
oic, the marquee i had orginally had a createEmptyMovieClip() method . This part i understand. The mc_tween was what you told me to download. Yea get a much clearer understanding of the codes. and thanks for clearing the thumb& panel.
Yup, the createEmptyMovieClip() method is how you would create movieclips dynamically. There is also the duplicateMovieClip() method if you want to (obviously) duplicate it.
Eh medy, something is wrong somewhere. First, i deleted all the layers expect the "actions" layer. Secondly, I deleted the extra* code which u told mi to. When i run, nothing comes out( just to be safe, i also copy 1 url address to the logos.txt)
Did you add the loadContainer(); function call to the lv2.onData function?
why do i need to delete this line medyman? i thought this line is the postioning of the slider of the images???
You don't have to delete those lines. The alpha property controls the transpareny of a clip (from a 0 to 100). What I'm doing there is setting everything to be 100% transparent/clear. So, when it first loads, you can't see it. Then I tween(animate) the alpha property to 100 in the for loop by a seperation of 0.1 seconds. It's only for visual effects. It serves no functional purpose.
I also goggle on stuff such as getBounds,roundedXSlideTo in case they might turn out to be as3 codes, but they can be used for as2. hmmm, strange very strange. Had the MC_tween2 installed too( is that an as3 code)?
No, MC Tween is an AS2 extention. Zeh Fernando, the creator of MC Tween, also created the Tweener class, which is the AS3 equivalant. Tweener can also be used for AS2.
getBounds() is also an AS2 method. It's been around since at least Flash MX 2004 and Flash Player 5. Here (http://http://livedocs.adobe.com/flash/mx2004/main_7_2/wwhelp/wwhimpl/common/html/wwhelp.htm?context=Flash_MX_2004&file=00001502.html) are the MX 2004 docs for getBounds(). Basically, what getBounds() does is provide the coordinates for the boundaries of the movieclip.
I used getBounds() to simulate the onRollOver effect. Flash has a bug where you can't have nested mouse events. So you can't interact within a movieclip that has any mouse events. Since our panel movieclip has mouse events, you wouldn't be able to click on the logos if we didn't do it this way.
If you want a more visual explanation, you can check out the "Scrolling Thumbnail Panel" tutorial by Lee Brimelow at gotoandlearn.com. Be careful though! Some of the coding techniques are the same, but I am not using his code, so what he is using getBounds for is different than what I am. And how he animates his panel is different from how I do it. Don't get confused.
Lastly, roundedXSlideTo is a method of MC Tween. Here (http://http://hosted.zeh.com.br/mctween/doc_roundedbezierslideto.html) is the documentation for it. Again, very much AS2! MC Tween doesn't work in AS3.
i copy my files, text files etc into the the .fla & delete your logo text etc (in short exchanging*)
But when i run the program there is an error ( the only different i feel was my pics were in .jpg & yours were in gif)
Are you getting an actual error? Or is it just blank?
Make sure you add the loadContainers() function call to the lv2.onData event. If it still doesn't work. Paste your AS here, all of it.
okie medy, if i not mistaken its a error of my file, the opening of my image file
Mind i paste the error when i get back to school tomorrow? ya, i followed what u told me to do, will check over it again. ok, i update u again:D
The links etc, i taken a look already, (found it in google). I find it quite interesting, but when i try to write it. omg, nothing comes out. :o
oh, btw u told me to delete the _alpha right, when i delete the whole thing became blank. anyway, i go check out on it if there is still an error i paste it here
Medyman
04-23-2008, 01:59 PM
Mind i paste the error when i get back to school tomorrow
No! I want it now. lol :p
but when i try to write it. omg, nothing comes out.
Post the errors you get verbatim tomorrow and I'll see what's the problem. If you followed my instructions, then there shouldn't be any AS problems. So it might be either related to the file paths and/or the text files.
Medyman
04-23-2008, 02:01 PM
If you notice, the images show up in order, seperated by .1 seconds. If you want to get rid of that. Delete
// Set _alpha properties to 0 so we can control when things are shown; looks more organized
panel["symbol"+i]._alpha = 0;
panel["symbol"+i]["thumb"]["image"]._alpha = 0;
You don't have to delete them. But if you wanted to get rid of the effect, you do.
YES MEDY-SIR. that line i played with it just now, it controls the size & postion of the pics. :D
I do the checking & error pasting 1st thing tomorrow :p
Anymore you want me to take a look in? MEDY ;)
Medyman
04-23-2008, 04:29 PM
YES MEDY-SIR. that line i played with it just now, it controls the size & postion of the pics. :D
What line are you talking about?
// Set _alpha properties to 0 so we can control when things are shown; looks more organized
panel["symbol"+i]._alpha = 0;
panel["symbol"+i]["thumb"]["image"]._alpha = 0;
This 100% does not control either the size or the position. The size isn't set anywhere in the coding. And the position is the line with _x in it.
Some reading. (http://livedocs.adobe.com/flash/mx2004/main_7_2/wwhelp/wwhimpl/common/html/wwhelp.htm?context=Flash_MX_2004&file=00001485.html)
// Set _alpha properties to 0 so we can control when things are shown; looks more organized
panel["symbol"+i]._alpha = 0;
panel["symbol"+i]["thumb"]["image"]._alpha = 0;
Sorrie, i saw the wrong line medy :p. its the panel["symbol"+i]._x that controls the sizes. right?
Did you add the loadContainer(); function call to the lv2.onData function?
hmm at the beginning when i edit this line, it "works", the marquee is going over the mascots. As i was deleting other lines, well i only see the the mascots. Okie, the script is posted below.
#include "mc_tween2.as"
var images:Array = [];
var urls:Array = [];
var lv:LoadVars = new LoadVars();
var lv2:LoadVars = new LoadVars();
lv.onData = function(src:String) {
images = src.split("\r\n"); }
lv2.onData = function(src:String) {
urls = src.split("\r\n");
loadContainers( );
}
lv.load("logos.txt");
lv2.load("urls.txt");
mascots.onRollOver = lightUp;
function lightUp() {
mascots.beibei.colorTo(0x4f96c4, .5, "easeOutQuad");
mascots.jingjing.colorTo(0x70c63d, .5, "easeOutQuad");
mascots.huanhuan.colorTo(0xff000e, .5, "easeOutQuad");
mascots.yingying.colorTo(0xfd7100, .5, "easeOutQuad");
mascots.nini.colorTo(0x008536, .5, "easeOutQuad");
mascots.blurTo(15,2,.5, "easeInOutQuad", .25);
mascots.alphaTo(0, .5, "linear", .25, function() {
loadContainers();
this.swapDepths(this._parent.getNextHighestDepth());
this.removeMovieClip();
});
}
this.createEmptyMovieClip("panel", this.getNextHighestDepth());
var count:Number = 0;
function loadContainers() {
for(i=0;i<images.length-1;i++) {
var symbol:MovieClip = panel.createEmptyMovieClip("symbol"+i, i);
var thumb:MovieClip = panel["symbol"+i].createEmptyMovieClip("thumb", i);
var image:MovieClip = panel["symbol"+i]["thumb"].createEmptyMovieClip("image", 30+i);
// You can go here. Position each symbol
panel["symbol"+i]._x = 202*i
panel["symbol"+i]._y = Stage.height/4;
panel["symbol"+i].alphaTo(100, .25, "easeOutQuad", (.1*i));
// MovieClipLoader
var mcl:MovieClipLoader = new MovieClipLoader();
var mclL:Object = new Object();
mclL.onLoadComplete = function() {
count++;
if(count ==images.length-1) {
showThumbs();
}
}
mcl.loadClip("events/"+images[i], panel["symbol" +i]["thumb"]["image"]);
mcl.addListener(mclL);
panel["symbol"+i].id = i;
panel["symbol"+i].onRelease = function() {
getURL(urls[this.id]);
}
}
}
function showThumbs() {
for(i=0;i<images.length-1;i++) {
var symbol = panel["symbol"+i].thumb.image
var delay = (0.1*i)+.25
symbol.alphaTo(100, .5, "easeOutQuad", delay);
}
beginScroll();
}
function beginScroll() {
var limit = Stage.width - panel._width
var time = panel._width / 150;
if(panel._x <= limit) {
panel.roundedXSlideTo(0, time, "linear", .25, beginScroll);
}
else {
panel.roundedXSlideTo(limit, time, "linear", .25,beginScroll);
}
panel.onRollOver = pauseResume;
}
function pauseResume() {
delete this.onRollOver;
this.pauseTween("_x");
var x = panel.getBounds(_root);
this.onEnterFrame = function() {
if(_xmouse<x.xMin || _xmouse>x.xMax || _ymouse<x.yMin || _ymouse>x.yMax) {
this.resumeTween("_x");
this.onRollOver = pauseResume;
delete this.onEnterFrame;
}
}
}
i delete all the comments& hopefully never delete any codes, if you have a hard time reading it let me know, i edit my post again asap. Maybe i need to delete the .mascots codes too, to make the whole marquee works. :D
note: I only change the codes ( file names etc, i leave me as the same) & eh if you find any errors which i forgetten to edit, change etc feel free to say in BOLD
var mclL, what that? i thought that was only something called mcl but i never heard of mclL yet
Medyman
04-24-2008, 02:34 AM
Ok, there's nothing wrong with that code. There must be something wrong with either your file structure or your text files.
Here is a more cleaned up version (though what you posted should work). I get rid of the showThumbs function, the mascots mouse events, the alpha animations and my beautiful comments (why in the world would you want to get rid of them?) :( *sarcasm*
Make sure to delete the entire visuals layer. Nothing more, nothing less.
#include "mc_tween2.as"
var images:Array = [];
var urls:Array = [];
var lv:LoadVars = new LoadVars();
var lv2:LoadVars = new LoadVars();
lv.onData = function(src:String) {
images = src.split("\r\n");
}
lv2.onData = function(src:String) {
urls = src.split("\r\n");
loadContainers();
}
lv.load("logos.txt");
lv2.load("urls.txt");
this.createEmptyMovieClip("panel", this.getNextHighestDepth());
var count:Number = 0;
function loadContainers() {
for(i=0;i<images.length-1;i++) {
var symbol:MovieClip = panel.createEmptyMovieClip("symbol"+i, i);
var thumb:MovieClip = panel["symbol"+i].createEmptyMovieClip("thumb", i);
var image:MovieClip = panel["symbol"+i]["thumb"].createEmptyMovieClip("image", 30+i);
panel["symbol"+i]._x = 202*i
panel["symbol"+i]._y = Stage.height/4;
var mcl:MovieClipLoader = new MovieClipLoader();
var mclL:Object = new Object();
mclL.onLoadComplete = function() {
count++;
if(count ==images.length-1) {
beginScroll();
}
}
mcl.loadClip("events/"+images[i], panel["symbol" +i]["thumb"]["image"]);
mcl.addListener(mclL);
panel["symbol"+i].id = i;
panel["symbol"+i].onRelease = function() {
trace(urls[this.id]);
}
}
}
function beginScroll() {
var limit = Stage.width - panel._width
var time = panel._width / 150;
if(panel._x <= limit) {
panel.roundedXSlideTo(0, time, "linear", .25, beginScroll);
}
else {
panel.roundedXSlideTo(limit, time, "linear", .25, beginScroll);
}
panel.onRollOver = pauseResume;
}
function pauseResume() {
delete this.onRollOver;
this.pauseTween("_x");
var x = panel.getBounds(_root);
this.onEnterFrame = function() {
if(_xmouse<x.xMin || _xmouse>x.xMax || _ymouse<x.yMin || _ymouse>x.yMax) {
this.resumeTween("_x");
this.onRollOver = pauseResume;
delete this.onEnterFrame;
}
}
}
I've tested this. It does work. So, if you can't get this to work. The problem is 100% with your setup.
Sorrie, i saw the wrong line medy . its the panel["symbol"+i]._x that controls the sizes. right?
Nope. That like controls the _x position. You'll get it, eventually (i hope) :p
var mclL, what that? i thought that was only something called mcl but i never heard of mclL yet
Keep readin'! It'll come up. mcl is my variable for a MovieClipLoader object. It doesn't need to be called mcl, that's just what I used because that's what most texts use for examples and I didn't want to confuse you.
mclL is a MovieClipLoader Listener. With it, you can react to events like onLoadInit (when the actions on the first frame of an imported movieclip are executed) and onLoadComplete (when whatever your importing finishes loaded).
Sorrie medy, i only delete the comments when i post here, in the script i still keep it( its very valuable i can`t bear to delete it :D)
my beautiful comments (why in the world would you want to get rid of them?) *sarcasm*
I've tested this. It does work. So, if you can't get this to work. The problem is 100% with your setup.
OK, i make a new file flash doc then, throw the images etc etc etc into the new flash doc folder. And see how its goes. ( it should be okie provided i DUN mess up the stuff (as usual) Zzz. THANKS for the cleaning up, not sure how i going to return the favour :p
Keep readin'! It'll come up. mcl is my variable for a MovieClipLoader object. It doesn't need to be called mcl, that's just what I used because that's what most texts use for examples and I didn't want to confuse you.
mclL is a MovieClipLoader Listener. With it, you can react to events like onLoadInit (when the actions on the first frame of an imported movieclip are executed) and onLoadComplete (when whatever your importing finishes loaded).
Sorrie, eh i might be abit short on patience i suppose ( jump to conclusion VERY fast) :p hehe
Medyman
04-24-2008, 03:00 AM
i only delete the comments when i post here, in the script i still keep it( its very valuable i can`t bear to delete it :D)
That's right, how it should be :D.
I'm only kidding, of course. Take them out, shift them around, take out the credits too if you want. I only added them for (1) the sake of people that read this thread (yes, all 10+ pages) after your project is over and (2) for the sake of the people I asked to covert it. I didn't want them to think that I was trying to rip off someone else's work.
HURRAY, YES its okie already medy. Can i start a Q&A session ( okie medyman, I suppose you WILL scream & mayb add in some colourful* words ) erm at the afternoon i had some errors blah blah( same old story) . I change my images folder name to events & it works now. I suppose its regards to this line. how should i change it to images? :D
mcl.loadClip("events/"+images[i], panel["symbol" +i]["thumb"]["image"]);
Okie, if you stop screaming already gulp*, i shall continue.
1: the direction of the marquee ( need it to scroll in 1 direction without stopping )
Can i guess the solution, I suppose its related to mc_tween2 ( i need to go read up on the code at the website right?)
2: the urls file's content, how shall i merge it??
Oh ya, yesterday you called me to take a look at the split method,do you mind explaining why your code & the website is different ( but yours is shorter of course:D) Thanks!!!
http://www.bigroom.co.uk/blog/list-loader-for-actionscript-2
That's right, how it should be .
I'm only kidding, of course. Take them out, shift them around, take out the credits too if you want. I only added them for (1) the sake of people that read this thread (yes, all 10+ pages) after your project is over and (2) for the sake of the people I asked to covert it. I didn't want them to think that I was trying to rip off someone else's work.
If i completed the whole stuff, AND if i know which url is using it, i will post a new thread. ( erm, if i completed there will be a thread & an updated thread if i know which url is using it) PROMISE
(1) Sorrie to everyone in this forum, i took so much pages (10+ gulp*) without knowing it, & you guys who read it had to bear with my nonsense :o
(2) i will thanks those you put in the credits, but the biggest THANKS will go to you medyman :D
Medyman
04-24-2008, 01:57 PM
I change my images folder name to events & it works now. I suppose its regards to this line. how should i change it to images?
Ahh...I forgot to mention that in the configuration steps. Usually, I hold the image paths in a variable, so that's probably why. Anyway, you figured out which line this is on.
If you want to point to the "images" folder, just change it here:
mcl.loadClip("images/"+images[i], panel["symbol" +i]["thumb"]["image"]);
the direction of the marquee ( need it to scroll in 1 direction without stopping )
Can i guess the solution, I suppose its related to mc_tween2 ( i need to go read up on the code at the website right?)
No, that has nothing to do with MC Tween. You'll have to dive into some ActionScript for that. The easiest way, I think, would be use duplicateMovieClip() with the onTweenComplete method of MC Tween
the urls file's content, how shall i merge it?
You can do whatever you want. It doesn't really matter. The simplest would be to set up some sort of delimiter. So, perhaps something like:
image.jpg|http://www.website.com
*This isn't harder to comprehend than XML
h ya, yesterday you called me to take a look at the split method,do you mind explaining why your code & the website is different
It's almost the same thing. The code on the website just broke it down in to several conditionals. I don't check for variations of linebreaks as it's not really needed. Plus the code on the website is a OOP class, so the class syntax makes for more code.
Sorrie to everyone in this forum, i took so much pages (10+ gulp*) without knowing it, & you guys who read it had to bear with my nonsense
Oh, come on. I'm trying to for the longest thread about one issue record ;)
i will thanks those you put in the credits, but the biggest THANKS will go to you medyman
Huh? That is me in the credits. Believe it or not, my real name isn't Medyman. LOL
No, that has nothing to do with MC Tween. You'll have to dive into some ActionScript for that. The easiest way, I think, would be use duplicateMovieClip() with the onTweenComplete method of MC Tween
k sure, i go read on duplicateMovieClip() & onTweenComplete. got to really read the books for stuffs. few more weeks to submit :eek:
if(panel._x <= limit) {
panel.roundedXSlideTo(0, time, "linear", .25, beginScroll);
}
else {
panel.roundedXSlideTo(limit, time, "linear", .25, beginScroll);
}
panel.onRollOver = pauseResume;
}
eh, i delete the whole bunch of code?then insert the the dulicate etc?
image.jpg|http://www.website.com
oh, so i juz to do to the logo text file & it should works right? anymore adding of stuff as etc?
Oh, come on. I'm trying to for the longest thread about one issue record
what the number of pages you aiming for?:D I think i broke the record in the flash section :o
Huh? That is me in the credits. Believe it or not, my real name isn't Medyman. LOL
OH , you are in the credits, hmm i go check it out carefully & pm you your real name. I sure u not medyman in real life( only in this forum):)
Medyman
04-24-2008, 02:28 PM
k sure, i go read on duplicateMovieClip() & onTweenComplete. got to really read the books for stuffs. few more weeks to submit
That's plenty of time. You'll get it. And just think, you'll be a Flash scrolling panel master at the end of it.
eh, i delete the whole bunch of code?then insert the the duplicate etc?
Kind of, you'll have to restructure it. What you should do is create 2 panel movieclips at the beginning of the code. Then assign variables to each.
Next, do some conditionals and see when one is at the right edge of the stage. If it is, position the other one to the right of it and start tweening that one.
Get the rest of the stuff figured out (one text file) and do this at the end.
oh, so i juz to do to the logo text file & it should works right? anymore adding of stuff as etc?
No, no. Why would it be that easy? :D If you do that, your images array will be this:
images[0] = "image1.jpg|http://www.website1.com";
images[1] = "image2.jpg|http://www.website2.com";
images[2] = "image3.jpg|http://www.website3.com";
You'll need to further split that (using the split method) and separate it into two arrays -- one for the file names and one for URLs
what the number of pages you aiming for? I think i broke the record in the flash section
I don't know...lets see where it goes. ;)
You'll need to further split that (using the split method) and separate it into two arrays -- one for the file names and one for URLs
gulp* so at the start of the script, there the split method( i need to do changes to it?) I thought that was already being done? :confused:
well, going to read that in the weekends
I don't know...lets see where it goes.
well i hope it be less than 15 pages, 2 pages for the spliting & 3 for the moving :D
okie, i start by by putting the file names etc in the same text file. Hopefully i can do it faster & less errors. need to rush for reports etc:D
the moving part i leave it for later den :p
Medyman
04-24-2008, 03:31 PM
gulp* so at the start of the script, there the split method( i need to do changes to it?) I thought that was already being done?
The split is being doing. You still need that. But now, you need to split it further.
split("/r/n") splits it based on the line breaks. split("|") would split it based on the | delimiter. The easiest way would probably be to loop through the images array, split it, and then push use the Array.push method to construct the two alternate arrays.
Tip: First create a new .fla and try to get the arrays to work properly. Then try to merge it into the current one.
Medyman
04-24-2008, 03:54 PM
Try this:
Create a new .fla. Save it to the same directory as your text file. Paste the following AS in the actions panel.
var rawdata:Array = []; // stores all the raw data
var images:Array = []; // stores symbol image file names
var urls:Array = []; // stores associated website URIs
var lv:LoadVars = new LoadVars();
lv.onData = function(src:String) {
rawdata = src.split("\r\n"); // Seperates the raw data based on line breaks. Output image.jpg|http://www.website.co,
for(i=0;i<rawdata.length-1;i++) { // Loops through all of the raw data
info = rawdata[i].split("|"); // Seperates each array element by a delimiter (vertical bar). Resulting array: info[rawdata[i]] = (info[0], info[1]) or (image, uri)
images.push(info[0]); // "Pushes" the 0th value (the image path) to the images array for later access
urls.push(info[1]); // "Pushes" the 1st value to the urls array for later access
}
testMe(); // Gotta make sure it works, right?
}
function testMe() {
for(i=0;i<rawdata.length-1;i++) {
trace("Raw Data: " + rawdata[i]); // Rawdata -- as in the text file
trace("Image: " + images[i]); // Image path
trace("URI: " + urls[i]); // URI path
trace(""); // Line Break
}
}
lv.load("logos.txt");
This is only a test. You'll have to figure out how to plug it into your marquee. But it should give you enough ideas about how to go about it.
i just taken a peek. the beginning part is very familer. Okie, this is just the linking of the files right? I seeing some similarites between the old marquee & the new marquee.
This is only a test. You'll have to figure out how to plug it into your marquee. But it should give you enough ideas about how to go about it.
eh, don`t quite get what you saying? do you mean the directions or the linking of the data?:confused:
Oh ya, so should i use the one you gave yesterday & this is for practice :D
Medyman
04-24-2008, 05:38 PM
The new code isn't for the marquee. It's how you would parse all the data with one text file.
Change your logos.txt file to the following format:
images.jpg|http://www.website.com
and run the new code. You'll understand it.
the 1st line is storing the raw data( pics etc), the 2nd is storing the images names,3rd is the url list,the 4th line is
LoadVars object to obtain verification of successful data loading, progress indications, and stream data while it downloads( works the same way as xml)
the 5th line is display the data in the text file exactly in the file. ( qns1? i read from a site, it is using lv.onData = function(thetext:String), but you changed the thetext to src, why is that so?)
for the 6th line I not too sure how to explain :o The 7th line is a for loop, this command will loop through all the images in the folder the 1st pic starts from 0. the 8th line is split("|") meaning what kind of symbol etc you are
using to seperate the two or more datas. the 9th line is line is push the image untill later & 10 line is the same for url( qns2 for the image i get the idea , but why is the url having [1] instead of [0]?) line 11 is testme( the name of next function
so what name you going is put is al`right. line 12 is the function of testMe. line 13 (qns 3 i not too sure about that, mind explaining?)line 14 is similar to line 15 & 16. 14 is the pic arrangment in the image folder, 15 is the tracing of the logo names step by step
16 is the url blah blah. line 17 is trace the thing to separate the 2 datas (qns 4 why we can`t put "|" instead of "") FINALLY, line 18 is load all the stuff data etc from the text file
ps: sorrie to anyone who read the post :p.
correct me if i having any mistakes ( newbie in action ) :D
Medyman
04-25-2008, 02:18 AM
Whoa there. That's a lot. Why don't I explain it my way and then you can judge if you have more questions.
First, lets forget the testMe() function. That's only for testing purposes. It has nothing to do with understanding what's going on.
So, we're left with this:
var rawdata:Array = []; // stores all the raw data
var images:Array = []; // stores symbol image file names
var urls:Array = []; // stores associated website URIs
var lv:LoadVars = new LoadVars();
lv.onData = function(src:String) {
rawdata = src.split("\r\n"); // Seperates the raw data based on line breaks. Output image.jpg|http://www.website.co,
for(i=0;i<rawdata.length-1;i++) { // Loops through all of the raw data
info = rawdata[i].split("|"); // Seperates each array element by a delimiter (vertical bar). Resulting array: info[rawdata[i]] = (info[0], info[1]) or (image, uri)
images.push(info[0]); // "Pushes" the 0th value (the image path) to the images array for later access
urls.push(info[1]); // "Pushes" the 1st value to the urls array for later access
}
}
lv.load("logos.txt");
1. The Arrays
At the top of the AS, we set three variables which represent three arrays. An array is a simple way to hold multiple pieces of data and still have one reference point.
Here we have three arrays set: rawdata, images, and urls
The rawdata array contains the full string that we parse from text file (image.jpg|http://www.website.com). The images array contains only the image portion or the part before the delimiter (image.jpg). The urls array contains the values that come after the delimiter.
How we separate what's before and after the delimiter is coming up.
2. The loadVars
I think you get this part. It's what you've been doing all along. For the benefit of a full post, loadVars is the method used to "load" the "vars" or variables from an external source.
3. The onData event
The onData event fires when all of the data from the external source has been brought into Flash and is ready to be parsed.
You ask about an alternate syntax:
lv.onData = function(thetext:String)
lv and thetext are both user-set variables. They are not explicit AS syntax. So this:
popsicles.onData = function(bananas:String)
will work just as well (but tastier) than any other syntax for those portions.
4. Split the Linebreaks
When the onData event fires, Flash has the external data in the following format:
image.jpg1|www.website1.com
image.jpg2|www.website2.com
image.jpg3|www.website3.com
It's exactly as what's in the text file. We need to break this down into manageable bits so that we can work the rest of the application properly. First, let's get rid of the line breaks.
rawdata = src.split("\r\n");
This handy-dandy bit of code says take the source data (src, again this can be anything) and split it wherever you encounter \r\n (signify line breaks) and assign it to the variable array of rawdata. At the end of that method, we're left with data that looks like this:
rawdata = array("image.jpg1|www.website1.com", "image.jpg2|www.website2.com", "image.jpg3|www.website3.com");
Each line of our external .txt file is now one element in an array. We can access a specific array with using it's index. For example:
rawdata[0] would equal image.jpg1|www.website1.com
rawdata[1] would equal image.jpg2|www.website2.com
and so on...
Notice that the count starts at zero. This is important.
5. Split based on delimiter
Now that we have the line breaks out, we'll need to separate the raw data that we have into the two parts we need -- the images and urls. To do this, we use a simple for loop:
for(i=0;i<rawdata.length-1;i++) { // Loops through all of the raw data
info = rawdata[i].split("|"); // Seperates each array element by a delimiter (vertical bar). Resulting array: info[rawdata[i]] = (info[0], info[1]) or (image, uri)
images.push(info[0]); // "Pushes" the 0th value (the image path) to the images array for later access
urls.push(info[1]); // "Pushes" the 1st value to the urls array for later access
}
The for loop has the following conditions: it starts at 0 (because remember, arrays start at 0) and it's going to perform as many loops as there are elements in the raw data array minus 1. Again, because the array count starts at 0 but the loop counter starts at 1, we need to account for this and subtract one from the rawdata.length value.
So let's split it:
info = rawdata[i].split("|");
By now you should be familiar with the split. This code is saying split the rawdata element where we encounter the "|" character. So it takes image.jpg|http://www.website.com and splits it into image.jpg and http://www.website.com.
Remember that since this is in a for loop, we're only dealing with one element at a time. So, it performs this action on the first line of the text file, then on the second line, the on the third line. It's not all at the same time.
6. Array Push
As I explained earlier, we can access specific array values by using an index. When the first line is split based on the delimiter, the result is this:
info = array("image1.jpg", "http://www.website1.com");
So, to access the image we would say info[0] and to access the website, we would say info[1].
Ok, we have the values, that should be it, right?
Not quite... Since we're doing this in a loop, each loop wipes the info array clean and inserts a new value.
So if at the end of everything you were to test for the values of info[0] and info[1] were it would show you the value of the last line in the text file. Why? Because it has looped through them all and the last value is just what's left.
So...to fix for this, what we need to do is maintain a separate array to hold these values. We already set these arrays up in the first three lines.
So, we use the array.push() method. array.push() bascially takes whatever value you feed to the function and adds it to the end of the array in question.
images.push(info[0]);
urls.push(info[1]);
The first line adds the image names to the images array. The second adds the url paths to the urls array.
That was long...sorry if it's confusing but it seemed like you were getting confused with the traces and everything so I thought I'd go over it again.
Sorrie medyman, I was just trying to understand it in my terms. So i just wrote it down & erm let you check if i was on the wrong side(oh i was indeed wrong in some parts). That nothing wrong with your explaination though its quite long ( thanks for trying to make it more digestable) :D
oh,the traces i seriously thought its was used to track down stuff, though I know what the purpose of it in actionscript. my mistake :o
lol, sorrie for making write you the whole stuff like an entire tutorial.
Hey i have a request to make, if you don`t mind, lol. Could i continue posting erm my noob-ish terms, if i`m wrong in my understanding, you could erm correct me. sounds more like a plea than a request. haha. Of course you can disagree, you are rather busy of late, so you might not have time to go through all of it :)
This sounds veri noob-ish since i working with it for 2 months now .I just to ask what the colors in the as means Well here goes, the Array is a command, the black words is the variables etc,
Thanks :D
Medyman
04-25-2008, 12:14 PM
Well those colors can be customized. I changed mine a while ago and I can't remember what the default ones were. But they're only for ease of reading code. It has no functional value.
If you do some searches for "syntax highlighting", you might come up with more info.
About your first request/plea, lol, go right ahead. Just, if you're going to do things line-by-line like that, it'll be easier for me to follow along and answer your questions if you:
1) Put in a line break between each line's explanation.
2) Bold the questions you would like answers to.
About your first request/plea, lol, go right ahead. Just, if you're going to do things line-by-line like that, it'll be easier for me to follow along and answer your questions if you:
1) Put in a line break between each line's explanation.
2) Blog the questions you would like answers to.
ok, thanks alot ( you one step closer to getting the longest thread in this forum ;) )
hey, the tutorial you wrote is talking about the split() method & how to use it right etc? lol, its so detailed that i print a copy to read :D
i learning step1( how to use split () method to make flash communicate with the 2 variables in the text files ( url &jpg). 2nd step( the moving direction & speed of the marquee ) step3 ( the rollOver, think we gone through that few weeks back)
Just checking it out, I trying to add more content in my report:p Look kinda of bare now.
Medyman
04-26-2008, 03:29 PM
ok, thanks alot ( you one step closer to getting the longest thread in this forum ;) )
hey, the tutorial you wrote is talking about the split() method & how to use it right etc? lol, its so detailed that i print a copy to read :D
i learning step1( how to use split () method to make flash communicate with the 2 variables in the text files ( url &jpg). 2nd step( the moving direction & speed of the marquee ) step3 ( the rollOver, think we gone through that few weeks back)
Just checking it out, I trying to add more content in my report:p Look kinda of bare now.
I wonder what actually is the longest thread, lol.
Anyway, yes I covered the split in my write up. I'm not sure if you're familiar with PHP. But if you are, the split() method is the same thing as the explode() function.
Don't know if that helps you any.
eh, i don`t anything about php. :confused: The only thing i know about web development stuff is eh, html,xml & ya flash :D
Medyman
04-26-2008, 06:46 PM
eh, i don`t anything about php. :confused: The only thing i know about web development stuff is eh, html,xml & ya flash :D
Oh...well, even if you don't. It's not hard to pick up.
It basically takes a string and splits it into an array based on the delimiter.
i sort of get the idea. oh btw, so for now right the split method is able to read the url& images variables right? ( i feel like running round & round the same circle). I never tried out in school yet. sorrie if you are repeating your sentence
If i right for this part, then just to check out something if i just write
something.push
will the program read another variable or even more stuff? (provided its in the data is in the same text file?
Medyman
04-26-2008, 07:08 PM
Yes, as I explained in my long paragraph, the new code parses the images and urls from one text file.
Think of the split() function as something that breaks larger pieces of data in smaller ones. First we split() the entire text file into individual lines. Then, we split the individual lines into images and urls.
Remember, each line in the text files is set up like this: images.jpg|http://www.website.com
The array.push() has nothing to do with reading a value from an array. It writes to the array.
If I have an array like this:
fruits = array("apple", "orange", "grape");
and I do this:
fruits.push("banana");
It will add banana to the end of the fruits array. So you'll get.
fruits = array("apple", "orange", "grape", "banana");
So, back to the marquee example. Once the for loop completes, all of the images and the URLs will be in their separate arrays because of this method.
I hope that makes sense.
sure, getting clearing abit. I orginally thought the split must be used to split 2 things then with another variable another split. ok, thanks alot for clearing my doubt :D
Using the example on the code u gave ( long but veri detailed tutorial, u provided if i want to add in more stuff, at the start i put.
var bananas //declare variables
...
....
banana. push(info[2]) push......
if more stuffs just keep adding it in the script & also the text file right? :)
Medyman
04-26-2008, 07:46 PM
Why do you need to add more variables?
Are you adding more information to the marquee? Like a caption or something? You're really abusing text files, then. XML would make this so much easier.
Anyway, I won't go down that same line of rhetoric again.
If you want to add more information, you would have to format your text file like so:
images.jpg|http://www.website.com|the text you want to appear
The AS, would then be:
var rawdata:Array = []; // stores all the raw data
var images:Array = []; // stores symbol image file names
var urls:Array = []; // stores associated website URIs
var captions:Array = []; // stores captions associated with the thumbnails
var lv:LoadVars = new LoadVars();
lv.onData = function(src:String) {
rawdata = src.split("\r\n"); // Seperates the raw data based on line breaks. Output image.jpg|http://www.website.co,
for(i=0;i<rawdata.length-1;i++) { // Loops through all of the raw data
info = rawdata[i].split("|"); // Seperates each array element by a delimiter (vertical bar). Resulting array: info[rawdata[i]] = (info[0], info[1]) or (image, uri)
images.push(info[0]); // "Pushes" the 0th value (the image path) to the images array for later access
urls.push(info[1]); // "Pushes" the 1st value to the urls array for later access
captions.push(info[2]) // "Pushes" the 2nd value to the captions array
}
}
lv.load("logos.txt");
The highlighted bits are the changes. I just used the "captions" as an example. If you want to call it "bananas", that works too.
Sorrie medy, its completed unrelated to my project :p. I just curious that all if i realli understand this part anot. Seens that i understand the split part already
I go work on it when i in school tomorow (doing the text file etc) :D
Thanks alot :)
Medyman
04-27-2008, 01:26 PM
Sorrie medy, its completed unrelated to my project :p. I just curious that all if i realli understand this part anot. Seens that i understand the split part already)
Ahh, gotcha. No harm in learning. I was just wondering what your plan was for it.
I'm glad you get the split() method now. :D
Eh, i better post my script down. when i run it nothing happens. ?? I might have left out something or another. I go check it again :p Let me just comfirm some stuff, if you don`t mind
rawdata is the images* folder
images is the images name
url is url names
the logo text is a txt file of both images & url? :D
#include "mc_tween2.as"
var rawdata:Array = []; // stores all the raw data
var images:Array = []; // stores symbol image file names
var urls:Array = []; // stores associated website URLs
var lv:LoadVars = new LoadVars();
lv.onData = function(src:String)
{
rawdata = src.split("\r\n"); // Seperates the raw data based on line breaks. Output image.jpg|http://www.website.co,
for(i=0;i<rawdata.length-1;i++) { // Loops through all of the raw data
info = rawdata[i].split("|"); // Seperates each array element by a delimiter (vertical bar). Resulting array: info[rawdata[i]] = (info[0], info[1]) or (image, uri)
images.push(info[0]); // "Pushes" the 0th value (the image path) to the images array for later access
urls.push(info[1]); // "Pushes" the 1st value to the urls array for later access
}
}
lv.load("logos.txt");
Medyman
04-28-2008, 01:56 AM
Nothing is supposed to happen. That code is to only parse the data, not to display it.
That is why I had all those traces in there before, if you'll remember. If you want to see what the output would be, place that testMe() function back in.
Again, it's only for testing -- so you actually get some results and can confirm that it's working. You won't need any of that in your marquee code.
Also, just to confirm. Make sure logos.txt is in the same directory as the .fla.
That is why I had all those traces in there before, if you'll remember. If you want to see what the output would be, place that testMe() function back in.
Again, it's only for testing -- so you actually get some results and can confirm that it's working. You won't need any of that in your marquee code.
Also, just to confirm. Make sure logos.txt is in the same directory as the .fla.
oh okie, Its just for testing if the things is correct etc(troubleshooting) logos.txt I used it for putting the URL & images names right?
Medyman
04-28-2008, 02:27 AM
oh okie, Its just for testing if the things is correct etc(troubleshooting) logos.txt I used it for putting the URL & images names right?
Yup, exactly.
ahh i get it just tried inserting a link with a image, well its works. :D thanks
Right so i put all the url into the images folder immediately. How should i move on frm parsing to display? :o
lol, never thought the traces can be useful as a troubleshoot/debugging techinquie. interesting :)
Medyman
04-28-2008, 02:58 AM
lol, never thought the traces can be useful as a troubleshoot/debugging techinquie. interesting :)
That's basically their main purpose, lol. Traces only output to the "Output" panel in the Flash IDE, so there is not much more use for them.
As far as integrating...
take a look at the initial marquee AS, remove all references to lv2 (the 2nd text file's loadvars).
Then you want to use the variables in the for loop. Look at the testMe() function for an idea of what the variable names might be.
Remember the trace technique. If you're not sure that it's working. Throw the value into a trace function and see what's really happening.
Post the code you're working with if you run into any problems.
erm ya, doing that now. just finish transfering the urls. thought you went offline, your bulb* went off :D
Oh i did not put the traces but in the testMe(), I put it loadContainers since there is a loadContainers below the function
oh ya, just a qns to ask too, the "symbol"& panel do i need to change their names? some of the vars I`m sure i need to changes their names for example "image" to "images" :) Oh, i just post half of it, if you want the whole chunk i edit the post( restore your commments back to their former glory :p) Befor you starting cursing me(which i hope you won`t :D) I personally suspect its the problem with symbols* & thumbs* & panel* )since they were in the orginal script
var rawdata:Array = []; // stores all the raw data
var images:Array = []; // stores symbol image file names
var urls:Array = []; // stores associated website URLs
var lv:LoadVars = new LoadVars();
lv.onData = function(src:String) {
rawdata = src.split("\r\n"); // Seperates the raw data based on line breaks. Output image.jpg|http://www.website.co,
for(i=0;i<rawdata.length-1;i++) { // Loops through all of the raw data
info = rawdata[i].split("|"); // Seperates each array element by a delimiter (vertical bar). Resulting array: info[rawdata[i]] = (info[0], info[1]) or (image, uri)
images.push(info[0]); // "Pushes" the 0th value (the image path) to the images array for later access
urls.push(info[1]); // "Pushes" the 1st value to the urls array for later access
}
loadContainers();
}
this.createEmptyMovieClip("panel", this.getNextHighestDepth());
var count:Number = 0;
function loadContainers() {
for(i=0;i<images.length-1;i++) {
var symbol:MovieClip = panel.createEmptyMovieClip("symbol"+i, i);
var thumb:MovieClip = panel["symbol"+i].createEmptyMovieClip("thumb", i);
var image:MovieClip = panel["symbol"+i]["thumb"].createEmptyMovieClip("image",30+ i);
panel["symbol"+i]._x = 150*i //gap between the images
panel["symbol"+i]._y = Stage.height/4; // height of the marquee
var mcl:MovieClipLoader = new MovieClipLoader();
var mclL:Object = new Object();
mclL.onLoadComplete = function() {
count++;
if(count ==images.length-1) {
beginScroll();
}
}
mcl.loadClip("rawdata/"+images[i], panel["symbol" +i]["thumb"]["images"]);
mcl.addListener(mclL);
panel["symbol"+i].id = i;
panel["symbol"+i].onRelease = function() {
getURL(urls[this.id]);
}
}
}
Medyman
04-28-2008, 12:56 PM
I'll take a closer look at the changes you made in a few hours when I'm a bit freer.
But...
You don't need to change any variable names. The "image" variable refers to something totally different than the "images" variable. Maybe it's confusing because the names I used are so similar, but that's my own coding convention -- it make sense to me.
"images" refers to an array that contains all of the filenames
"image" refers to a single element within that array
You shouldn't have to change anything in the for loop. Just the loadVars part needs to be changed.
Quickly, I see you changed this line:
mcl.loadClip("rawdata/"+images[i], panel["symbol" +i]["thumb"]["images"]);
That's probably what's causing the error. The highlighted part is the relative path to the image from the flash movie. images[i] is being sent from the text file (this part should word fine). The "rawdata/" is the folder that the images lie in. It's not a variable. So if you changed your folder name to rawdata, that's different. Otherwise, it needs to be images/ or logos/ or w/e it's called.
Anything within double quotes is a literal string, not a variable.
Again the only changes you need to make are to the lv.onData event, which looks like you did right.
By the way, this is the perfect place to insert some traces and see what was working and what's not. You would probably find that the movie clip is created but the images aren't loading, which means your path is off.
i assumed i do not need to put traces since the above part is okie, :(
I learnt a lesson which programming does not teach ( Do not assume, )
the rawdata was wrong? at the beginning, its was events( from the file you uploaded) So i assume* its should be changed
k thanks, you go do your stuffs 1st, I looking through it too
I thought some stuff of the name you uploaded was different from the tutorial you wrote? hmm, nvm i could check it out tomorow :)
Medyman
04-28-2008, 03:25 PM
i assumed i do not need to put traces since the above part is okie
It's ok the way I wrote it. But if you're changing variables, adding traces to make sure that you changed them correctly is an easy way to diagnose the problem
the rawdata was wrong? at the beginning, its was events( from the file you uploaded) So i assume* its should be changed
It should be changed, but to the name of the directory that the images are in. Your folder was called images before. If it's the same you want to the string to be "images/" not "rawdata/". The only way "rawdata/" would work is if you renamed the directory to rawdata.
You don't need to change any variable names. The only thing you need to change are the lv.load() statement to match your text file's filename and the string ("rawdata/") in the loadClip statement to direct to your images directory. That's it.
With that said, you can change the variable names if you want to. As long as you change all instances of the variable name, it doesn't matter. But chances are that you might miss one or two of those instances and the code won't work. So, it's better to leave them be unless you have a good reason to change them.
my orginally image folder(became rawdata) so you mean i put everything back to normal 1st? I edited if there any probs i check with u again. I re-read your last post again tomorow. Thanks for the tip :)
Medyman
04-28-2008, 10:27 PM
my orginally image folder(became rawdata) so you mean i put everything back to normal 1st? I edited if there any probs i check with u again. I re-read your last post again tomorow. Thanks for the tip :)
So the folder with your logos in it is called rawdata? If so, then the code should work. I suspect you're misunderstanding me though.
I'm talking about the actual directory that the images are in. If the folder is called images, you would put images there not rawdata.
Back to HTML...
<img src="images/logo.jpg">
The highlighted part is what that string is...the folder path.
Does that make it clear?
OMG, I forgot the most important of them all when i look through it. the textfile which stores all the names & urls. As for the tracing part, I did it. well everything is al`right now(included the editing of the variables)
mcl.loadClip("rawdata/"+images[i], panel["symbol" +i]["thumb"]["images"]);
the rawdata* name is depending on what name i put (file which stores all the pics) right?
}
testMe();
}
function testMe() {
for(i=0;i<rawdata.length-1;i++) {
trace("Raw Data: " + rawdata[i]); // Rawdata -- as in the text file
trace("Image: " + images[i]); // Image path
trace("URL; " + urls[i]); // URL path
trace(""); // Line Break
}
}
When i replace the testMe(hightlighted) to loadContainers() & deleting all the traces, they gave errors such as error opening URl
what is the error about? ( I copy the folder onto desktop which gave this error)
"file:///C|/Documents%20and%20Settings/hyk/Desktop/New%20Folder/rawdata/ACE.jpg
So the folder with your logos in it is called rawdata? If so, then the code should work. I suspect you're misunderstanding me though.
Ok, so the name of the file ( storing all the pics ) is called rawdata. I`m right about this
I abit confused about this part , folder with your logos &actual directory that the images are in.
there should only be 2 files which is not flash in the folder where i storing all the things included fla & swf ( the textfile to store the names of the URLS & xxx.jpg, a folder where all the images is a.ka rawdata)
Eh, why is there html? :confused:
Medyman
04-29-2008, 02:14 AM
Ok...let's clear up this confusion.
Now, what I'm about to ask you to do has nothing to do with the marquee. So, don't get confused by it.
Let's say you were creating a regular HTML page, for example's sake. Now, how would you add the ACE.jpg logo? What would your code be?
<img src="..." >
What would you add in place of the highlighted part above?
Note: The HTML file would be in the same exact place as your .swf is now.
< img src= "Ace.jpg">
btw, sidetrack abit. if you going to change your actionscript colors, go edit-->perferences-->actionscript
Medyman
04-29-2008, 02:32 AM
Ok...now do this
Create a folder. Call it logos. Put all of your logos (the images) in it.
Now, open the flash file.
Change:
mcl.loadClip("rawdata/"+images[i], panel["symbol" +i]["thumb"]["images"]);
to this:
mcl.loadClip("logos/"+images[i], panel["symbol" +i]["thumb"]["images"]);
Now, do you get what I mean by what folder your images are in?
As for the colors...
I don't really use the Flash IDE for coding, so it's not worth changing. And like I said before, they're only for ease of reading. I don't pay much attention to them. They're great for catching spelling mistakes though.
i suppose i know what you trying to say. the rawdata is used (storing of images), so do (logos). :) So, you telling me what name stands for what right?
In that case, since the pics i taking from this logos* folder, i need to change all rawdata to logos right in the script
Medyman
04-29-2008, 02:47 AM
Kind of...
What I orignally had as the "events/" string should be changed to "logos/" if you're taking images from the logos folder.
The rawdata array is just that...an array. It's a variable set inside the script. It has NOTHING to do with what you name the actual image files or the text file.
Does that make sense?
I think you're overcomplicating things. That string that I'm telling you to change is just the image path, so that flash knows where to look for the images. It's not referring to a variable, an object...nothing.
Back to my HTML example
<img src="logos/ACE.jpg">
What I'm telling you to change is the equivalant in Flash. The source path. That's it. It doesn't have anything to do with the rawdata array.
The rawdata array is just that...an array.
is that what you mean, i leave it alone then? var rawdata:Array = []; // stores all the raw data
I go change all the rawdata to logos right away
Medyman
04-29-2008, 03:02 AM
is that what you mean, i leave it alone then? var rawdata:Array = []; // stores all the raw data
I go change all the rawdata to logos right away
No...that's not what I mean.
Don't change it!
One more time...
the only 2 things that you need to change are:
1. The name of the text file in
lv.load(file.txt)
2. The image path in
mcl.loadClip("rawdata/"+images[i], panel["symbol" +i]["thumb"]["images"]);
That's it. Those two things. Nothing more, nothing less.
If you're still confused. Go back to my original .fla that I posted for you. Remember how I had events/ in there? Look at the .zip file. There was an events folder with my images inside. That's what the events was referring to. The folder. I think you confused yourself by changing it to rawdata.
was thinking to do that while reading your tutorials. maybe i change too much stuffs yesterday leading to a big mess-up.
okie, i going to use the fla you send. change the 2 lines you send & the split type. Hopefully, don`t mess up again :p
Medyman
04-29-2008, 03:13 AM
was thinking to do that while reading your tutorials. maybe i change too much stuffs yesterday leading to a big mess-up.
okie, i going to use the fla you send. change the 2 lines you send & the split type. Hopefully, don`t mess up again :p
Good idea.
Go back to what I originally had. And do things step-by-step.
1. Replace the path to the images (replace events/ with the name of your folder...originally it was images/ it might now be logos/)
2. Replace the name of the text files (BOTH) with yours.
Test it...if it works, move on. Otherwise post back and I'll troubleshoot with you.
3. Take out the lv2 stuff (lv2.load, lv2.onData, var lv2)
4. Insert the new functions that I showed you. You have this done perfectly now.
Test it...if it works, great! If not, post your code and we'll work through it.
i copy the edited one ( the one you removed the mascots) & add in the split method that we dicussed yesterday. I change the events/ to rawdata & the textfile to logos.txt.
Use the traces & the results are like the one below, just show you an example
Raw Data: ACE.jpg
|http://www.acetechbiometric.com/
Image: ACE.jpg
URL; http://www.acetechbiometric.com/
I do all the tasks that you told me to do right? :D
Medyman
04-29-2008, 03:31 AM
Yes, it's working perfectly now.
Now just call loadContainers() instead of testMe()
delete the testMe() function
and you should be all set.
OMG, its the 2nd time today. Argh ,HELP!!! :(
Error opening URL "file:///C|/Documents%20and%20Settings/hoyk/Desktop/New%20Folder/rawdata/Xbio.jpg
}
loadContainers();
}
ACE.jpg |http://www.ace.com
btw, not sure if this help you ,I put it like that in my textfile.( though i don`t think its related at all)
Medyman
04-29-2008, 11:57 AM
You're still not understanding the image path! It's the FOLDER'S NAME. It doesn't refer to a variable.
Do this:
Create a HTML file that is in the same place as your .fla. Add this code:
<html>
<head>
<title>What's my image's path?</title>
</head>
<body>
<img src="rawdata/ACE.jpg">
</body>
</html>
Open the HTML in a browser. Do you see an image? I'm guessing not. Because the image path is wrong! Adjust the <img> tag so that the image shows up on the HTML page. Once it works, post the correct <img> tag back here and I'll tell you what to insert into the image path.
Maybe i was wrong ??? Sorrie in advance Medyman... & sorrie for the caps locks:p
I go try out tomorow, the program is in school
Okie, so u telling me to do in notepad, save it as html & save it in the same file directory as the marquee, once its works( figure out what the correct name of the images* folders for GOODNESS SAKE post it back ) right?
Once it works, post the correct <img> tag back here and I'll tell you what to insert into the image path.
Medyman
04-29-2008, 12:07 PM
Okie, so u telling me to do in notepad, save it as html & save it in the same file directory as the marquee, once its works( figure out what the correct name of the images* folders for GOODNESS SAKE post it back ) right?
Yes, that's exactly what I'm telling you.
Okie, I try make it right this time when i in school ( i abit backwards on my timetable:mad:) my bad. Being having a spinning head the whole day looking at where in the wrong is my mistake:p
Eh medyman, Its works perfectly, I did not change anyting , just copy & save the whole stuff I took a screenshot for your reference :) I did not see the title* though
<img src="rawdata/ACE.jpg">
Medyman
04-30-2008, 01:26 AM
Title? What title?
So...the marquee works now? There shouldn't be any problems. I can't see the image you attached, but it kind of looks like you actually did name your folder to rawdata.
You might want to change that to something that makes more sense (like logo) but regardless...the AS should work as you have it now, w/o any changes.
ya, i think i better re-copy the as again, hopefully its works. though we still haven`t found out what the error :D
You might want to change that to something that makes more sense (like logo)
you mean the images* folder? ya, that a good idea. I update you again
1. The name of the text file in
Code:
lv.load(file.txt)2. The image path in
Code:
mcl.loadClip("rawdata/"+images[i], panel["symbol" +i]["thumb"]["images"]);That's it. Those two things. Nothing more, nothing less.
I did as you say in the last few posts, just change these 2 lines, (image folder known as logo) as you suggested. tracing was done,perfect can see all those stuffs, where they are & what http:. After that,i remove all the traces & change the testMe(); to loadContainers(); , last but not least, did the html (the path location to image) Any wrong till now. The same errors appears :D
#include "mc_tween2.as"
var rawdata:Array = []; // stores all the raw data
var images:Array = []; // stores symbol image file names
var urls:Array = []; // stores associated website URIs
var lv:LoadVars = new LoadVars();
lv.onData = function(src:String) {
rawdata = src.split("\r\n"); // Seperates the raw data based on line breaks. Output image.jpg|http://www.website.co,
for(i=0;i<rawdata.length-1;i++) { // Loops through all of the raw data
info = rawdata[i].split("|"); // Seperates each array element by a delimiter (vertical bar). Resulting array: info[rawdata[i]] = (info[0], info[1]) or (image, uri)
images.push(info[0]); // "Pushes" the 0th value (the image path) to the images array for later access
urls.push(info[1]); // "Pushes" the 1st value to the urls array for later access
}
loadContainers(); // Gotta make sure it works, right?
}
lv.load("logos.txt");
this.createEmptyMovieClip("panel", this.getNextHighestDepth());
var count:Number = 0;
function loadContainers() {
for(i=0;i<images.length-1;i++) {
var symbol:MovieClip = panel.createEmptyMovieClip("symbol"+i, i);
var thumb:MovieClip = panel["symbol"+i].createEmptyMovieClip("thumb", i);
var image:MovieClip = panel["symbol"+i]["thumb"].createEmptyMovieClip("image", 30+i);
panel["symbol"+i]._x = 202*i
panel["symbol"+i]._y = Stage.height/4;
var mcl:MovieClipLoader = new MovieClipLoader();
var mclL:Object = new Object();
mclL.onLoadComplete = function() {
count++;
if(count ==images.length-1) {
beginScroll();
}
}
mcl.loadClip("logo/"+images[i], panel["symbol" +i]["thumb"]["image"]);
mcl.addListener(mclL);
panel["symbol"+i].id = i;
panel["symbol"+i].onRelease = function() {
getURL(urls[this.id]);
}
}
}
function beginScroll() {
var limit = Stage.width - panel._width
var time = panel._width / 150;
if(panel._x <= limit) {
panel.roundedXSlideTo(0, time, "linear", .25, beginScroll);
}
else {
panel.roundedXSlideTo(limit, time, "linear", .25, beginScroll);
}
panel.onRollOver = pauseResume;
}
function pauseResume() {
delete this.onRollOver;
this.pauseTween("_x");
var x = panel.getBounds(_root);
this.onEnterFrame = function() {
if(_xmouse<x.xMin || _xmouse>x.xMax || _ymouse<x.yMin || _ymouse>x.yMax) {
this.resumeTween("_x");
this.onRollOver = pauseResume;
delete this.onEnterFrame;
}
}
}
Medyman
04-30-2008, 01:03 PM
Hmm...I can't spot the error. I'm still not convinced it's not due to your setup.
Do one thing....zip up all of your project files (including text files and images) and post it online (mediafire.com is a good option). I'll take a closer look to see what's exactly going on there.
Hey medyman, just a qns to ask. Its regarding the tweened animations. is mc_tween more widely used because its uses more less file space than other methods related to it?
Medyman
05-02-2008, 02:47 AM
Hey medyman, just a qns to ask. Its regarding the tweened animations. is mc_tween more widely used because its uses more less file space than other methods related to it?
What other methods are you talking about?
If you're talking about just this marquee and why I used MC Tween instead of the way you originally had it, it has to do with ease of coding. With MC Tween it's only 1 line of code. If I remember correctly, you had a few functions doing the same thing.
MC Tween (and now the Tweener class) are such powerful classes. There isn't any file size benefit. If you were to use Flash's native Tween class, you would still need to import the same amount of code (approx.) but it's much more complicated syntax.
So, the biggest plus of MC Tween...
it's powerful and it's easy to implement (relative to the other tweening engines).
Does that answer your question?
:Di see. Thanks. I was just google around regarding flash. There are a few sites talking about optimising flash stuffs & one was about using mc_tween instead of inserting keyframes , its for my understanding basically :)
If you're talking about just this marquee and why I used MC Tween instead of the way you originally had it, it has to do with ease of coding. With MC Tween it's only 1 line of code. If I remember correctly, you had a few functions doing the same thing.
regarding the old code, i still don`t understand till today why he/she use 2 for loops & some of the codes was well repeating
Sorrie another qns i from that site i read, it says its best not to use eval.
ps: i think you gt say it somewhere be4 & eval was used the old codes, its just basically just for my understanding, hope you don`t mind
Medyman
05-02-2008, 03:15 AM
Ahh, I see...
Yes, using MC Tween will effect size if you're tweening on the timeline, adding keyframes etc. Using actionscript over timeline stuff will always save file space. So, that rule isn't just about MC Tween, it's about ALL actionscript. Now, using ActionScript does take more of a tool on system resources as it's running. Timeline tweening, takes longer to load at the beggining.
So, each have their pros and cons. Each method has its place. For example, if you're making a simple button with an over and out state. It makes no sense to code that with actionscript. That's more trouble and code than it's work. But if you're making a marquee, as you are, it's way too complicated to do it on the timeline (and kind of amateur, too).
As far as the eval...
It really depends on the situation. What eval() does is bascially replicate a small subset of the Array class. So using arrays are a lot more powerful. But for the purpose that I used them, I don't need the full Array class. I suppose the technically correct way is to use arrays, but eval() works just fine. I don't know of any disadvantages to using it in the context that I used it in.
If you wanted to use arrays, you would use the array.push method to create another array. And would have to create another function to loop through the movieclips within the array and apply the onRollOver and onRollOut states as well load the movieclips. Bascially what I have now, just split into two functions. I find that to be more complicated and my end goal with all my code is to follow the KISS (Keep It Simple Stupid) rule.
hi medyman here the link. btw, just remind you. remember to change the mc_tween since you are using flash 8:D
http://www.mediafire.com/?zi1tsy296np
thanks alot for helping me take a look:)
Medyman
05-02-2008, 03:57 PM
MC Tween works with Flash 8. The only thing that varies from one version of flash to the next are components.
Since MC Tween is written in AS2, it works for all versions of Flash that support AS2 -- including CS3. If you wanted to use AS3, it wouldn't work. For AS3, Zeh Fernando has written the Tweener class. Tweener also works for AS2, btw.
Anyway to your movie...
As I assume, you're not setting it up correctly. You didn't follow my instructions on setting up the text file. You can't have random spaces in there.
This:
ACE.jpg | http://www.acetechbiometric.com/
ArtVision.jpg | http://www.artivision.com.sg
Cisco.jpg | http://www.cisco.com
Decod.jpg | http://www.decod.com.sg
needs to be:
ACE.jpg|http://www.acetechbiometric.com/
ArtVision.jpg|http://www.artivision.com.sg
Cisco.jpg|http://www.cisco.com
Decod.jpg|http://www.decod.com.sg
No spaces as I've shown in all my examples. Fix this and the movie will work.
Also, increase your frame rate. At 12, it looks horrible. Something like 20 or even 30 would be much smoother.
I don't recommend this but if you want the text file to look "prettier" and want to add a specific number of spaces or tabs before and after the delimiter, we can code for that. But it will need to be the exact same. If you use one tab, it will always have to be one tab...not 5 spaces that are the same distance as a tab. Again, don't recommend this approach. It's far too easy to make a mistake.
Since MC Tween is written in AS2, it works for all versions of Flash that support AS2 -- including CS3. If you wanted to use AS3, it wouldn't work. For AS3, Zeh Fernando has written the Tweener class. Tweener also works for AS2, btw.
Oh, no wonder when i use my friend flash 8 to open the file, there the mc_tween error
I don't recommend this but if you want the text file to look "prettier" and want to add a specific number of spaces or tabs before and after the delimiter, we can code for that. But it will need to be the exact same. If you use one tab, it will always have to be one tab...not 5 spaces that are the same distance as a tab. Again, don't recommend this approach. It's far too easy to make a mistake.
my bad stunts :p, i was thinking of making it more 'presentable' instead of squeezing all together never expected it to be such a big bad error,my bad sorrie. could i make a guess, if i going to have the spaces (using the split method again, delimiter etc?), its not a must(understanding only) Okie, i go work on it. nxt week we will be doing the moving direction :D
i went to the mc_tween website to read up on the directions etc stuff, i'm not too sure about some of your lines there.
Medyman
05-02-2008, 06:08 PM
Oh, no wonder when i use my friend flash 8 to open the file, there the mc_tween error
Hmm...Again, MC Tween works with Flash 8! The error is probably because your friend doesn't have MC Tween installed. He has to go to the website and download the extension.
could i make a guess, if i going to have the spaces (using the split method again, delimiter etc?)
Exactly! You would change this line.
info = rawdata[i].split("|");
Right now we have the vertical bar as the delimiter. If you had a tab before and after it would be "\t|\t". But as I said, there are way too many changes for mistakes here. Maybe go back at the end and make this change. It's best to not have too many variables when getting an application to work at first.
i'm not too sure about some of your lines there
Which lines? Ask away...
ReadyToLearn
05-02-2008, 10:50 PM
Hi,
I don't mean to crash this thread but i'm just wondering if this technique would work with timed changes instead of scrolling. Meaning if it could go to next image every hour instead of scrolling all images at once.
Thanks
Medyman
05-02-2008, 11:51 PM
ReadyToLearn...
Please create another thread for your question. I don't want to create confusion here. I've already confused poor hyk enough :p
OMG, its my 100 posts on a topic :eek:
Please create another thread for your question. I don't want to create confusion here. I've already confused poor hyk enough
lol, no medyman its me who been confusing you :o ah i see, its \t, i thought if i did it as "gap between the double quotes" it shoulds work, lol :D. thanks.
Its regarding the slideTo. but oh well, yours moving & mine is slightly different. So do i need to change all of it(maybe half since i don`t want the marquee to move from right to left) the function is called startScrolling if i not wrong
The last part is the mousing stuff, but lets talk about the scrolling 1st. the mouse i just do not understand the code. I thought there was a simpler version which you wrote?
Medyman
05-03-2008, 05:05 PM
Its regarding the slideTo. but oh well, yours moving & mine is slightly different. So do i need to change all of it(maybe half since i don`t want the marquee to move from right to left) the function is called startScrolling if i not wrong
I don't understand what you mean 100% here. But going from what you've said earlier, I think you want continous motion, right? To accomplish that, you'll have to change the setup quite significantly.
The way something like that is done is that you create two identical movieclips (in your case it would be 2 copies of the "panel" movieclip). Then you would test to see where the movieclips are. If one of the movieclips are off the screen, you would movie to the extreme right.
It's hard to explain. I'll post a visual example of what I mean in a little bit.
ReadyToLearn
05-03-2008, 05:27 PM
Ok Medyman.
I will create a new thread later. I want to get the basics first and then will post about the rest.
Ok?
lol medyman, you understand me the best :D. oh, so i need to change the whole scrolling code. I thought i could at least keep the first part(sliding from left to right)
It's hard to explain. I'll post a visual example of what I mean in a little bit.
I guess you are afraid of what happened to the split method, my bad. :D Take your time, i in no rush you quite busy yourself :o
Medyman
05-03-2008, 09:01 PM
:D...
It actually is really hard to explain. And yes, I don't want to confuse you with a sub par explanation, so here (http://www.visualbinary.net/files/tutorials/continuous-motion/) is a visual.
Each image represents a "panel" movieclip. I aded a black background so you could see what's happening. When an image moves off the stage, it gets added to the back again. This creates a neverending animation. Of course in the final version, this effect would happen offstage so you wouldn't see it. I used smaller images so that you can actually see it working. Also, I used three "panels" because they were smaller. The effect would have been difficult to understand if there were only two images switching places. You would create only two.
I haven't used MC Tween in this example. The reason? It gets way too complicated because you need to specify end positions with MC Tween. That is you need to say move this movieclip to position 0 on the stage in 2 seconds. We can determine these values but it will take a lot of unnecessary math. To keep everything consistent, it's much easier to use a consistent method to tween them.
So what I've used is a simple technique. I believe this is somewhat similar to what you used in your original code. I use an onEnterFrame() event to decrease the _x position of the movieclips by 2. An onEnterFrame() event is fired once per frame. In my example, my framerate is 40. So I'm moving the movieclip to the left by 80 pixels a second. You can adjust this accordingly.
I've included the Flash 8 and Flash CS3 source files. You said you have a friend with Flash 8. Perhaps you can get him to convert it to MX 2004 format for you. If not, I'm including the ActionScript below. Paste it into a new .fla and hit Ctrl+Enter to test. Again, this is only an example. You will need to use only parts of it in your marquee, not all. The ActionScript is fully dynamic -- no need for anything on the stage/library.
If you use this technique, it means that you will need to apply the mouse events and load the logos into both movie clips. I showed someone how to apply the same functions to two movieclips at the same time in this thread (http://www.dynamicdrive.com/forums/showthread.php?t=31468#post139430).
So, here the actionscript:
// Author: Vishal Arora
// Website: vishalarora.com, visualbinary.net
// Creation Date: 3 May 2008
// License: Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported (http://creativecommons.org/licenses/by-nc-sa/3.0/)
// Images by Joni Karanka (www.jonikaranka.com). All rights reserved.
// Structure
// Create containers for images
this.createEmptyMovieClip("panel1", this.getNextHighestDepth());
this.createEmptyMovieClip("panel2", this.getNextHighestDepth());
this.createEmptyMovieClip("panel3", this.getNextHighestDepth());
// Load in images for example purposes
panel1.loadMovie("http://www.visualbinary.net/files/tutorials/continuous-motion/images/4.jpg");
panel2.loadMovie("http://www.visualbinary.net/files/tutorials/continuous-motion/images/3.jpg");
panel3.loadMovie("http://www.visualbinary.net/files/tutorials/continuous-motion/images/2.jpg");
// Position the panel movieclips
// 450px is the width of the images I choose to use
panel2._x = 450;
panel3._x = 900;
// Start scrolling right away
this.onEnterFrame = Scroll;
// Functionality
// Workhorse function -- ScrollI()
function Scroll() {
panel1._x = panel1._x - 2; // move panel1 to the left by 2px
panel2._x = panel2._x - 2; // move panel2 to the left by 2px
panel3._x = panel3._x - 2; // move panel2 to the left by 2px
if (panel1._x == -450) { // if panel1 is off the screen, move it to the end of the queue
panel1._x = 900;
}
if (panel2._x == -450) { // if panel2 is off the screen, move it to the end of the queue
panel2._x = 900;
}
if (panel3._x == -450) { // if panel3 is off the screen, move it to the end of the queue
panel3._x = 900;
}
}
I haven't used MC Tween in this example. The reason? It gets way too complicated because you need to specify end positions with MC Tween. That is you need to say move this movieclip to position 0 on the stage in 2 seconds. We can determine these values but it will take a lot of unnecessary math. To keep everything consistent, it's much easier to use a consistent method to tween them.
Is that why at the beginning, the marquee will pause for a sec then start moving& it did not start at the 0 position at the start(using the 1st* orginal code you provided as example?
You will need to use only parts of it in your marquee, not all. The ActionScript is fully dynamic -- no need for anything on the stage/library.
My guess is that i need to delete the whole chuck from the loadContainers() function till the rollOver part. Wow, you sure took alot of time calculating the distance :p btw, i don`t think i need to keep the panel.loadMovie for the marquee right(expect for tutorials purposes) ?
I could understand the 1st two paragraphs. After that its all the maths, need to play with the numbers :D
Medyman
05-04-2008, 02:52 PM
Is that why at the beginning, the marquee will pause for a sec then start moving& it did not start at the 0 position at the start(using the 1st* orginal code you provided as example?
Which code are you talking about? The one with MC Tween or the one I posted in my last post?
With the MC Tween one, the object was somewhat different, so the technique was different. I would jut forget about it and focus on this new one so as to not get confused. They are both valid methods for two valid situations. In this one, it's easier and simpler to use an onEnterFrame event.
My guess is that i need to delete the whole chuck from the loadContainers() function till the rollOver part
Not quite. The loadContainers() function builds the logos within the panel movieclip. That can stay as is. You'll need to edit the startScrolling() function -- actually remove it and substitute the above.
Wow, you sure took alot of time calculating the distance
Actually, not really. My images were 450 in length. So when the image is 100% off the stage, the _x position is equal to negative the width. The 900 comes from 450x2 (because you want to place it after the 2 images that are on the stage).
The reason I hardcoded the values is because I was calling the onEnterFrame right away -- as soon as the movie loaded. At that moment, the containers (panel1, panel2, panel3) have a width of 0 because the loadMovie hasn't finished loading the image yet. In your marquee, you will probably want to wait until everything has loaded and then tell the scrolling to start. If you do this, you can use -panel._width instead of hardcoding. This will make it even more dynamic making it easy for you to add/remove logos to the movie via the text files without having to edit the Flash.
Let me know if you have any troubles integrating this technique into your marquee.
btw, i still haven done the textfile thing. :D anw, so i run the code you wrote, get an idea on how its works& work out how am i going to implement it, if i having problems i get back to you:p. do i need to take away the mc_tween? since you say its 2 different techniques
Medyman
05-05-2008, 01:36 AM
btw, i still haven done the textfile thing. :D anw, so i run the code you wrote, get an idea on how its works& work out how am i going to implement it, if i having problems i get back to you:p. do i need to take away the mc_tween? since you say its 2 different techniques
By "take away the mc_tween" do you mean delete this statement:
#include "mc_tween2.as"
I think you safely can. Delete it and if you get an error, add it back in. I originally used MC Tween for some alpha tweens in the original version but I think we've removed them in subsequent versions.
Medyman
05-05-2008, 01:43 AM
Based on the last file that you sent me the highlighted below is what you would have to remove/replace with the technique I showed in my last example.
#include "mc_tween2.as"
var rawdata:Array = []; // stores all the raw data
var images:Array = []; // stores symbol image file names
var urls:Array = []; // stores associated website URIs
var lv:LoadVars = new LoadVars();
lv.onData = function(src:String) {
rawdata = src.split("\r\n"); // Seperates the raw data based on line breaks. Output image.jpg|http://www.website.co,
for(i=0;i<rawdata.length-1;i++) { // Loops through all of the raw data
info = rawdata[i].split("|"); // Seperates each array element by a delimiter (vertical bar). Resulting array: info[rawdata[i]] = (info[0], info[1]) or (image, uri)
images.push(info[0]); // "Pushes" the 0th value (the image path) to the images array for later access
urls.push(info[1]); // "Pushes" the 1st value to the urls array for later access
}
loadContainers();
}
lv.load("logos.txt");
this.createEmptyMovieClip("panel", this.getNextHighestDepth());
var count:Number = 0;
function loadContainers() {
for(i=0;i<images.length-1;i++) {
var symbol:MovieClip = panel.createEmptyMovieClip("symbol"+i, i);
var thumb:MovieClip = panel["symbol"+i].createEmptyMovieClip("thumb", i);
var image:MovieClip = panel["symbol"+i]["thumb"].createEmptyMovieClip("image", 30+i);
panel["symbol"+i]._x = 202*i
panel["symbol"+i]._y = Stage.height/4;
var mcl:MovieClipLoader = new MovieClipLoader();
var mclL:Object = new Object();
mclL.onLoadComplete = function() {
count++;
if(count ==images.length-1) {
beginScroll();
}
}
mcl.loadClip("rawdata/"+images[i], panel["symbol" +i]["thumb"]["image"]);
mcl.addListener(mclL);
panel["symbol"+i].id = i;
panel["symbol"+i].onRelease = function() {
getURL(urls[this.id]);
}
}
}
function beginScroll() {
var limit = Stage.width - panel._width
var time = panel._width / 150;
if(panel._x <= limit) {
panel.roundedXSlideTo(0, time, "linear", .25, beginScroll);
}
else {
panel.roundedXSlideTo(limit, time, "linear", .25, beginScroll);
}
panel.onRollOver = pauseResume;
}
function pauseResume() {
delete this.onRollOver;
this.pauseTween("_x");
var x = panel.getBounds(_root);
this.onEnterFrame = function() {
if(_xmouse<x.xMin || _xmouse>x.xMax || _ymouse<x.yMin || _ymouse>x.yMax) {
this.resumeTween("_x");
this.onRollOver = pauseResume;
delete this.onEnterFrame;
}
}
}
You would need to create another panel, simliar to this code (but with a different instance name:
this.createEmptyMovieClip("panel", this.getNextHighestDepth());
Then follow the technique that I linked to earlier (from the other thread).
thanks medyman, you gave me a CLEAN version:D oh well, the function beginScrolling was deleted which was expected(replaced with the code you gave in previous post).
this.createEmptyMovieClip("panel", this.getNextHighestDepth());
regarding this, you mean i need to add another line of this? since there is already 1 line of it after the logo.txt.instance name, do you mean if there is 2 panel, so panel & panel1? looking from your example
Medyman
05-05-2008, 01:51 PM
regarding this, you mean i need to add another line of this? since there is already 1 line of it after the logo.txt.instance name, do you mean if there is 2 panel, so panel & panel1? looking from your example
Yup, exactly.
Like so:
this.createEmptyMovieClip("panel1", this.getNextHighestDepth());
this.createEmptyMovieClip("panel2", this.getNextHighestDepth());
The names don't matter as long as they're consistent. You can call them panel and panel1, if you wish.
eh medyman, some problems cropped up. the textfile still won`t work. i edited like you told me to:(, another thing is i could not run your tutorial( i just need to copy& paste the as & save it right?)
lastly i change & replace the code, could you please see if i miss out any parts? :D
Medyman
05-06-2008, 02:19 AM
some problems cropped up. the textfile still won`t work
Try changing
this.createEmptyMovieClip("panel1", this.getNextHighestDepth());
this.createEmptyMovieClip("panel2", this.getNextHighestDepth());
to
this.createEmptyMovieClip("panel", this.getNextHighestDepth());
this.createEmptyMovieClip("panel2", this.getNextHighestDepth());
Does it work now?
another thing is i could not run your tutorial( i just need to copy& paste the as & save it right?)
Yup. Are you getting any errors? or is it just not loading?
Erm, i need to have around 5/6 pics at the start of the marquee.( something like the very old version which i first send you ) So do i add in more & some of the extra stuffs?
No...remember that the panel movieclip contains all of your logos. So, you only need to duplicate it once to create the effect.
Remember what I said about looping through both panels. You still haven't added that. When I get some time, I'll write a little example of what I mean. I'm not doing a good job explaining here.
Before i posted, i tried changing but there was the error opening URL (i also tried panel1 & panel2). anyways just to be on the safe side, i retype all in "L" (l)since they look very similar to "1" (one) in the fla but i still having the errors.
i just kinda of getting anxious about my marquee, not sure if i can complete on time& i had not see it "alive" for a few weeks :(
another thing is i could not run your tutorial( i just need to copy& paste the as & save it right?)
Yup. Are you getting any errors? or is it just not loading?
hmm strange, medyman did you do something to it? sometimes i could run the marquee & sometimes it does not load. When i exit swf, the flash will be quite laggy.
No...remember that the panel movieclip contains all of your logos. So, you only need to duplicate it once to create the effect.
I wrote a line after doing some reading.if its funny pls do not laugh, lol. Is there a need to put _root? what the difference between duplicateMovieClip & MovieClip.duplicateMovieClip? I went to livedocs & the outputs look the same to me
for(i=0;i<images.length-1;i++)
panel.duplicateMovieClip("panel"+i,this.getNextHighestDepth());
// insert this line at the for loop
one last thing, i edited the code which i post just now with panel & panel2
var rawdata:Array = []; // stores all the raw data
var images:Array = []; // stores symbol image file names
var urls:Array = []; // stores associated website URLS
var lv:LoadVars = new LoadVars();
lv.onData = function(src:String) {
rawdata = src.split("\r\n"); // Seperates the raw data based on line breaks. Output image.jpg|http://www.website.com
for(i=0;i<rawdata.length-1;i++) { // Loops through all of the raw data
info = rawdata[i].split("|"); // Seperates each array element by a delimiter (vertical bar). Resulting array: info[rawdata[i]] = (info[0], info[1]) or (image, uri)
images.push(info[0]); // "Pushes" the 0th value (the image path) to the images array for later access
urls.push(info[1]); // "Pushes" the 1st value to the urls array for later access
}
loadContainers();
}
lv.load("logos.txt");
this.createEmptyMovieClip("panel", this.getNextHighestDepth());
this.createEmptyMovieClip("panel2", this.getNextHighestDepth());
var count:Number = 0;
function loadContainers() {
for(i=0;i<images.length-1;i++) {
var symbol:MovieClip = panel.createEmptyMovieClip("symbol"+i, i);
var thumb:MovieClip = panel["symbol"+i].createEmptyMovieClip("thumb", i);
var image:MovieClip = panel["symbol"+i]["thumb"].createEmptyMovieClip("image", 30+i);
panel["symbol"+i]._x = 202*i
panel["symbol"+i]._y = Stage.height/4;
var mcl:MovieClipLoader = new MovieClipLoader();
var mclL:Object = new Object();
mclL.onLoadComplete = function() {
count++;
if(count ==images.length-1) {
}
}
mcl.loadClip("logos/"+images[i], panel["symbol" +i]["thumb"]["image"]);
mcl.addListener(mclL);
panel["symbol"+i].id = i;
panel["symbol"+i].onRelease = function() {
getURL(urls[this.id]);
}
}
}
// Position the panel movieclips
// 450px is the width of the images I choose to use
panel._x = 450;
panel2._x = 900;
// Start scrolling right away
this.onEnterFrame = Scroll;
// Functionality
// Workhorse function -- ScrollI()
function Scroll() {
panel._x = panel._x - 2; // move panel1 to the left by 2px
panel2._x = panel2._x - 2; // move panel2 to the left by 2px
if (panel._x == -450) { // if panel1 is off the screen, move it to the end of the queue
panel._x = 900;
}
if (panel2._x == -450) { // if panel2 is off the screen, move it to the end of the queue
panel2._x = 900;
}
}
Medyman
05-06-2008, 04:40 PM
Ok, I undestood none of that. I think your major problem is that you're taking my examples too literally. The examples I'm giving are designed to be just plug and play into the marquee. You have to learn that logic and apply it. You should be disecting my actionscript, understanding what it does and then apply it to the marquee yourself with what you've learned.
Also, you're overthinking it. What will help you greatly I think is to make an outline of what should be happening. Working in the abstract can get really confusing. So take out some pen/paper and create a little diagram of what should be happening to the marquee.
Trust me when I say that if you understand the examples I posted, you can get the marquee to work. I have a working example on my computer exactly as you probably want it. I could paste the code here but that would be doing you a disservice.
lso, you're overthinking it. What will help you greatly I think is to make an outline of what should be happening. Working in the abstract can get really confusing. So take out some pen/paper and create a little diagram of what should be happening to the marquee.
Medyman, do you mean i followed the whole as step by step& draw a diagram on what is going to happen ?
Trust me when I say that if you understand the examples I posted, you can get the marquee to work. I have a working example on my computer exactly as you probably want it. I could paste the code here but that would be doing you a disservice.
eh, so how my understanding so far, is that very bad? . If you gave me the whole stuff now, it means these many pages of writing were for nothing:D
i think my previous post was extremely long, i am having trouble reading myself too. :o Sorrie
Medyman
05-06-2008, 05:29 PM
:D
I mean if you write down what you would like to happen, just conceptually -- no AS involved. It will help clear your head of thoughts.
Believe it or not, you're done most of it. It's like 10 minutes of work left for you to get it like what you need.
What I'm confused about is where you are now. You should have a working marquee. What should be left to do is create the continous motion. That's it.
I provided an example on how to do that. So let me know how I can help you better understand it. I know it's hard to grasp some of these concepts when you first start with ActionScript. You're getting it though. There are just some sticking points I think that you probably need to get over before everything clicks.
Let me know how I can help
I mean if you write down what you would like to happen, just conceptually -- no AS involved. It will help clear your head of thoughts.
ah i see. i thought i need to follow the code. well here goes,
i like to create a moving marquee using as only. the images is stored in a folder & the images names in a textfile. the fla will find the images's name in the textfile, if the name is also in the folder the image will appear. its the same thing for urls.Last but not least, the marquee must be moving continously
izzt something like that medyman?:p
What I'm confused about is where you are now. You should have a working marquee. What should be left to do is create the continous motion. That's it.
Lol, i even more confused than you medyman. I being staring the code from line 0 to line xx & xx to line 0. I not even sure where my mistake is. By rights, at least i should be able to link to the urls .:( i supose
I got a feeling its going to be completed, but its either its short of something or there is an error somewhere
eh, i not sure i getting back to usual habits* but i give it a shot. :D Medyman, could you tell me what symbol& thumb means. ( i think i ask you before, but its still rather confusing. is panel a frame*( for storing the images in). if i right about this, could you also explain i just need it once* before the loadContainers function. The next time i see it, its around the end of the script which is regarding the allignment
AH, could it be the error
var image:MovieClip = panel["symbol"+i]["thumb"].createEmptyMovieClip("image", 30+i);
when i add a "s" to var image, i partly confused by image & images. :o (images is the pics file names right?)
Error opening URL "file:///C|/Documents%20and%20Settings/hyk/Desktop/marquee/logos/undefined"
Medyman
05-07-2008, 02:25 AM
Error opening URL "file:///C|/Documents%20and%20Settings/hyk/Desktop/marquee/logos/undefined"
This error means that the variable for the image name is not being read from the text file. This is probably due to this:
when i add a "s" to var image, i partly confused by image & images. (images is the pics file names right?)
I should have picked different names but this was originally just split off from the marquee that made for one of our clients, and i use that naming convention.
Anyway, image (singular) is the individual container that holds each logo. Images (plural) is the array that holds all the filenames. So they're two different things. Each has it's place. So, you shouldn't change that unless you know what you're changing.
Let's do this. Go back to the version that you uploaded to me last. It's posted a few threads up if you don't have that version anymore. Fix the text files in it, get rid of all the tabs and spaces (we can make it pretty after everything else works...no point in throwing in extra changes of something going wrong).
Once you remove all of the spaces, the marquee will work! If it doesn't then we have a problem with something else. I've tested it though on my computer and it does work.
Then I'll try to walk you through the rest of it in a different way. I'm invested in making you understand this now :D.
So confirm that you get it to work using the file that you posted earlier (and modified text file) and we'll go from there.
Let's do this. Go back to the version that you uploaded to me last. It's posted a few threads up if you don't have that version anymore. Fix the text files in it, get rid of all the tabs and spaces (we can make it pretty after everything else works...no point in throwing in extra changes of something going wrong).
ya, i changed the textfile already. all of it.(checked), re-copied the code i posted(checked) :D. As for pretty-wise, nah i just want to complete in the fastest time ever
ACE.jpg|http://www.acetechbiometric.com/
ArtVision.jpg|http://www.artivision.com.sg
Cisco.jpg|http://www.cisco.com
eh i still having those long* errors. what the problem??? -gulp-, is that a very big problem?
Medyman
05-07-2008, 02:39 AM
Are your images still in the folder called rawdata? If not, they need to be.
If they are, what is the exact error that you're getting?
you calling me to change the name of the folder(storing the pics) to rawdata?
ya i change it, still having the same problem. I thought we comfirmed on last week to call it logo? :D
Error opening URL "file:///C|/Documents%20and%20Settings/hoyk/Desktop/marquee/logos/Xbio.jpg"
eh, i change to the name to rawdata. Serious, but why is there a logos(& its the textfile name)?
Medyman
05-07-2008, 02:54 AM
Lol...not this again. Ok let's try it again.
Download what you uploaded to me again (http://www.mediafire.com/?zi1tsy296np). Even if you have the same file, redownload it please.
Keep these files in a different place than the other files so things don't get mixed up. Unzip the file. Replace logos.txt with this file (1755).
Don't change anything in the ActionScript. Don't change the folder name (keep it rawdata).
It works now, RIGHT?
I update you asap. My school network hates mediafire. K DON`T CHANGE ANYTHING. JUST OVERWRITE THE logo.txt. YES MEDYMAN. VERY LOUD & CLEAR :p
Medyman
05-07-2008, 03:02 AM
Haha...Good!
Sorry if that seemed a little militant. I was just trying to make sure we're on the same page. There's enough confusion going around :p
If you need I can upload it somewhere else for you. Or email it or something.
NO. ITS WORKS. WEEEE~. what happens? finally T_T. lol, we just joking around don`t worry :D. i not angry or something. Ah mr mouse is back. for once, i could dl files from mediafire in my school.:D they might have make a compromise between themselves
mind telling me where i screw up???
Medyman
05-07-2008, 03:08 AM
Ok...great. It works!
Now, do you understand the logic about what I posted with the continous motion and how it applies to the marquee? If you do, great. Let's add the code in.
If not, I'll explain it again.
Now, do you understand the logic about what I posted with the continous motion and how it applies to the marquee? If you do, great. Let's add the code in
eh, do you meant this?
if(panel._x <= limit) {
panel.roundedXSlideTo(0, time, "linear", .25, beginScroll);
}
else {
panel.roundedXSlideTo(limit, time, "linear", .25, beginScroll);
}
panel.onRollOver = pauseResume;
}
or this?
this.createEmptyMovieClip("panel", this.getNextHighestDepth());
Medyman
05-07-2008, 03:16 AM
No, I mean with the example I posted in this post (http://www.dynamicdrive.com/forums/showpost.php?p=141634&postcount=165).
eh i paste this whole chunk down right? replacing the start of function beginScroll() to the end of the script? :D i added this.createEmptyMovieClip("panel2", this.getNextHighestDepth()); too
Medyman
05-07-2008, 03:22 AM
right? replacing the start of function beginScroll() to the end of the script?
Well, kind of. Not exactly. I was just asking if you understand the technique (i.e. what's going on here). If you don't I'll go over it again. Because if you don't understand it you won't understand how to intergrate it into the rest of the script.
It's not as easy as just copying and pasting.
sorrie medyman, its moving now(at a extremely slow speed). at the start i forgotten there still the panel3. so if i never cleared that, its just won`t work. can you explain why when i change your tutorial, the 2nd pic will eat into the 1st pic, but mine won`t. is that the image size of my pics?
// Position the panel movieclips
// 450px is the width of the images I choose to use
panel2._x = 450;
// Start scrolling right away
this.onEnterFrame = Scroll;
// Functionality
// Workhorse function -- ScrollI()
function Scroll() {
panel._x = panel._x - 2; // move panel1 to the left by 2px
panel2._x = panel2._x - 2; // move panel2 to the left by 2px
if (panel._x == -450) { // if panel1 is off the screen, move it to the end of the queue
panel._x = 900;
}
if (panel2._x == -450) { // if panel2 is off the screen, move it to the end of the queue
panel2._x = 900;
}
}
Medyman
05-07-2008, 03:33 AM
sorrie medyman, its moving now(at a extremely slow speed). at the start i forgotten there still the panel3. so if i never cleared that, its just won`t work
The slow speed is because you're running it at a frame rate of 12. Movie it up to increase the speed.
Did you change something? Go back to how it was when it worked.
Again, you'll need to change the code from my example for it to work. It's not just a matter of copying and pasting. There is more to do than just changing names/variables. It's actually different code...same technique.
Medyman
05-07-2008, 03:34 AM
Once you revert back to the state where it worked:
Delete the beginScroll() and pauseResume() functions entirely. Just get rid of them.
just took away the panel3(all of it).panel1 became panel. ? btw, its works. Just reporting my updates :D eh, is there an error with my code or setup? I can`t see my last pic & after that it went all blank.
Medyman
05-07-2008, 03:47 AM
You should keep it named panel1. It'll make it easier to deal with. You'll need to loop through panel1 and panel2 to create the same actions to both.
If you have a number after both, it makes it a lot easier.
You should have something like this to create both empty containers;
this.createEmptyMovieClip("panel1", this.getNextHighestDepth());
this.createEmptyMovieClip("panel2", this.getNextHighestDepth());
Next you'll need to loop through both panel movieclips and add the logos inside. So create another loop inside loadContainers() but outside the current loop. It'll look something like this:
function loadContainers() {
for(j=1;j<=2;j++) {
for(i=0;i<images.length-1;i++) {
// CODE HERE
}
}
}
The code that goes inside the loop is essentially the same as before. The only difference now is that we have to refernce the index of the outside loop when assigning the panel movieclip.
So,
var symbol:MovieClip = panel.createEmptyMovieClip("symbol"+i, i);
becomes
var symbol:MovieClip = this["panel"+j].createEmptyMovieClip("symbol"+i, i);
You'll have to replace all instances of panel within the loop to this["panel"+j]
Medyman
05-07-2008, 03:50 AM
When you're all done add this:
panel2._y = 100;
at the bottom of all of your actionscript (outside all the fuctions/loops). If you've done it right, you should see two panels that look exactly the same.
If not, post your entire code.
before i start editing, just to comfirm. I put all the panel to panel1 right?
Medyman
05-07-2008, 03:56 AM
before i start editing, just to comfirm. I put all the panel to panel1 right?
Not all. Look at my 2nd to last post about that. But there should be nothing called panel anymore. It should have a number after it. Within the loop, the number will be applied dynamically.
Medyman
05-07-2008, 04:11 AM
You didn't change all the instances of panel in the loop.
Replace all instances of panel within the loop with
this["panel"+j] as I stated previously.
Also, get rid of all of this:
// Position the panel movieclips
// 450px is the width of the images I choose to use
panel.x=900;
panel2._x = 450;
// Start scrolling right away
this.onEnterFrame = Scroll;
// Functionality
// Workhorse function -- ScrollI()
function Scroll() {
panel._x = panel._x - 2; // move panel1 to the left by 2px
panel2._x = panel2._x - 2; // move panel2 to the left by 2px
if (panel._x == -450) { // if panel1 is off the screen, move it to the end of the queue
panell_x = 900;
}
if (panel2._x == -450) { // if panel2 is off the screen, move it to the end of the queue
panel2._x = 900;
}
}
Make those changes and test again. It should work. If it doesn't...post your code again!
Medyman
05-07-2008, 04:21 AM
You missed most of them.
this.createEmptyMovieClip("panel1", this.getNextHighestDepth());
this.createEmptyMovieClip("panel2", this.getNextHighestDepth());
var count:Number = 0;
function loadContainers() {
for(j=1;j<=2;j++) {
for(i=0;i<images.length-1;i++) {
var symbol:MovieClip = this["panel"+j].createEmptyMovieClip("symbol"+i, i);
var thumb:MovieClip = panel["symbol"+i].createEmptyMovieClip("thumb", i);
var image:MovieClip = panel["symbol"+i]["thumb"].createEmptyMovieClip("image", 30+i);
this["panel"+j]._x = 202*i
this["panel"+j]._y = Stage.height/4;
var mcl:MovieClipLoader = new MovieClipLoader();
var mclL:Object = new Object();
mclL.onLoadComplete = function() {
count++;
if(count ==images.length-1) {
beginScroll();
}
}
}
mcl.loadClip("rawdata/"+images[i], panel["symbol" +i]["thumb"]["image"]);
mcl.addListener(mclL);
panel["symbol"+i].id = i;
panel["symbol"+i].onRelease = function() {
getURL(urls[this.id]);
}
}
}
Test again. If it doesn't work, post the code again. You only need to paste the loadContainers() function. And please use the [code] tag when posting code.
*bump* my head on table. SORRIE. :p
i edited all like you told me too. Eh how could you scan through it so fast?
**Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 50: Unexpected '.' encountered
["panel"+j]["symbol"+i].id = i
his.createEmptyMovieClip("panel1", this.getNextHighestDepth());
this.createEmptyMovieClip("panel2", this.getNextHighestDepth());
var count:Number = 0;
function loadContainers() {
for(j=1;j<=2;j++) {
for(i=0;i<images.length-1;i++) {
var symbol:MovieClip = this["panel"+j].createEmptyMovieClip("symbol"+i, i);
var thumb:MovieClip = ["panel"+j]["symbol"+i].createEmptyMovieClip("thumb", i);
var image:MovieClip = ["panel"+j]["symbol"+i]["thumb"].createEmptyMovieClip("image", 30+i);
this["panel"+j]._x = 202*i
this["panel"+j]._y = Stage.height/4;
var mcl:MovieClipLoader = new MovieClipLoader();
var mclL:Object = new Object();
mclL.onLoadComplete = function() {
count++;
if(count ==images.length-1) {
beginScroll();
}
}
}
mcl.loadClip("rawdata/"+images[i], ["panel"+j]["symbol" +i]["thumb"]["image"]);
mcl.addListener(mclL);
["panel"+j]["symbol"+i].id = i;
["panel"+j]["symbol"+i].onRelease = function() {
getURL(urls[this.id]);
}
}
}
Medyman
05-07-2008, 04:27 AM
i edited all like you told me too
Not quite...
["panel"+j]["symbol"+i].id = i
should be
this["panel"+j]["symbol"+i].id = i
If you've forgotten the this in other places, please add it.
medyman, so i add
this["panel"+j] to all the panel right?
Medyman
05-07-2008, 04:38 AM
Yup.
Everywhere that's highlighted below should be this["panel" + j] instead of ["panel" + j]
his.createEmptyMovieClip("panel1", this.getNextHighestDepth());
this.createEmptyMovieClip("panel2", this.getNextHighestDepth());
var count:Number = 0;
function loadContainers() {
for(j=1;j<=2;j++) {
for(i=0;i<images.length-1;i++) {
var symbol:MovieClip = this["panel"+j].createEmptyMovieClip("symbol"+i, i);
var thumb:MovieClip = ["panel"+j]["symbol"+i].createEmptyMovieClip("thumb", i);
var image:MovieClip = ["panel"+j]["symbol"+i]["thumb"].createEmptyMovieClip("image", 30+i);
this["panel"+j]._x = 202*i
this["panel"+j]._y = Stage.height/4;
var mcl:MovieClipLoader = new MovieClipLoader();
var mclL:Object = new Object();
mclL.onLoadComplete = function() {
count++;
if(count ==images.length-1) {
beginScroll();
}
}
}
mcl.loadClip("rawdata/"+images[i], ["panel"+j]["symbol" +i]["thumb"]["image"]);
mcl.addListener(mclL);
["panel"+j]["symbol"+i].id = i;
["panel"+j]["symbol"+i].onRelease = function() {
getURL(urls[this.id]);
}
}
}
lol, i was about to post it. so nothing will happens right?
Medyman
05-07-2008, 04:46 AM
Did you add panel2._y = 100; to the botttom?
If so, you should see a duplicate of the panels movieclip. You might need to expand the size of your window. I have my stage set at the default 550 x 400 and I can see it.
Confirm that you do, and we'll move on to adding the motion.
this["panel"+j]["symbol"+i].id = i
this["panel"+j]["symbol"+i].onRelease = function() {
getURL(urls[this.id]);
}
}
}
panel2._y = 100; // my last line for now
eh, its blank medyman. I think we leave it for now( its quite late already, your time :D)
your stage size is the same as me. could it be the code errors?( my fault :p)
Medyman
05-07-2008, 05:01 AM
This is what I have:
What's the difference between this and what you're using?
var rawdata:Array = []; // stores all the raw data
var images:Array = []; // stores symbol image file names
var urls:Array = []; // stores associated website URIs
var lv:LoadVars = new LoadVars();
lv.onData = function(src:String) {
rawdata = src.split("\r\n"); // Seperates the raw data based on line breaks. Output image.jpg|http://www.website.co,
for(i=0;i<rawdata.length-1;i++) { // Loops through all of the raw data
info = rawdata[i].split("|"); // Seperates each array element by a delimiter (vertical bar). Resulting array: info[rawdata[i]] = (info[0], info[1]) or (image, uri)
images.push(info[0]); // "Pushes" the 0th value (the image path) to the images array for later access
urls.push(info[1]); // "Pushes" the 1st value to the urls array for later access
}
loadContainers();
}
lv.load("logos.txt");
this.createEmptyMovieClip("panel1", this.getNextHighestDepth());
this.createEmptyMovieClip("panel2", this.getNextHighestDepth());
var count:Number = 0;
function loadContainers() {
for(j=1;j<=2;j++) {
for(i=0;i<images.length-1;i++) {
var symbol:MovieClip = this["panel"+j].createEmptyMovieClip("symbol"+i, i);
var thumb:MovieClip = this["panel"+j]["symbol"+i].createEmptyMovieClip("thumb", i);
var image:MovieClip = this["panel"+j]["symbol"+i]["thumb"].createEmptyMovieClip("image", 30+i);
this["panel"+j]["symbol"+i]._x = 202*i
this["panel"+j]["symbol"+i]._y = Stage.height/4;
var mcl:MovieClipLoader = new MovieClipLoader();
var mclL:Object = new Object();
mclL.onLoadComplete = function() {
count++;
if(count ==images.length-1) {
beginScroll();
}
}
mcl.loadClip("rawdata/"+images[i], this["panel"+j]["symbol" +i]["thumb"]["image"]);
mcl.addListener(mclL);
this["panel"+j]["symbol"+i].id = i;
this["panel"+j]["symbol"+i].onRelease = function() {
getURL(urls[this.id]);
}
}
}
}
panel2._y = 100;
Edit: We'll have to leave this here for now. Figure out what's different about my code and what you're using. Once you get it working, follow the instructions in my next post
btw, just copy your code. its works. we continue later. Thanks. I get back to my troubleshooting :(
Medyman
05-07-2008, 05:08 AM
this["panel"+j]._x = 202*i
this["panel"+j]._y = Stage.height/4;
Should be
this["panel"+j]["symbol"+i]._x = 202*i
this["panel"+j]["symbol"+i]._y = Stage.height/4;
It should work now. If not, compare your code to what I posted above
Medyman
05-07-2008, 05:09 AM
Once you get it working...
First, delete:
panel2._y = 100;
That was only for testing purposes.
Next we need to look at the following function:
mclL.onLoadComplete = function() {
count++;
if(count ==images.length-1) {
beginScroll();
}
}
What this function does is count how many of the logos have loaded. When the number gets to the total amout of images there are in the text file, it fires the beginScroll() function.
Well, now we have two panels so we have double the about of images to count. Also, the beginScroll function doesn't exist anymore. We got rid of it. So, now we need something like this:
mclL.onLoadComplete = function() {
count++;
if(count == ((images.length-2)*2)) {
panel1.onEnterFrame = Scroll;
}
}
As you can see, the we've multipled the total by 2. Now, this will fire when both panels have been loaded. Also, as I showed by my example (http://www.visualbinary.net/files/tutorials/continuous-motion/), it makes more sense here to use an onEnterFrame instead of using something like MC Tween. So, once all the images have loaded, we call the Scroll function.
We'll write the Scroll function later. Does all of this make sense? Post your questions, I'll answer them in the morning
if(count == ((images.length-2)*2))
this was used because there were 2 panels right? if there for example x of it it will be
if(count == ((images.length-x)*x))
I not too clear about this part, what the difference between the 2 of them?
panel1.onEnterFrame = Scroll;
beginScroll();
I guess we might need this for the scrolling part Maybe some of the parts & also duplicateMovieClip right?
panel.onRollOver = panelOver;
function panelOver() {
this.onEnterFrame = scrollPanel;
delete this.onRollOver;
}
var b = stroke.getBounds(_root);
function scrollPanel() {
if(_xmouse<b.xMin || _xmouse>b.xMax || _ymouse<b.yMin || _ymouse>b.yMax) {
this.onRollOver = panelOver;
delete this.onEnterFrame;
}
if(panel._x >= 89) {
panel._x = 89;
}
if(panel._x <= -751) {
panel._x = -751;
}
var xdist = _xmouse - 250;
panel._x += Math.round(-xdist / 7);
}
Medyman
05-07-2008, 01:02 PM
if(count == ((images.length-2)*2))
this was used because there were 2 panels right? if there for example x of it it will be
if(count == ((images.length-x)*x))
Yup. 100% right.
I not too clear about this part, what the difference between the 2 of them?
panel1.onEnterFrame = Scroll;
beginScroll();
Well for one they're two different functions. They're both user-defined functions so they have no meaning outside of this project....just in case you're thinking they are ActionScript methods.
The biggest difference is the onEnterFrame. An onEnterFrame fires once per frame that the movieclip you're targeting is on the stage (not only the visible stage, can be off the visible window too). So panel1.onEnterFrame means that every frame (my frame rate is 30, so that means 30 times a second) the Scroll() function is called.
Make sense? If it does and the movie is working for you thus far, you can move ahead to positioning and animation the panels.
Make sense? If it does and the movie is working for you thus far, you can move ahead to positioning and animation the panels.
Eh, its all right now. Its just can`t move only. okie, so for a start i need to . I could try writing if you don`t mind teaching along the way :D
function scrol()
{panel1.onEnterFrame = function()
panel2.onEnterFrame {
Sorrie medyman, that the max that i could write now after reading up on it in school:( i know that alot errors here & there. ah, the 30* where should i put it?
// MoveRight class -- moves clip to the right 20 pixels
class MoveRight extends MovieClip {
function scroll() {
this.panel1._x += 30;
}
} This one was what i found & edited at livedocs. something is not wrong with code:( is it related?
I relooks your last 2 posts,
mclL.onLoadComplete = function() {
count++;
if(count ==images.length-1) {
beginScroll();
}
}
}
i need to in insert this for a start right?
function beginScroll() {
Medyman
05-07-2008, 02:05 PM
Eh, its all right now. Its just can`t move only. okie, so for a start i need to . I could try writing if you don`t mind teaching along the way
Well you haven't written the Scroll function yet :D. So it's fine that it doesn't move. And of course I don't mind helping.
function scrol()
{panel1.onEnterFrame = function()
panel2.onEnterFrame {
Not quite... You've already declared that panel1.onEnterFrame is equal to the Scroll function. So, you don't need to declare it again. You can just begin with the motion.
This one was what i found & edited at livedocs. something is not wrong with code is it related?
I guess it can be related. We're trying to do the same thing here. But that's using a class to do it. Object Oriented Programming is a whole another can of worms that you don't want to get into at this point.
I relooks your last 2 posts,
mclL.onLoadComplete = function() {
count++;
if(count ==images.length-1) {
beginScroll();
}
}
}
i need to in insert this for a start right?
function beginScroll() {
No...reread this (http://www.dynamicdrive.com/forums/showpost.php?p=142057&postcount=214) post. For starters, the function is called Scroll() not beginScroll().
Edit: Link was wrong. Updated.
i suppose you mean this post?
// mouse events
// clearInterval onRollOver
logos_mc.onRollOver = function() {
clearInterval(scroll_int);
trace("Stopping the marquee");
}
// re-setInterval onRollOut
logos_mc.onRollOut = function() {
scroll_int = setInterval(startScrolling, 15);
trace("Ok, start again.");
}
okie lets start with this chunk right?
mclL.onLoadComplete = function() {
count++;
if(count ==images.length-1) {
Scroll();
}
}
Am i on the right track now?:D If i am, lol so lets change the logos_mc for starters to panel1. Eh where the onEnterFrame btw?
Yeah, that might be a good resource for you too look at. It's doing the same thing essentially, except with PHP. My use of the variable lv is just a common naming convention (stands of loadVars), so if you see that elsewhere it doesn't necessarily mean in the same thing.
while i was reading those history*, its suddenly crossed my mind. So lv is loadVars in this marquee of its just a variable? Its abit OOT though :D
Medyman
05-07-2008, 02:19 PM
i suppose you mean this post?
// mouse events
// clearInterval onRollOver
logos_mc.onRollOver = function() {
clearInterval(scroll_int);
trace("Stopping the marquee");
}
// re-setInterval onRollOut
logos_mc.onRollOut = function() {
scroll_int = setInterval(startScrolling, 15);
trace("Ok, start again.");
}
Which version is that from? No, i did not mean that. I meant the one I linked to.
okie lets start with this chunk right?
mclL.onLoadComplete = function() {
count++;
if(count ==images.length-1) {
Scroll();
}
}
No, not exactly. Read the bottom of this post (http://www.dynamicdrive.com/forums/showpost.php?p=142057&postcount=214) again. It has the code, I'm not sure what the confusion is. You don't need to change it from what I've posted.
Am i on the right track now? If i am, lol so lets change the logos_mc for starters to panel1. Eh where the onEnterFrame btw?
logos_mc? Where did that come from? Again, that first code you posted can be discarded. The onEnterFrame should be clearer after you reread that post I just linked to.
while i was reading those history*, its suddenly crossed my mind. So lv is loadVars in this marquee of its just a variable? Its abit OOT though
Yeah, it's a variable. What's OOT?
Which version is that from? No, i did not mean that. I meant the one I linked to.
lol, i know medyman. But you gave me a post which was a month back( you could check the link again):D
EDITED: ok, you corrected it
OOT stands for out of topic. my bad. I forgotten you prefer clear* language
mclL.onLoadComplete = function() {
count++;
if(count == ((images.length-2)*2)) {
panel1.onEnterFrame = Scroll;
}
}
Okie, since i can`t realli write in as. My last 2/3 posts were all crappy code. Mind if i say it out in eng?:p The thing i/we have to do now is to declare the Scroll( how fast/slow its move etc. I should be correct by now
Medyman
05-07-2008, 02:38 PM
lol, i know medyman. But you gave me a post which was a month back( you could check the link again)
Yeah, sorry about that. I fixed the link.
OOT stands for out of topic. my bad. I forgotten you prefer clear* language
Lol...that's clear for someone who knows what OOT is. I'm not up on my web acronyms.
Okie, since i can`t realli write in as. My last 2/3 posts were all crappy code. Mind if i say it out in eng? The thing i/we have to do now is to declare the Scroll( how fast/slow its move etc. I should be correct by now
Yes...that's correct. That's exactly what the step after the next one is :p
Before we start moving things, lets position the panels. Right now both panels are on top of each other.
First, create the Scroll() function;
function Scroll() {
trace("this is when the panel would start scrolling)"
}
Next, we'll need some way of positioning the 2nd panel (the 1st one is already where we want it). Let's create another function for that. You could do it within Scroll() but it's clearner this way.
We'll call it position.
function position() {
panel2._x = panel1._width;
}
}
This will position panel2 right after panel1, so they look like they are joined. Now, add a call to this function within Scroll();
function Scroll() {
position();
trace("this is when the panel would start scrolling)"
}
Because we're caling Scroll() onEnterFrame, that means that the postion() function will also fire once per frame. We actually only want it to fire once for the entire movie. If it was firing once per frame, panel2 would never move because we would keep delcaring the _x property to be the same.
So, to do this...
We create a boolean variable that we will set when postioned() runs for the first time. Once the variable is set...we'll use an if statement to test if we should run position() or not. If the variable is set, we won't run it. If it is set, we will run it. Lets call this boolean variable positioned
So, this gives us:
var positioned:Boolean = false;
function position() {
if (positioned == false) {
panel2._x = panel1._width;
positioned = true;
}
}
Are you with me so far?
lol. I sure am with you. Not asleep O.O but with no flash software.:D the first 2 parts of the codes is it linked together? I having abit of confusion here by the traces.
so, scroll() is for panel1 & postion is for 2. I think i change it to scroll1()& scroll2(). At least,i know what are they for :p. the last 2 wks, we having enough confusion over images, rawdata etc.
Eh, medyman could you pls use // instead of trace ( its for debugging purposes i know). the boolean part could we leave it till we done with the above part 1st
function Scroll() {
position();
panel2._x = panel1._width;
}
is it something like that??
function Scroll(){
}
function postion(){
panel2._x+panel._width
}
is this the clearer way which you spoke of?
Because we're caling Scroll() onEnterFrame, that means that the postion() function will also fire once per frame. We actually only want it to fire once for the entire movie. If it was firing once per frame, panel2 would never move because we would keep delcaring the _x property to be the same.
I not quite sure with what you trying to say. sorrie (perhaps i need to test it out be4 getting a clearer picture)
Medyman
05-07-2008, 02:53 PM
so, scroll() is for panel1 & postion is for 2. I think i change it to scroll1()& scroll2(). At least,i know what are they for . the last 2 wks, we having enough confusion over images,
Umm...no. Scroll() is to scroll the movieclips. position() is to position them. Panel1 is already where we need it to be so no need to position it. That's why panel2 is the only thing in the position movieclip.
Eh, medyman could you pls use // instead of trace ( its for debugging purposes i know).
Yea, sure. But don't get caught up on the traces. They're just an easy way to know what's going on.
So Scroll() and position() are two seperate functions. The entire bit should look like this:
var positioned:Boolean = false; // Is panel2 positioned yet?
function position() {
if (positioned == false) { // if we've already positioned it, don't run this.
panel2._x = panel1._width; // position panel2 at the end of panel 1;
positioned = true; // panel2 is positioned, no need to run the postion() function anymore
}
}
function Scroll() {
position(); // First position panel2 and then we'll start scrolling it.
// trace("scrolling");
}
Make sense?
Note: You won't see a visible difference after doing this but trust that it's done what you want.
ah i see, so panel1 we cleared it a few posts just now* (sorrie to bother your sleep:o).
var positioned:Boolean = false; // Is panel2 positioned yet?
function position() {
if (positioned == false) { // if we've already positioned it, don't run this.
panel2._x = panel1._width; // position panel2 at the end of panel 1;
positioned = true; // panel2 is positioned, no need to run the postion() function anymore
}
}
}
medyman, I thought boolean was &&,|| etc, anw its a part of as. your comments i having a little problem mostly its regarding the true& false parts :confused:
Medyman
05-07-2008, 03:04 PM
A Boolean variable is a variable that holds either a true or false value. The && and || are conditional operators.
In other words what's happening here is that we only want to run this function once, but we're calling it multiple times. To fix this, the first time we set the positioned to true. Then within the function we say only run it if it's false. So the very first time it run the function. After that, it will not.
Make sense now?
the first time we set the positioned to true. Then within the function we say only run it if it's false. So the very first time it run the function. After that, it will not.
the 1st time do you mean
var positioned:Boolean = false;
Medyman
05-07-2008, 03:14 PM
Yes.
The position() function can only run when the positioned variable is false.
This is the order of it
positioned = false;
position() function starts
positioned = true;
position() function is called again, but does not run because positioned = true;
position() function is called again, but does not run because positioned = true;
etc....
So it only runs once!
Is this making any sense?
okie i am slowly clearing my doubts. thanks
its only involved the 1st 3 lines right?
Medyman
05-07-2008, 03:21 PM
Yes...
Ok, so are u ready for the next step...actually moving this thing?
so up till now, its the postioning of the images. NOW we moving on to the scrolling/moving part. Sure, ready when you are. If you are not busy from your work:D
Medyman
05-07-2008, 03:33 PM
Ok...great
The logic to moving the panels is this. As you know now, the onEnterFrame event fires once per frame. If your framerate is 30, it will fire 30 times a second.
I'm going to be using framerate of 30 as an example. Adjust your logic to whatever you want your framerate to be. I recommend something close to 30, though
So the Scroll() function is running 30x a second. This allows us to say that every time the Scroll() function runs...decrease (because we're going from right to left) the _x position of panel1 and panel2 by 5 pixels (the number of pixels is up to you).
To do this, we add the following lines within the Scroll function
panel1._x = panel1._x - 2; // move panel1 to the left by 2px
panel2._x = panel2._x - 2; // move panel2 to the left by 2px
panel1._x is the current _x position of panel1. When this function runs (30x a second), it subtracts 2 from the current value. The current value updates so it's 2 less each time. Same thing for panel2.
Test the movie. It should be scrolling.
I usually change -2 to -40 or something to test. It takes quite a while with -2
Once both panels scroll by, you'll notice that the motion isn't contiouous. It just scrolls from one end to the other. What we want to do is use some conditional statements that say when panel1 (or panel2) have completely moved off the stage, let's add it behind panel2 (or panel1). This way it'll seem like they're moving continously. If you don't get this concept, take a look at the example I posted before.
This gives us the following code:
if (panel1._x <= -panel1._width) { // if panel1 is off the screen, move it to the end of the queue
//trace("panel1 off screen");
panel1._x = panel2._x + panel2._width;
}
This says that if the _x position of panel1 is less than or equal to negative it's width, place panel1 at the end of panel2. When panel1 is totally off the stage, it will have an _x position of negative it's width because the _x position is measured from the upper left hand corner. How we figure out where to put it after it's off the visible stage is this:
Figure out the _x position of panel2 (panel2._x) and add to it the width of panel2.
The same logic gives us a similar statement for panel2.
if (panel2._x <= -panel2._width) { // if panel2 is off the screen, move it to the end of the queue
panel2._x = panel1._x + panel1._width;
//trace("panel2 off screen");
}
Put it all together and we have this as our Scroll() function:
function Scroll() {
position();
panel1._x = panel1._x - 2; // move panel1 to the left by 2px
panel2._x = panel2._x - 2; // move panel2 to the left by 2px
if (panel1._x <= -panel1._width) { // if panel1 is off the screen, move it to the end of the queue
//trace("panel1 off screen");
panel1._x = panel2._x + panel2._width;
}
if (panel2._x <= -panel2._width) { // if panel2 is off the screen, move it to the end of the queue
panel2._x = panel1._x + panel1._width;
//trace("panel2 off screen");
}
}
Test it and it will be scroll perpetually. You'd never know that there were two movieclips. Let me know if there are any problems here.
What's left? The onRollOvers and onRollOuts. The end is near.
var positioned:Boolean = false; // Is panel2 positioned yet?
function position() {
if (positioned == false) { // if we've already positioned it, don't run this.
panel2._x = panel1._width; // position panel2 at the end of panel 1;
positioned = true; // panel2 is positioned, no need to run the postion() function anymore
}
}
function Scroll() {
position();
panel1._x = panel1._x - 2; // move panel1 to the left by 2px
panel2._x = panel2._x - 2; // move panel2 to the left by 2px
if (panel1._x <= -panel1._width) { // if panel1 is off the screen, move it to the end of the queue
//trace("panel1 off screen");
panel1._x = panel2._x + panel2._width;
}
if (panel2._x <= -panel2._width) { // if panel2 is off the screen, move it to the end of the queue
panel2._x = panel1._x + panel1._width;
//trace("panel2 off screen");
}
}
}
so that all what i had to put in when i in school tomorow
So the Scroll() function is running 30x a second. Its in the setting right? where your frame rate is
the pixels & stuffs, i abit confused with that.haha. I think i play around with the numbers to get a clearer picture
What's left? The onRollOvers and onRollOuts. The end is near.
haha, hopefully. i sure hope i don`t have errors:). when its finally complete, we could quote a sentence from your old post. (when its done, it will 10 times
more cleaner & better :D)
Medyman
05-07-2008, 03:48 PM
so that all what i had to put in when i in school tomorow
And change this:
mclL.onLoadComplete = function() {
count++;
if(count == ((rawdata.length-2)*2)) {
panel1.onEnterFrame = Scroll;
}
}
Its in the setting right? where your frame rate is
Yeah, it's in the properties panel.
haha, hopefully. i sure hope i don`t have errors. when its finally complete, we could quote a sentence from your old post. (when its done, it will 10 times
more cleaner & better )
If you follow those instructions, there shouldn't be. I've tested everything I've told you to do. So it works, when done correctly :D
And cleaner & better are relative terms. But I certianly think it's cleaner than what you had.
If you follow those instructions, there shouldn't be. I've tested everything I've told you to do. So it works, when done correctly
And cleaner & better are relative terms. But I certianly think it's cleaner than what you had.
al`right let me go try out before i continue my posts, i quite forgetful.:p well, what i can say, the orginal one was written by a student, the modifed one was written by an expert( who studied on his own, help out in the forum& learn it step by step) :D
Ah, okie medyman. Its can move now. I ready for your rollOn& rollOver tutorials. you told me to change the images to rawdata. Is it because of the pics folder name?
mclL.onLoadComplete = function() {
count++;
if(count == ((rawdata.length-2)*2)) {
panel1.onEnterFrame = Scroll;
}
}
edited: medyman, i got some slight problems. firstly the last logo did not appear & secondly there a big gap between the last & first logo
Medyman
05-08-2008, 01:10 AM
Ah, okie medyman. Its can move now. I ready for your rollOn& rollOver tutorials. you told me to change the images to rawdata. Is it because of the pics folder name?
mclL.onLoadComplete = function() {
count++;
if(count == ((rawdata.length-2)*2)) {
panel1.onEnterFrame = Scroll;
}
}
Hey!
No, it's not because of the folder name. This refers to the rawdata array. You can call it images if you like. Alternately you can call it urls. It's all the same value.
On to the rollOvers...
We want the panel to stop moving on the rollovers. Ok, so to stop it, we need to know what is making it move in the first place.
So, what's making it move....
"The Scroll() function", you say out loud :p
So, because we're going to need to stop the panels from moving when we mouse over panel1 and panel2, let's create a function so we don't have repetitive code -- like so:
function stopScroll() {
delete panel1.onEnterFrame;
}
stopScroll() -- pretty self explanatory. It deletes the onEnterFrame event. Remember that the onEnterFrame event is what calls the Scroll() function. We delete the onEnterFrame event, we delete the call to the Scroll() function.
But just creating the function won't do anything. You have to assign it to some mouse events. We want stopScroll() to kick in when we mouse over panel1 or panel2. So, we say...
panel1.onRollOver = stopScroll;
panel2.onRollOver = stopScroll;
Now, it'll stop when you mouse over it. But it won't start back up again. Well, of course not! You just deleted the onEnterFrame event. But you want it to start when you mouse off the panel, you say? Ok! Declare the onEnterFrame again. Like so:
panel1.onRollOut = function() {
panel1.onEnterFrame = Scroll;
}
panel2.onRollOut = function() {
panel1.onEnterFrame = Scroll;
}
Put it all together and you have these short lines to control the mouse events:
panel1.onRollOver = stopScroll;
panel2.onRollOver = stopScroll;
panel1.onRollOut = function() {
panel1.onEnterFrame = Scroll;
}
panel2.onRollOut = function() {
panel1.onEnterFrame = Scroll;
}
function stopScroll() {
delete panel1.onEnterFrame;
}
Your entire code should look like this now:
var rawdata:Array = []; // stores all the raw data
var images:Array = []; // stores symbol image file names
var urls:Array = []; // stores associated website URIs
var lv:LoadVars = new LoadVars();
lv.onData = function(src:String) {
rawdata = src.split("\r\n"); // Seperates the raw data based on line breaks. Output image.jpg|http://www.website.co,
for(i=0;i<rawdata.length-1;i++) { // Loops through all of the raw data
info = rawdata[i].split("|"); // Seperates each array element by a delimiter (vertical bar). Resulting array: info[rawdata[i]] = (info[0], info[1]) or (image, uri)
images.push(info[0]); // "Pushes" the 0th value (the image path) to the images array for later access
urls.push(info[1]); // "Pushes" the 1st value to the urls array for later access
}
loadContainers();
}
lv.load("logos.txt");
this.createEmptyMovieClip("panel1", this.getNextHighestDepth());
this.createEmptyMovieClip("panel2", this.getNextHighestDepth());
var count:Number = 0;
function loadContainers() {
for(j=1;j<=2;j++) {
for(i=0;i<images.length-1;i++) {
var symbol:MovieClip = this["panel"+j].createEmptyMovieClip("symbol"+i, i);
var thumb:MovieClip = this["panel"+j]["symbol"+i].createEmptyMovieClip("thumb", i);
var image:MovieClip = this["panel"+j]["symbol"+i]["thumb"].createEmptyMovieClip("image", 30+i);
this["panel"+j]["symbol"+i]._x = 202*i
this["panel"+j]["symbol"+i]._y = Stage.height/4;
var mcl:MovieClipLoader = new MovieClipLoader();
var mclL:Object = new Object();
mclL.onLoadComplete = function() {
count++;
if(count == ((rawdata.length-2)*2)) {
panel1.onEnterFrame = Scroll;
}
}
mcl.loadClip("rawdata/"+images[i], this["panel"+j]["symbol" +i]["thumb"]["image"]);
mcl.addListener(mclL);
this["panel"+j]["symbol"+i].id = i;
this["panel"+j]["symbol"+i].onRelease = function() {
//getURL(urls[this.id]);
trace(urls[this.id]);
}
}
}
}
var positioned:Boolean = false;
function position() {
if (positioned == false) {
panel2._x = panel1._width;
positioned = true;
}
}
function Scroll() {
position();
panel1._x = panel1._x - 2; // move panel1 to the left by 2px
panel2._x = panel2._x - 2; // move panel2 to the left by 2px
if (panel1._x <= -panel1._width) { // if panel1 is off the screen, move it to the end of the queue
//trace("panel1 off screen");
panel1._x = panel2._x + panel2._width;
}
if (panel2._x <= -panel2._width) { // if panel2 is off the screen, move it to the end of the queue
panel2._x = panel1._x + panel1._width;
trace("panel2 off screen");
}
}
panel1.onRollOver = stopScroll;
panel2.onRollOver = stopScroll;
panel1.onRollOut = function() {
panel1.onEnterFrame = Scroll;
}
panel2.onRollOut = function() {
panel1.onEnterFrame = Scroll;
}
function stopScroll() {
delete panel1.onEnterFrame;
}
And now, my friend, you have a working marquee :D
i see. sorry its was my mistake just now :p. I was thinking that you would do a function Mouse(). the whole marquee is dependemt on panel1& panel2 right? they are the MAIN characters:D
Medyman
05-08-2008, 01:19 AM
Oh, and to clean up the code a little further make these changes:
Replace
mclL.onLoadComplete = function() {
count++;
if(count == ((rawdata.length-2)*2)) {
panel1.onEnterFrame = Scroll;
}
}
with
mclL.onLoadComplete = function() {
count++;
if(count == ((rawdata.length-2)*2)) {
position();
}
}
Also replace
var positioned:Boolean = false; // Is panel2 positioned yet?
function position() {
if (positioned == false) { // if we've already positioned it, don't run this.
panel2._x = panel1._width; // position panel2 at the end of panel 1;
positioned = true; // panel2 is positioned, no need to run the postion() function anymore
}
}
With...
function position() {
panel2._x = panel1._width; // position panel2 at the end of panel 1;
panel1.onEnterFrame = Scroll;
}
This will free up some system resources, get rid of a variable and a conditional. Won't make too large of a difference but every little bit counts, I say.
Now, the final bit of code will look like this:
var rawdata:Array = []; // stores all the raw data
var images:Array = []; // stores symbol image file names
var urls:Array = []; // stores associated website URIs
var lv:LoadVars = new LoadVars();
lv.onData = function(src:String) {
rawdata = src.split("\r\n"); // Seperates the raw data based on line breaks. Output image.jpg|http://www.website.co,
for(i=0;i<rawdata.length-1;i++) { // Loops through all of the raw data
info = rawdata[i].split("|"); // Seperates each array element by a delimiter (vertical bar). Resulting array: info[rawdata[i]] = (info[0], info[1]) or (image, uri)
images.push(info[0]); // "Pushes" the 0th value (the image path) to the images array for later access
urls.push(info[1]); // "Pushes" the 1st value to the urls array for later access
}
loadContainers();
}
lv.load("logos.txt");
this.createEmptyMovieClip("panel1", this.getNextHighestDepth());
this.createEmptyMovieClip("panel2", this.getNextHighestDepth());
var count:Number = 0;
function loadContainers() {
for(j=1;j<=2;j++) {
for(i=0;i<images.length-1;i++) {
var symbol:MovieClip = this["panel"+j].createEmptyMovieClip("symbol"+i, i);
var thumb:MovieClip = this["panel"+j]["symbol"+i].createEmptyMovieClip("thumb", i);
var image:MovieClip = this["panel"+j]["symbol"+i]["thumb"].createEmptyMovieClip("image", 30+i);
this["panel"+j]["symbol"+i]._x = 202*i
this["panel"+j]["symbol"+i]._y = Stage.height/4;
var mcl:MovieClipLoader = new MovieClipLoader();
var mclL:Object = new Object();
mclL.onLoadComplete = function() {
count++;
if(count == ((rawdata.length-2)*2)) {
position();
}
}
mcl.loadClip("rawdata/"+images[i], this["panel"+j]["symbol" +i]["thumb"]["image"]);
mcl.addListener(mclL);
this["panel"+j]["symbol"+i].id = i;
this["panel"+j]["symbol"+i].onRelease = function() {
getURL(urls[this.id]);
}
}
}
}
function position() {
panel2._x = panel1._width; // position panel2 at the end of panel 1;
panel1.onEnterFrame = Scroll;
}
function Scroll() {
position(); // First position panel2 and then we'll start scrolling it.
panel1._x = panel1._x - 10; // move panel1 to the left by 2px
panel2._x = panel2._x - 10; // move panel2 to the left by 2px
}
panel1.onRollOver = stopScroll;
panel2.onRollOver = stopScroll;
panel1.onRollOut = function() {
panel1.onEnterFrame = Scroll;
}
panel2.onRollOut = function() {
panel1.onEnterFrame = Scroll;
}
function stopScroll() {
delete panel1.onEnterFrame;
}
It sures looks okie on paper. But medyman, there still the problem with the last logo. & I don`t see the 1st pic appearing after that.( there still the big gap though) :D
i change the frame rate for faster scanning* purposes, i don`t think its really affects the marquee right expect the speed
Medyman
05-08-2008, 01:31 AM
Post your code.
that was what i copied from your code medyman. anyways here goes :D
Medyman
05-08-2008, 01:40 AM
Sorry man...
I don't know what happened there... The conditionals got lost in the Scroll() function. The copying and pasting from different versions finally caught up to me.
Replace the Scroll() function with this:
function Scroll() {
panel1._x = panel1._x - 100; // move panel1 to the left by 2px
panel2._x = panel2._x - 100; // move panel2 to the left by 2px
if (panel1._x <= -panel1._width) { // if panel1 is off the screen, move it to the end of the queue
panel1._x = panel2._x + panel2._width;
}
if (panel2._x <= -panel2._width) { // if panel2 is off the screen, move it to the end of the queue
panel2._x = panel1._x + panel1._width;
}
}
lol. Medyman, i think there something wrong with the code somewhere.
1. Its moving at an incrediable speed.( i change the frame rate to a around 10 but its still moving very fast) *spinning head*
2. At the first round, there seems to be a big gap between the last& first image, but its works al`right after the first round
3. lol, the last logo friend. I still can`t see it. :D
Medyman
05-08-2008, 03:15 AM
1. Change the highlighted to a smaller number
panel1._x = panel1._x - 100; // move panel1 to the left by 2px
panel2._x = panel2._x - 100; // move panel2 to the left by 2px
I don't have the patience to watch the thing go by 2 pixels at a time.
2. Change the onLoadComplete event and position() functions again. Below are corrected. Bascially, the width of the 1st panel wasn't availabel when we were calling it.
mclL.onLoadComplete = function() {
count++;
if(count == ((rawdata.length-2)*2)) {
_root.onEnterFrame = position;
}
}
function position() {
if(panel1._width > 0) {
delete _root.onEnterFrame;
panel2._x = panel1._width; // position panel2 at the end of panel 1;
panel1.onEnterFrame = Scroll;
}
}
3. Change the for loop from for(i=0;i<images.length-1;i++) to for(i=0;i<images.length;i++) -- meaning remove the -1.
AH. Thanks medyman :D. ya its work perfectly.
Change the for loop from for(i=0;i<images.length-1;i++) to for(i=0;i<images.length;i++) -- meaning remove the -1.
i suppose the more -x you have= the last x logos will be taken off right?
Another thing, the marquee looks odd. Feel kinda of stiff :p ( that the last of my concern)
lol, i increase the number instead at the beginning
hmm odd, i can`t link to the urls
Medyman
05-08-2008, 03:36 AM
i suppose the more -x you have= the last x logos will be taken off right?
Yea.
Another thing, the marquee looks odd. Feel kinda of stiff
What do you mean by stiff?
mm odd, i can`t link to the urls
Delete both onRollOut functions. Replace stopScroll() with:
function stopScroll() {
delete panel1.onEnterFrame;
delete this.onRollOver;
var x = panel1.getBounds(_root);
this.onEnterFrame = function() {
if(_ymouse<x.yMin || _ymouse>x.yMax) {
panel1.onEnterFrame = Scroll;
this.onRollOver = stopScroll;
}
}
}
Eh its kinda of laggy. Maybe from what i felt :p
Ya its al`right now( wait till i found some errors ;)). I suppose i can start asking you qns about the codes. Some of the parts i still confused by it :D
var image:MovieClip = this["panel"+j]["symbol"+i]["thumb"].createEmptyMovieClip("image", 30+i);
I tried deleting the 30 from the above line. Its still works. What with the 30 btw?
Medyman
05-08-2008, 03:50 AM
I tried deleting the 30 from the above line. Its still works. What with the 30 btw?
It's not an error. It's from a previous manifestation of your marquee. This thing has taken so long, theres bound to be remnants of old code. As long as the number is unique, it doesn't matter.
I think that's left over from the marquee that I made for my client. It made sense there with my setup, but doesn't effect yours.
Eh its kinda of laggy. Maybe from what i felt
Play with the offset and the frame rate to see what works best. I'm on a pretty fast system so I don't experience any lagging.
what is offset? Some of the words on the logos looked blur when its is moving.
regarding the Q&A session. I read through all the post once more before i check with you. But for a start i would like to ask this part :D
this.onEnterFrame = function() {
if(_ymouse<x.yMin || _ymouse>x.yMax) {
panel1.onEnterFrame = Scroll;
this.onRollOver = stopScroll;
}
}
}
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.