PDA

View Full Version : flash noob question(seriously noob)



wolverinejoe80
March 11th, 2009, 02:37 PM
hi guys,

serious noob here. this is my first time ever attempting flash..

I want the simple movie to load the URL(home page) after it's finished.

so i tried to add
getURL("http://www.google.com " , "_blank");

at the end of movie, but i keep getting errors..

this is the website that i'm working on

LINK (http://web4architects.com/clients/TMR/index.html)


It's a very simple. i'm not even going to dare to make it fancier. I just want the movie to be over and go straight to the home page without any clicks.. i tried to put the geturl thingy at the last movie clip(Imagine tomorrow) and i tried to put it at the end of the keyline.. neither seem to work...

i'm sure it's very easy one, but it just doesn't work...


please please help!
thanks in advance!

Joe

GrndMasterFlash
March 11th, 2009, 02:59 PM
ok, the first thing you want to do is avoid AS2 completely!!!!
trust me there are many good reasons for this and 90% of the people on this site will agree.

so in AS3 to load a url you would do the fallowing




var url_req:URLRequest ;
var loader:Loader;

loadThis("http://someURL.com");

function loadThis(s:String)
{
url_req = new URLRequest(s);
loader = new Loader;
loader.contentLoaderInfo.addEventListener("complete", handleLoadedObj);
loader.load(url_req);
addChild(loader);
}
function handleLoadedObj(e:Event)
{
trace(e);
}
mess around with that, hope it helps

lunatic
March 11th, 2009, 03:03 PM
ok, the first thing you want to do is avoid AS2 completely!!!!
trust me there are many good reasons for this and 90% of the people on this site will agree.

so in AS3 to load a url you would do the fallowing




var url_req:URLRequest ;
var loader:Loader;

loadThis("http://someURL.com");

fucntion loadThis()
{
url_req = new URLRequest(s);
loader = new Loader;
loader.contentLoaderInfo.addEventListener("complete", handleLoadedObj);
loader.load(url_req);
addChild(loader);
}
function handleLoadedObj(e:Event)
{
trace(e);
}


mess around with that, hope it helps

I know nothing about AS3 except that its hard to learn and confusing. That said, why do you declare loader and url_req twice? Once outside and then again inside the function? Can't you just access the var's from inside the function that were declared outside?

Daganev
March 11th, 2009, 03:06 PM
proper class structure is to declare variables (use var x) outside of functions, and to instantiate them (use x = y) inside of functions.

as3 is much better than as2, and worth the 4 hours of reading to understand the difference.

GrndMasterFlash
March 11th, 2009, 03:08 PM
im actually not declaring url_req twice, Im declaring it out side of the function once, but in the function im giving i a new value a clean slate if you will, and now that i look at it i left out an important part, the s:String, so when i say url_req = new URLRequest(s); im reall just putting the value of my new Request in my main Request

btw, im editing my code to fix the loadThis function



fucntion loadThis(s:String)
{
url_req = new URLRequest(s);
loader = new Loader;
loader.contentLoaderInfo.addEventListener("complete", handleLoadedObj);
loader.load(url_req);
addChild(loader);
}



**edit **
^what he said

wolverinejoe80
March 11th, 2009, 03:08 PM
thanks guys!! so place that code at the end of the keyline? i don't know where to put it..

anyway i just bought a flash book and man it's all gibberish to me.. i thought trying to make html website is hard.. flash is another planet.. damn!

well, i'll try it and if it doesn't work, i'll beg again for a help! thanks guys!!

GrndMasterFlash
March 11th, 2009, 03:13 PM
copy and past the code to the first frame of your movie, then any time you want simply write

loadThis("http://thisiswhyyourefat.com/")

and it shall be loaded!!! :D

wolverinejoe80
March 11th, 2009, 03:15 PM
i inserted that code at the end of keyline(i created a blank key frame in a new layer), and i get this message..

1071: Syntax error: expected a definition keyword (such as function) after attribute fucntion, not loadThis.

wolverinejoe80
March 11th, 2009, 03:16 PM
copy and past the code to the first frame of your movie, then any time you want simply write

loadThis("http://thisiswhyyourefat.com/")

and it shall be loaded!!! :D


ok! i placed at end end! will try right now.

wolverinejoe80
March 11th, 2009, 03:18 PM
i still get a same message.. is there anyway i can attach my fla file here?

GrndMasterFlash
March 11th, 2009, 03:21 PM
yeah, when you write your next post click the paper clip and you can attach files, you might want to zip it first as the size of what you can attach is rather limited


***edit***

ahhhh, im such a bad speller i wrote fucntion instead of function, god im so stupid, blah!!!

ok, going to edit the example code for the 3rd time :(

the error was caused by my spelling error btw.....

wolverinejoe80
March 11th, 2009, 03:32 PM
ouch.. my file is 1.3mb because of images... i'll attach one without the images on it..

wolverinejoe80
March 11th, 2009, 03:34 PM
i'm uploading the fla without the images. thanks for the help!! i really really appreciate it!

GrndMasterFlash
March 11th, 2009, 04:37 PM
ok, have fun with that,
i put in to different loading methods

loadThis and loadURL

loadURL is like an <a> tag in html so loadURL("http://blah.com") will open a new window with blah.com

while loadThis loads images and other .swf files, anyways, this should give you something to play with :D

wolverinejoe80
March 11th, 2009, 04:59 PM
thanks!

i just tried it, but it loads at the beginning of the website. can it play after the movie is over?

wolverinejoe80
March 11th, 2009, 05:01 PM
never mind, i figured it out! thanks master flash!

GrndMasterFlash
March 11th, 2009, 05:02 PM
yeah, any time you want to load a page just make the call using loadURL("blah");
and it'll work anywhere you want ;)