A Flash Developer Resource Site

Page 1 of 2 12 LastLast
Results 1 to 20 of 23

Thread: AS2 to AS3 migration problems

  1. #1
    Member
    Join Date
    Oct 2006
    Posts
    36

    AS2 to AS3 migration problems

    import flash.external.ExternalInterface;
    var cookieValue: = ExternalInterface.call("myGetCookie", "yumyum");
    if (cookieValue==1) {this.gotoandplay(15)}


    This worked perfectly in AS2. But these people have compeletly changed everything with AS3. I get all kinds of errors in AS3. Any help on how to code this right in AS3?

    ReferenceError: Error #1056: Cannot create property ::cookieValue on global.
    at Timeline0_e48252b3c782d46a9f429a26c25bf69/::frame5()

    The ExternalInterfaceCall is calling a javascript which gets a cookie called yumyum.


    Please help...

  2. #2
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    I don't know your javascript and the context of your movie, but your syntax is wrong. This does not give any error.

    import flash.external.ExternalInterface;
    var cookieValue:int = ExternalInterface.call("myGetCookie", "yumyum");
    if (cookieValue == 1)
    {
    this.gotoAndPlay(15);
    }
    - The right of the People to create Flash movies shall not be infringed. -

  3. #3
    will i ever get it?
    Join Date
    Feb 2004
    Posts
    707
    after you call the variable, i think you are missing the datatype
    import flash.external.ExternalInterface;
    var cookieValue:ExternalInterface = ExternalInterface.call("myGetCookie", "yumyum");
    if (cookieValue==1) {this.gotoandplay(15)}

  4. #4
    Member
    Join Date
    Oct 2006
    Posts
    36

    error

    here is what i did.
    I just opened flash 9, created a new movie and in the first keyframe i inserted this code....

    import flash.external.ExternalInterface;
    var cookieValue:ExternalInterface = ExternalInterface.call("myGetCookie", "yumyum");
    hello_txt.text = cookieValue;




    this is what the javascript looks like

    <script language="javascript">
    function myGetCookie(boo)
    {
    alert(boo);
    return boo;
    }
    </script>




    and this is the error I get

    TypeError: Error #2007: Parameter text must be non-null.
    at flash.text::TextField/set text()
    at Timeline0_6dfaac927ac5345a43cd79566763588/::frame1()

  5. #5
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    You need to change the datatype to String. Here is your script tested:

    http://flashscript.biz/fk/extinterface/ext.html

    You will get this error when you test movie, because the player does not see any javascript.
    - The right of the People to create Flash movies shall not be infringed. -

  6. #6
    Member
    Join Date
    Oct 2006
    Posts
    36

    huh?

    Please pardon the ignorance. I do not know what you mean by change the datatype. Could you please paste the working code so that i can just copy and paste it.

    p.s. I hope not to stay ignorant forever.

  7. #7
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    import flash.external.ExternalInterface;
    var cookieValue:String = ExternalInterface.call("myGetCookie", "yumyum");
    hello_txt.text = cookieValue;
    - The right of the People to create Flash movies shall not be infringed. -

  8. #8
    Member
    Join Date
    Oct 2006
    Posts
    36

    still errors

    Now i get this error...

    ReferenceError: Error #1065: Variable Timeline0_1f2ce31a6b79bb4b844a593a7f64adbf is not defined.

    it seems like the command ExternalInterface.call("myGetCookie", "yumyum"); is not working.

  9. #9
    Member
    Join Date
    Oct 2006
    Posts
    36

    error here

    You can witness the error for yourself here ...

    http://myoperators.com/useless/bootycal.htm

  10. #10
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    I did not get the error. I placed of course a textfield on stage and published the movie and added the Javascript. What else do you have in the movie? On my mac on firefox I do not only get the little window but it displays yumyum also in the textfield.
    - The right of the People to create Flash movies shall not be infringed. -

  11. #11
    Member
    Join Date
    Oct 2006
    Posts
    36

    hmm

    I have no idea what is causing the error. I have nothing else in my fla file. I just created the file and pasted that code in keyframe 1 then exported.

    Can you please send me your fla file to skenglish@hotmail.co.uk. Maybe i can spot the problem if i compare the two files ...
    Last edited by 0gani; 10-09-2006 at 02:43 PM.

  12. #12
    half as fun, double the price senocular's Avatar
    Join Date
    Feb 2002
    Location
    San Francisco, CA (USA)
    Posts
    4,361
    call is a method that returns a value of * in AS3. You should give your cookieValue variable a datatype of * to reflect that. Then, when assigning to a text field in Flash, use String() to convert the value to a string.
    code:
    import flash.external.ExternalInterface;
    var cookieValue:* = ExternalInterface.call("myGetCookie", "yumyum");
    hello_txt.text = String(cookieValue);


    Keep in mind that you won't get the desired results testing in Flash since you need the HTML and JavaScript for ExternalInterface to interact with. Instead of testing, publish, then view your HTML in the browser.

    You should also refrain from using alerts in your ExternalInterface functions. They can wreak havoc.

  13. #13
    Member
    Join Date
    Oct 2006
    Posts
    36

    no luck

    Thanks senocular. I have made a little progress now.... at least i get an output on the screen....

    but the output is "null"


    here is the link...please advise
    www.myoperators.com/useless/bootycow.htm

    also, i am not getting any popup alerts...whats going on here
    Last edited by 0gani; 10-09-2006 at 03:09 PM.

  14. #14
    Member
    Join Date
    Oct 2006
    Posts
    36
    I tried this code

    Code:
    import flash.external.ExternalInterface;
    if(ExternalInterface.available){
        trace(ExternalInterface.call("myGetCookie", "yumyum"));
    }else{
        trace("ExternalInterface is not available");
    }
    I get this result
    www.myoperators.com/useless/b.htm

    The flash never fully loads.... it is just loading for ages... any ideas people ?

  15. #15
    Member
    Join Date
    Oct 2006
    Posts
    36

    the download

    here is the fla file here ..

    http://myoperators.com/useless/helloworld.fla

    you can download it and try to see where i am going wrong.

    Thanks in advance

  16. #16
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    Last edited by cancerinform; 10-09-2006 at 09:55 PM.
    - The right of the People to create Flash movies shall not be infringed. -

  17. #17
    Member
    Join Date
    Oct 2006
    Posts
    36

    no it doesnt

    ok, explain this. It is working perfectly in firefox, displaying "yumyum" in the popup and the screen output. But in IE there is no popup and output is null.

    What could cause this?

    Also, Cancerinform, are you aware that your swf files are causing errors in internet explorer? Is it because of your MAC. Because the error says that i do not have a ocx plugin and it crashes my IE.
    Last edited by 0gani; 10-10-2006 at 02:21 AM.

  18. #18
    Member
    Join Date
    Oct 2006
    Posts
    36

    wierd

    This AS2 works great in both IE and firefox
    Code:
    import flash.external.ExternalInterface;
    var cookieValue = ExternalInterface.call("myGetCookie", "yumyum");
    hello_txt.text = cookieValue;

    This AS3 works great only in firefox but not IE
    Code:
    import flash.external.ExternalInterface;
    var cookieValue:* = ExternalInterface.call("myGetCookie", "yumyum");
    hello_txt.text = String(cookieValue);
    What's wrong with this? What is it that IE doesnt like about this code in AS3?

  19. #19
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    There are many things wrong in IE. There are constant problems with audio for example. I have experienced some other problems with events.

    May be IE does not like any datatyping

    Yes, and I am a happy Mac user. I only use Safari and FF. The word IE has since long time been eliminated from the vocabulary of Mac users.

    Regarding ocx plugin the problem is on your site.
    - The right of the People to create Flash movies shall not be infringed. -

  20. #20
    Member
    Join Date
    Oct 2006
    Posts
    36
    Actually, after further research, i discovered the problem is with flash player 9. Something is wrong with the way it installs itself. I dont know what causes it and how to stop it.

    please tell me if you get an error on this page.... because i get an error in my browser.

    www.myoperators.com/useless/butterflys.htm

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