View Full Version : actionscript for loadmovie? pls help...
chal7ds
11-19-2004, 04:04 AM
hey all,
i am a total newbie, so bear with me here.
ok, what i have is a movie file with a tv set in the animation that flickers on and off all fuzzed out with it's channels. There is another character in the animation, who, when you click on him, rises up, and has a remote control. When you click on one of the buttons on the remote, it cleans up the tv, and you're able to see a clear channel. Now, here's where i need your help...
...ok....once this clear channel is up, i am going to have it to where now the user will be able to click on a button on the tv set and be able to change the channels from this single button located on the lower part of the tv. To save file size, i have created 50 other swf files of just the screen with it's channel animations. So, what i want to do, is call up each channel (mc) with actionscript from the button within the main movie.
The screen size in each sub-swf file is 68.7 width by 44.8 heighth. The total size of my main movie (the stage) is 949 width by 740 pixels. obviously, i am going to want the screen swf mc that is being called by the actionscript to show up in the same spot that the original one sitting there is at, so that it gives the illusion that someone changed the channel. The names of my sub swf mc's are "channel1.swf", "channel2.swf", etc etc...
ok, so...how do i call these channels up with actionscript? i assume it's like loadmovie or something?!? ..but i don't know how. Please help out there!
much appreciated...
thanx,
chal7ds
chal7ds@yahoo.com
Create a tv screen size mc in this example called tv_mc (make sure the registration point is in the top left corner). Put a copy of it onto the stage and name it (in the position where your tv is. Put a button on the stage so you can use onRelease event handler - in your case the TV button.
tv_btn.onRelease = function() {
laodMovie("channel1",tv_mc);
}
easy as that really. The external SWF (channel1) will load into the tv_mc area using the registration point as 0,0. Note that the loaded mc channel1 inherits the characteristics of the tv_mc - position, scale, instance name etc. but the timeline is the timeline of channel1.
Use unloadMovie to remove it.
here is an example - quick and dirty I am afraid but you get the idea.
chal7ds
11-19-2004, 03:36 PM
okay, that first part works great. But, what about when the user decides to click on the button again so that he can go 'UP' a channel?
That's how i want it to be setup, so that once the user hits the button again it goes to the next channel up "channel2.swf" and so on...so that if he hits it again on channel 2, it'll go to "channel3.swf"..etc.. i have a total of 8 channels..so the last channel he'll be able to go to will be 8 on that button. if he hits it again from channel 8, i'd like it to restart to channel 0.
how would you configure that code from the same button?
in addition, i have a button next to the up button...and this button next to it will take the channels down! so for example, if the user clicks on the up button and channel1.swf loads...he can either hit that button again and it goes to channel2.swf, or, he can hit the button NEXT to it, and it will take it to channel 0. if he hits it again, it'll go to "channel8.swf"... see what i'm saying? ..like a normal tv in real life kind've...
how would you set that up?
I liked your flash examples..if you could do that again, that would be awesome!
if not, cool...appreciate any help!
thanx,
chal7ds
chal7ds@yahoo.com
ok here are the fla's remember to compile them into swf and then run tv.swf.
It loads the first channel on the up button press and then the next channel on the up button press and because there are only 2 channels it then loads an end movie on the 3rd button press. The user can keep pressing up but it wont go anywhere. On the down button press it will move down the channels to the start. I have inlcluded a dynamic text field which shows the user which channel he/she is watching.
I think this is what you wanted.
I tidied up the tv.fla and theend.fla to make it look nicer. Graphics are not my strong point :)
chal7ds
11-20-2004, 04:43 AM
alright, i downloaded your files..and i totally understood how you set it up...but i guess i'm not advanced enough with code yet..because i tried to manipulate the code for my movie with the changes that would fit mine, but it didn't work.
So...i'm attaching an example movie of what my movie is like..plus all the channels with it. If you open my 'example' file, you'll see on the stage a hand carrying a remote. the red button on the remote is clickable for the user..and takes them to the second frame...which turns a channel on..where george bush is talking...but, as this george bush channel is going...i'd like to have the two buttons, up button and down button to be able to retrieve the channels starting at frame 8 (that's why you'll see that i pasted your code in at frame 8 on the script layer. although, my modifications of your code totally suck and don't work. this is where i was hoping you could come in! if you could check out that code on frame 8 in the script layer...and see what i'm doing wrong, that'd be great.
anyways, i'd like it so that once the user presses the up button on the tv, the george bush channel is replaced by the incoming channel1.swf..and channel2.swf...etc.. and same for when the user pushes the down button..it should go to channel8.swf..and then channel7.swf...and so on...
I got rid of the other 42 channels..i'm only messing with 8 now...
please don't change the remote's red button though..i want that to stay the same..the red button should still go to the second frame and lead into the george bush channel.
all i need is those loadmovie actions for frame 8 on the script layer to work...
if you have time for this, cool! if not, could you at least tell me what i did wrong with my code??
thanx a million man! ...and i don't believe that you're a newbie..if you are...you must know other coding... :)
that's it for now...
chal7ds
chal7ds@yahoo.com
chal7ds
11-20-2004, 04:45 AM
here's the rest of the channels...
chal7ds :eek:
Ok I completed the work you asked. The graphics are yours. The TV plays George Bush at the start without any prompting. The user can scroll through the red button on the remote to go up the channels and the yellow button to go down the channels. If you are at channel 8 then it will go back to the start which is G Bush etc. Just looping round as the user hits up or down.
I cleared out your work (sorry) as mine is more compact. You only have one frame in the main timeline and 3 layers. ALL of the script is in one place and you have no need to make the timeline do the work as all you are really doing is loading movies.
Also, I included a channel 0 which is George Bush so the attachment is tv.fla and channel0.fla all the other channels you already have and they will work fine without any code change.
I have changed the code around and it is very straightforward, I have a few probs with the up and down bit but now it is sorted and the coding is quite neat with just a couple of function calls doing all the work. You should be able to follow it quite easily.
Hope this is what you wanted?
As for coding, yes I only started in October (about 5 or 6 weeks ago) and this includes the flash part as well. I hang around here helping to improve my skills. Currently working on PHP stuff as I am new to that as well.
I have put a copy on my test site for you to see it quickly - i will leave it there for a short while. The buttons are very small to hit but they are on the remote as you put them.
If this is what you wanted then please just give me some credit on your site thats all I ask.bush tv (http://www.barkerfamily.plus.com/)
chal7ds
11-21-2004, 05:16 PM
Thanx! that works cool...
i changed it quite a bit to fit what i needed though. i actually didn't want the red and yellow buttons to channel up and down, so i put the code in the grey tv buttons and just made the red button the initial turning on of the tv set.
Thanx again for your help though..it was much appreciated! i would have never been able to figure out code like that!
chal7ds@yahoo.com
chal7ds
vBulletin® v3.7.1, Copyright ©2000-2009, Jelsoft Enterprises Ltd.