A Flash Developer Resource Site

Results 1 to 15 of 15

Thread: Fucntion to generate Random Number in AS 2.0

  1. #1
    Animator
    Join Date
    Jan 2001
    Location
    Dubai
    Posts
    200

    Fucntion to generate Random Number in AS 2.0

    Hello all

    Can anyone help in creating a fucntion in AS 2.0 to generate random number every time get accessed and can be called in front of the XML link from which i am pulling the data from, the purpose is to call the XML always from server to that we never get cached results in swf.


    Thanks in advance

    F.
    fahad.bhatti@gmail.com
    I won't change directions and i won't change my mind, How much difference does it made?

  2. #2
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    force fresh data with -

    myXML.load("some.xml?vers="+new Date().getTime());

  3. #3
    Animator
    Join Date
    Jan 2001
    Location
    Dubai
    Posts
    200

    Data binding issues in XML

    Hi

    Can i use that with the url like below in flash:

    XMLurl = "http://www.domain.com?vers="+new Date().getTime();+";

    one more issue just raised up, which is if any one who access our page for the first time, they get the values as "undefined" but when they refresh the page again they get the values coming in from the XML correctly, is it something related to cache swf/xml or some thing else?

    Thanks
    Fahad.
    fahad.bhatti@gmail.com
    I won't change directions and i won't change my mind, How much difference does it made?

  4. #4
    Animator
    Join Date
    Jan 2001
    Location
    Dubai
    Posts
    200
    and heres how i am calling my flash files in for IE and !IE browsers:

    <div id="HighlightSectionHolder">

    <object classid="clsid27CDB6E-AE6D-11cf-96B8-444553540000" width="770" height="276" Id="Spotlight_en_gb" wmode="transparent" name="Spotlight_en_gb">
    <param name="movie" value="Movies.swf" />
    <param name="wmode" value="transparent" />
    <param name="menu" value="false" />
    <!--[if !IE]>-->
    <object type="application/x-shockwave-flash" data="Movies.swf" width="770" height="276" wmode="transparent">
    <!--<![endif]-->
    <!--Non Flash Content-->
    Alternate Flash Content
    <!--Non Flash Content End-->
    <!--[if !IE]>-->
    </object>
    <!--<![endif]-->
    </object>

    </div>
    <script type="text/javascript">CountryCode();</script>
    fahad.bhatti@gmail.com
    I won't change directions and i won't change my mind, How much difference does it made?

  5. #5
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    to force the browser to load a new file each time

    <PARAM NAME=movie VALUE="Movies.swf?" + new Date().getTime() />

    also, check this link -

    http://kb.adobe.com/selfservice/view...nalId=tn_14743

  6. #6
    Animator
    Join Date
    Jan 2001
    Location
    Dubai
    Posts
    200
    Hi

    shouldnt there be a ; at the end of the param?

    <PARAM NAME=movie VALUE="Movies.swf?" + new Date().getTime(); />

    or will it work exactly as you mentioned?

    F.
    fahad.bhatti@gmail.com
    I won't change directions and i won't change my mind, How much difference does it made?

  7. #7
    Animator
    Join Date
    Jan 2001
    Location
    Dubai
    Posts
    200
    I am also using one !IE condition for synching the file with the non IE browsers, i have added up the cache buster in itlike this:

    <object type="application/x-shockwave-flash" data="$Common/Data/HomePageData/Movies.swf?" + new Date().getTime(); +" width="770" height="276" wmode="transparent">

    Is this the right way to embed in the object type ?
    fahad.bhatti@gmail.com
    I won't change directions and i won't change my mind, How much difference does it made?

  8. #8
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    let me know the results of your tests

  9. #9
    Animator
    Join Date
    Jan 2001
    Location
    Dubai
    Posts
    200
    Hi,

    1. The problem coming in is that I get the results ok in our internal network at work, checked it several other PCs and it worked well, but if checked from external networks say from other PCs at different locations it shows the undefined where the data should be coming in from XML, when they refresh the page by ctrl + F5 the results appears....

    Do you see any possibility with the XML or SWF caching? as i have added up the cache buster on both XML and SWF paths already.

    2. Secondly the Var value which is being thrown by the javascript everytime when page loads up and pulled by dynamic text box in flash does work in IE but not fetched in Firefoex, here is what i am writing up for calling up the flashes in my page:

    Code:
    <div id="HighlightSectionHolder">
    
      <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="770" height="276" Id="Spotlight_en_gb" wmode="transparent" name="Spotlight_en_gb">
        <param name="movie" value="Movies.swf?" + new Date().getTime(); />
        <param name="wmode" value="transparent" />
        <param name="menu" value="false" />
        <!--[if !IE]>-->
        <object type="application/x-shockwave-flash" data="Movies.swf?" + new Date().getTime(); +"" width="770" height="276" wmode="transparent">
        <!--<![endif]-->
                    <!--Non Flash Content-->
                   Alternate Flash content here
                    <!--Non Flash Content End-->
        <!--[if !IE]>-->
        </object>
        <!--<![endif]-->
      </object>
    
    </div>
    <script type="text/javascript">CountryCode();</script>
    and here is the JS which generates the ID:

    Code:
    function CountryCode(){
    	var tempObj = document.getElementById('Spotlight_en_gb');
    	if(tempObj)
    	{
    		tempObj.SetVariable('ccode', countryCode); 
    	}
    }
    The ccode is the variable name dynamic text box in my flash movies.swf, I have tried to give the id and name as 'Spotlight_en_gb' to the !IE object tag but that even didnt worked.


    Please give your thoughts on that,

    F.
    fahad.bhatti@gmail.com
    I won't change directions and i won't change my mind, How much difference does it made?

  10. #10
    Animator
    Join Date
    Jan 2001
    Location
    Dubai
    Posts
    200
    Do you think is it the getElementById issue that is not throwing the value in FireFox or is the Id being not given in the object tag for !IE.
    fahad.bhatti@gmail.com
    I won't change directions and i won't change my mind, How much difference does it made?

  11. #11
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    could be you are sending variables to the movie before it has completed loading ...?
    this might explain the Refresh..?

    look at the source code (Javascript and object/embed) in this file.
    can you make use of its logic ?

    http://www.jackleaman.co.uk/test/jav...-to-flash.html

  12. #12
    Animator
    Join Date
    Jan 2001
    Location
    Dubai
    Posts
    200
    testing the page without sending the variable on to it to see if woithout throwing the var if we get the results properly...
    fahad.bhatti@gmail.com
    I won't change directions and i won't change my mind, How much difference does it made?

  13. #13
    Animator
    Join Date
    Jan 2001
    Location
    Dubai
    Posts
    200
    Didnt worked out on external networks, and stays the same showing undefined on Load.
    fahad.bhatti@gmail.com
    I won't change directions and i won't change my mind, How much difference does it made?

  14. #14
    Animator
    Join Date
    Jan 2001
    Location
    Dubai
    Posts
    200
    Thanks for the link I am checking that for atleast getting it compatible with FF and IE both, will keep you posted on how did i get on....
    fahad.bhatti@gmail.com
    I won't change directions and i won't change my mind, How much difference does it made?

  15. #15
    Animator
    Join Date
    Jan 2001
    Location
    Dubai
    Posts
    200

    Unhappy

    Hi there

    I have checked your given link for setting the variable in flash, can you please check my test page and suggest any changes.


    Code:
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    <script type="text/javascript" src="swfobject.js"></script>
    
    <script type="text/javascript">
    swfobject.registerObject("Spotlight_en_gb", "8");
    
    function CountryCode(){
    	var tempObj = document.getElementById('Spotlight_en_gb');
    	if(tempObj)
    	{
    		tempObj.SetVariable('ccode', 'UAE'); 
    	}
    }
    </script>  
     
    </head>
    
    <body>
    
      <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="550" height="400" id="Spotlight_en_gb" wmode="transparent">
        <param name="movie" value="Vartest.swf?"/>
        <param name="wmode" value="transparent" />
        <param name="menu" value="false" />
        <!--[if !IE]>-->
        <object type="application/x-shockwave-flash" data="Vartest.swf?" width="770" height="276" wmode="transparent">
        <!--<![endif]-->
                    <!--Non Flash Content-->
                      Alternate Flash Content
                    <!--Non Flash Content End-->
        <!--[if !IE]>-->
        </object>
        <!--<![endif]-->
      </object>
    <script type="text/javascript">CountryCode();</script>
    </body>
    The values are getting in IE but not in FF, as there are two object tags but the id should be same.

    You can download the zipped version with everything from:
    http://www.showtimearabia.com/test/Var/2Objects1ID.zip

    Thanks
    F.
    fahad.bhatti@gmail.com
    I won't change directions and i won't change my mind, How much difference does it made?

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center