A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: strict mode

  1. #1
    Senior Member creekmonkey's Avatar
    Join Date
    Jul 2006
    Posts
    121

    strict mode

    Ok as I am totally new to as3 i tried making a simple one element movie and exporting as flash 9

    in my start script i have

    my_element=element("my_element");

    when i run the movie i get the error

    property'my_element' used without first being declared in strict mode

    what have I missed? What is strict mode and how do I declare an element in strict mode?

  2. #2
    Senior Member kusco's Avatar
    Join Date
    Nov 2001
    Posts
    681
    In 3DFA Flash 9 export, you need to declare your variables before using them.

    Sometimes its simply a matter of putting a 'var' before the assignment ...

    var my_element = element ("my_element");

    However, if you want my_element to become a property of the movie, with a value that persists over time and is accessible to other scripts, then you need to declare "var my_element" in the "Properties" tab of the "Movie script".

    In the next release though, 3DFA will be merging the Properties tab and adopting the same compromise that Flash 9 uses, where any variable declared outside of a function will become a property. Its not the most efficient way, but its easier and more compatible with both Flash and older 3DFA projects.

    In any case, you still need to declare your variables before using them. Thats the difference, variable names need to be declared with a simple 'var' before being assigned their first value. It could be worse though, in strict AS3, you must also include the variable type in the declaration, so you would have write ...

    var my_element:* = element ("my_element");

    The * indicates that the variable can take any kind of type. But you can be more specific with the variable type, forcing the variable to only ever accept, for example, a string or a number ...

    var my_string:String = "hello";
    var my_number:Number = 42;

    A value will be automatically be converted to the desired type, if possible, before being assigned to those variables.

    Old school programmers like myself, though, might think that these official AS3 declarations look overly complicated, and so 3DFA also allows you to use C# declarations ...

    string my_string = "hello";
    int my_number = 42;
    float my_number = 42.5;

    3DFA will also soon be accepting C# function declarations and other C# syntax to help old school programmers like myself to migrate to ActionScript 3, like everyone should.
    Last edited by kusco; 08-13-2007 at 05:19 PM.
    Cheers,
    kusco
    (3DFA Support Team)

  3. #3
    Senior Member
    Join Date
    Dec 2006
    Posts
    274
    Quote Originally Posted by kusco
    Old school programmers like myself, though, might think that these official AS3 declarations look overly complicated, and so 3DFA also allows you to use C# declarations ...

    string my_string = "hello";
    int my_number = 42;
    float my_number = 42.5;

    3DFA will also soon be accepting C# function declarations and other C# syntax to help old school programmers like myself to migrate to ActionScript 3, like everyone should.
    Yep, java, C#, C styles are more familar to me also, that as3 style looks like Pascal or Delphi to me
    But most important to me in future 3dfa will be that it's scripting is consistent, like if I see some AS3 example, I want to be able to "convert" it to the 3dfa without too much hassle.. so AS3 class/event/variable etc. declaration and usage should be straightforward and not confusing... (I'm not saying it is confusing )

  4. #4
    Senior Member kusco's Avatar
    Join Date
    Nov 2001
    Posts
    681
    Flash 9 compatibility is one of 3DFA's highest priorities.

    The language syntax, and the available classes will continue to grow to the point where most AS3 samples should be able to be dropped directly into 3DFA to run without changes.

    And even if you program using C# syntax, you should always be able to export your project as AS3 source code that can be dropped directly into Flash or Flex.

    The next version of 3DFA contains the ability to program classes.
    Cheers,
    kusco
    (3DFA Support Team)

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