• passing data from HTML to Flash


    http://www.actionscript.org/forums/showthread.php3?t=125761

    I'm trying to pass a title and filename which are or will be set in the html page. at the moment in the html page im setting the as

    Code:
    <param name="txttitle" value="dentist" /><param name="filename" value="mo.flv" />
    and I'm using the following to try get them into the swf...
    Code:
    loadVariables("index.htm", "txttitle");loadVariables("index.htm", "filename");
    any ideas?
    theste is offline   Reply With Quote
    Old 01-12-2007, 03:04 PM   #2
    Super Moderator
     
    CyanBlue's Avatar
     
    Join Date: Jan 2002
    Location: Centreville, VA
    Posts: 25,003
    Default

    Howdy and Welcome...

    You have to use FlashVars to pass in the variables in HTML...
    Please check this thread...
    http://www.actionscript.org/forums/s....php3?t=125702
    __________________
    CyanBlue / Jason Je / Macromedia Certified Flash Developer & Designer
    http://CyanBlue.FlashVacuum.com
    http://www.FlashVacuum.com
    http://tutorials.FlashVacuum.com

    Do NOT PM, Email or Call me... Your question belongs right in this forum...
    CyanBlue is offline   Reply With Quote
    Old 01-12-2007, 03:14 PM   #3
    Registered User
     
    Join Date: Jan 2007
    Posts: 31
    Default

    ok, so i need the Flashvars tag/thing somewhere in the PARAM tag? so what/how would i get it in my action script, or would it have been loaded automatically and i can just refer to it where needed without anything like loadVariables("nnn" "mmm");
    theste is offline   Reply With Quote
    Old 01-12-2007, 03:33 PM   #4
    Super Moderator
     
    CyanBlue's Avatar
     
    Join Date: Jan 2002
    Location: Centreville, VA
    Posts: 25,003
    Default

    If you provide the variable via FlashVars, you can access it like _root.variableName and it should work... and that's exactly what I have said in that thread...
    __________________
    CyanBlue / Jason Je / Macromedia Certified Flash Developer & Designer
    http://CyanBlue.FlashVacuum.com
    http://www.FlashVacuum.com
    http://tutorials.FlashVacuum.com

    Do NOT PM, Email or Call me... Your question belongs right in this forum...
    CyanBlue is offline   Reply With Quote
    Old 01-12-2007, 03:38 PM   #5
    Registered User
     
    Join Date: Jan 2007
    Posts: 31
    Default

    aye, atm i now have
    Code:
    <PARAM NAME=FlashVars VALUE="sr_title=dentist&sr_url=mo.flv">
    in the HTML

    and in the Actionscript i have
    Code:
    function SetValue() {showreel_title = _root.sr_titleshowreel_url = _root.sr_url}
    and im using those variables here
    Code:
    stream_ns.play(showreel_url);txtPlay.text = showreel_title & "Showreel Loading, Please Wait...";
    but its still not working :?
    theste is offline   Reply With Quote
    Old 01-12-2007, 03:49 PM   #6
    Super Moderator
     
    CyanBlue's Avatar
     
    Join Date: Jan 2002
    Location: Centreville, VA
    Posts: 25,003
    Default

    Let's add some trace lines and tell me what you get...
    First, create a textField somewhere and give it an instance name of 'output_txt'... and add the following lines...
    ActionScript Code:
    stream_ns.play(showreel_url);txtPlay.text = showreel_title & "Showreel Loading, Please Wait...";output_txt.text += "showreel_title = " + showreel_title + "<br>";output_txt.text += "showreel_url = " + showreel_url + "<br>";output_txt.text += "_root.sr_title = " + _root.sr_title + "<br>";output_txt.text += "_root.sr_url = " + _root.sr_url + "<br>";
    __________________
    CyanBlue / Jason Je / Macromedia Certified Flash Developer & Designer
    http://CyanBlue.FlashVacuum.com
    http://www.FlashVacuum.com
    http://tutorials.FlashVacuum.com

    Do NOT PM, Email or Call me... Your question belongs right in this forum...
    CyanBlue is offline   Reply With Quote
    Old 01-12-2007, 03:54 PM   #7
    Registered User
     
    Join Date: Jan 2007
    Posts: 31
    Default

    I got this returned

    Code:
    showreel_title = undefined<br>showreel_url = undefined<br>_root.sr_title = undefined<br>_root.sr_url = undefined<br>

    Last edited by theste; 01-12-2007 at 04:05 PM..
    theste is offline   Reply With Quote
    Old 01-12-2007, 04:05 PM   #8
    Super Moderator
     
    CyanBlue's Avatar
     
    Join Date: Jan 2002
    Location: Centreville, VA
    Posts: 25,003
    Default

    Um... Are you testing it over the web browser??? What's your embed tag look like???
    __________________
    CyanBlue / Jason Je / Macromedia Certified Flash Developer & Designer
    http://CyanBlue.FlashVacuum.com
    http://www.FlashVacuum.com
    http://tutorials.FlashVacuum.com

    Do NOT PM, Email or Call me... Your question belongs right in this forum...
    CyanBlue is offline   Reply With Quote
    Old 01-12-2007, 04:09 PM   #9
    Registered User
     
    Join Date: Jan 2007
    Posts: 31
    Default

    heres all my code, well most of it
    Code:
    var connection_nc:NetConnection = new NetConnection();connection_nc.connect(null);var stream_ns:NetStream = new NetStream(connection_nc);stream_ns.play(showreel_url);txtPlay.text = showreel_title & "Showreel Loading, Please Wait...";output_txt.text += "showreel_title = " + showreel_title + "<br>";output_txt.text += "showreel_url = " + showreel_url + "<br>";output_txt.text += "_root.sr_title = " + _root.sr_title + "<br>";output_txt.text += "_root.sr_url = " + _root.sr_url + "<br>";//function SetValue() {showreel_title = _root.sr_title;showreel_url = _root.sr_url;//}my_video.attachVideo(stream_ns);stream_ns.play(showreel_url);stream_ns.pause();txtLoad.text = "LOADING";txtPlay.text = showreel_title & "Showreel Loading, Please Wait...";but_play._visible = 0;but_pause._visible = 0;this.loaded_txt(this.getNextHighestDepth(), 10, 10, 160, 22);var loaded_interval:Number = setInterval(checkBytesLoaded, 500, stream_ns);function checkBytesLoaded(my_ns:NetStream) {    var pctLoaded:Number = Math.round(my_ns.bytesLoaded / my_ns.bytesTotal * 100);    loaded_txt.text = Math.round(my_ns.bytesLoaded / 1000) + " of " + Math.round(my_ns.bytesTotal / 1000) + " KB loaded (" + pctLoaded + "%)";    progressBar_mc.bar_mc._xscale = pctLoaded;if (pctLoaded >= 15) {txtLoad.text = "READY";txtPlay.text = "Press Play When Ready";but_play._visible = 1;but_pause._visible = 0;}    if (pctLoaded >= 100) {        clearInterval(loaded_interval);    }}
    and my HTML page Object tag...

    Code:
    <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="270" height="230" id="preloader" align="middle"><PARAM NAME=FlashVars VALUE="sr_title=dentist&sr_url=mo.flv"><param name="allowScriptAccess" value="sameDomain" /><param name="movie" value="preloader.swf" /><param name="play" value="false" /><param name="loop" value="false" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /><embed src="preloader.swf" play="false" loop="false" quality="high" bgcolor="#ffffff" width="270" height="230" name="preloader" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>
    Im testing it on my own server

    http://www.theste.co.uk/kaka/index.htm
    theste is offline   Reply With Quote
    Old 01-12-2007, 04:13 PM   #10
    Super Moderator
     
    CyanBlue's Avatar
     
    Join Date: Jan 2002
    Location: Centreville, VA
    Posts: 25,003
    Default

    That script should work on IE... But not in FF because you are not providing the FlashVars for the EMBED tag...
    Can you verify what I just said???
    __________________
    CyanBlue / Jason Je / Macromedia Certified Flash Developer & Designer
    http://CyanBlue.FlashVacuum.com
    http://www.FlashVacuum.com
    http://tutorials.FlashVacuum.com

    Do NOT PM, Email or Call me... Your question belongs right in this forum...
  • 相关阅读:
    P4329 [COCI2006-2007#1] Bond
    P4802 [CCO 2015]路短最
    1-4-14:计算邮资
    1-4-13:分段函数
    1-4-12:骑车与走路
    1-4-11:晶晶赴约会
    1-4-10:有一门课不及格的学生
    1-4-09:判断能否被3,5,7整除
    1-4-08:判断一个数能否同时被3和5整除
    1-4-07:收集瓶盖赢大奖
  • 原文地址:https://www.cnblogs.com/cy163/p/1632962.html
Copyright © 2020-2023  润新知