all groups > flash (macromedia) > december 2005 >
You're in the

flash (macromedia)

group:

loadMovie with HREF and ASfunction


loadMovie with HREF and ASfunction bigbrain28
12/19/2005 9:30:41 PM
flash (macromedia):
I have found bits and pieces to this answer, but none that are enuff help to
get my issue solved... I have the following AS attached to certain buttons:

on (press){loadMovieNum("A1.swf","1","GET");
unloadMovieNum(5);
}
(Which of course works fine for buttons within the main movie)

And what I need is to accomplish the same task via <a HREF...> from my
dynamically called text file; as in, I need my list of "links" in the text file
to load movies. I have already seen the <a
href="asfunction:myFunction,param">link</a> examples and also read that I need
to define that function... But I am just not getting it, and sadly I have to
ask for some hand holding, as I am not a AS coder at all! If someone could
help, or point me at a working example I would be quite grateful!


Thanks!
Re: loadMovie with HREF and ASfunction urami_
12/20/2005 7:39:50 AM


[quoted text, click to view]

First of all , the use of GET is no appropriate here. It is only when you work with
variables, not SWF files. so get rid off it.
In regard to the asfunction:

Following simple logic if we wonted to load movies (swf) or JPG into flash
and define level and the file name so it could use one function for countless
number of links w/o hard coded location (level) we would do something like :

function loadImage (location,level) {
level = Number(level) ; // this will convert the string to a number
loadMovieNum (location,level);
}

Now your link :
<A HREF='asfunction:loadImage,movie1.swf,60'>Link1</A>

However it will be wrong .
It won't work that way. If you trace out 'location' it will come up as 'movie1.swf,60'
loadMovieNum doesn't know what is that , it sees the 60 as part of the file name
it's getting send in the location var, not as a level var.
This will happen with most of the paramters.

You MUST split the string in the function...
The above should be :

function loadImage (qString) {
var params = new Array();
params = qString.split(",", 2);
var level = Number(params[1]);
loadMovieNum (params[0], level);
trace (params[0]);
trace (params[1]);
}

And than you cna use link in your text file line like :

<A HREF="asfunction:loadImage,movie1.swf,60">Link1</A>
or
<A HREF="asfunction:loadImage,movie2.swf,61">Link1</A>



Check :
http://www.macromedia.com/support/flash/ts/documents/asfunction.htm

--
Regards

Urami


--



Merry Christmas and a Happy New Year guys :)



クリスマスと新年おめでとうございます

聖誕節和新年快樂
圣诞节和新年快乐

<urami>
http://www.Flashfugitive.com
</urami>

<web junk free>
http://www.firefox.com
AddThis Social Bookmark Button