Results 1 to 9 of 9

Thread: Passing Number variable to Flash

  1. #1
    Join Date
    Jan 2007
    Location
    Charlotte, NC
    Posts
    82
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Passing Number variable to Flash

    I need to know how to pass a number variable to a Flash movie from swfObject. Currently the variable being passed is being read as a string.

    Anybody got any ideas?

    Thanks,

    Jeff

  2. #2
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    If you put your variable in quotes it is a string, no matter what the content is. The best way is correct scripting.

    in Flash when you declare your var use this format:

    Code:
    var varName:Number = 0;
    Then in your swfObject don't use quotes. just pass the number.
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  3. #3
    Join Date
    Nov 2007
    Location
    Canada
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    you must be kidding me!!!!!
    Blizard!!!
    have you ever tested what ur talking about that would always define your variable to be = 0 .

    the way to do it jamiller is the following code.

    var newVar:Number = Number(varName);


    where newVar is the variable you will be using in the flash file and varName is the variable created by swfobject.


    Have fun!!!!

    contact me if u need further help!!


    ... ByVisual ...

  4. #4
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    Actually, no it won't. This will start the number as 0. It won't change until code or action change it.

    Using your example, your number will always equal itself, you lose any math abilities. While this is good for a function where the number won't change, it loses any changeability based on other functions. You will always have to declare the variable as a whole, instead of a variable.

    There are multiple ways to do many things, but if you want to code less, declare less. Now instead of setting a base number, and have the chance to change it based on multiple ways, you make him declare 2 variables, changing each anytime he wants to pass a new number.

    var varName: Number = 0;

    sets varName to 0. Want to change it?

    with a button?

    Code:
    on (release) {
         _root.varName += 1;
         trace(_root.varName);
    }

    on a specific action?

    Code:
    onClipEvent (enterFrame) {
    	if (_root._currentframe == 1) {
    		_root.myNum += 1;
    		trace(_root.myNum);
    	} else {
    		_root.myNum == 0;
    		trace(_root.myNum);
    	}
    }
    and on.. and on...

    So to answer your question, yes I do know what I am talking about, yes I do test my codes.. perhaps you can take the codes I have provided here and test them yourself?

    If that would be too advanced for you I can provide an fla.
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  5. #5
    Join Date
    Nov 2007
    Location
    Canada
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Cool

    " I need to know how to pass a number variable to a Flash movie from swfObject. Currently the variable being passed is being read as a string.

    Anybody got any ideas?

    Thanks,

    Jeff "


    it has nothing to do with math!!!! its a variable being defined in html and thrown into flash. so what he needs is a simple fix that would change his variable from a string to a number. get it!!

    by defining the variable as a number and setting it = 0 that does not work. because the variable sent in by swfObject is set once on the load of the movie. thats why the best way is to transform it into another variable which is also a number. then whatever you want to do from adding to subtracting to complex physics equations all is possible the important thing is that the loaded variable is a number.

    I totally understand what you are trying to say!! it would have worked out if jeff is not using swfobject. get it!!!

    please try it out using swfobject!!!

    your way would never give him the initial value of the variable input in the swfobject.

  6. #6
    Join Date
    Jul 2006
    Location
    just north of Boston, MA
    Posts
    1,806
    Thanks
    13
    Thanked 72 Times in 72 Posts

    Default

    Quote Originally Posted by byvisual View Post
    you must be kidding me!!!!!
    Blizard!!!
    Quote Originally Posted by byvisual View Post
    it has nothing to do with math!!!! its a variable being defined in html and thrown into flash. so what he needs is a simple fix that would change his variable from a string to a number. get it!!
    ...
    ...
    I totally understand what you are trying to say!! it would have worked out if jeff is not using swfobject. get it!!!

    please try it out using swfobject!!!

    your way would never give him the initial value of the variable input in the swfobject.
    Please watch your tensing and tone... Blizzard, nor anyone here does not deserve your tone whether he is correct or not. if you believe he is wrong then you can just state it, but the extra exclamation points are not necessary, and frankly very rude.
    This is a volunteer, I will repeat volunteer, forum and thus he is not getting paid to help you, or jamiller, or anyone. We thank you for your opinions, and I am not saying Blizzard is right or wrong because I know nothing about flash, but I took offense to the blatant attack to a member that knows his stuff and is here day by day attempting to help people out. No one here is perfect, (not even you Twey and John ) so in the future just please watch how you respond to the question(s) here.

    Edit:
    now from a general coding stand point,

    Quote Originally Posted by jamiller
    I need to know how to pass a number variable to a Flash movie from swfObject. Currently the variable being passed is being read as a string.
    this seems to be a problem of type casting? just as you stated byvisual

    as I stated before I do not know anything about flash, but if there is a method by which you can type cast the string into a number, in theory that should solve the question

    in either event though Jamiller, it would probably be best if you could possibly show us some actual code wrapping it in [code] tags (for formatting)... I know many people have some skepticism about releasing their code, however you do not need to release the whole thing, just the snippet causing the problem.... we would nis dealing with this problem
    eed both the user-input and the variable-processing code please.
    Last edited by boogyman; 11-28-2007 at 10:03 PM.

  7. #7
    Join Date
    Nov 2007
    Location
    Canada
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    your right, boogyman

    now reading it over i was a bit tense in my language. and i do tend to use allot of exclamation marks!

    never meant to offend anybody but on all sides sorry if i did.

    sorry blizzard for the high tone of replies but please look into what i was talking about, and if you do have other solutions please let me know about I'm always happy to learn new ways for things.


    ...ByVisual...

  8. #8
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    There are many ways to do such, and as the OP states he doesn't want a string read as a number, his number is being read as a string. The basic cause for thisis Flash reads variables based on the code inside thefla, if it is en-quoted ("like this") it is a string. If there are no quotes it is a value (in the OP's case, a number).

    Based on this knowledge, the OP most likely has a number variable inside his AS coding.

    Now, he is using SWFObject to exploit this number in some way, and if it is a number it is probably a counter, a score, or some other mathematical increase/decrease for a game or a hit counter, etc. Which means this number will change, based on the actions of the user or the page it is on, etc.

    If he is just passing a variable from HTML to the Flash he would be better off with FlashVars anyway.

    It also depends on the version of Flash being used. All of this, both your and my replies are based on speculation as to what the OP really wants. Until we get more information we can just post our thoughts and let him try all of them until one works, and then hopefully he will post back telling one of us thanks, at which point we can figure out more.

    That's usually the way it works.

    As far as the tone and use of exclamation... To each his own.
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  9. #9
    Join Date
    Dec 2007
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Flash is unfathomable for a beginner.

Bookmarks

Posting Permissions

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