Home Tutorials Forums Articles Blogs Movies Library Employment Press Buy templates

Go Back   ActionScript.org Forums > Flex > Flex 2 & 3

Reply
 
Thread Tools Rate Thread Display Modes
Old 11-03-2009, 08:23 PM   #11
wvxvw
Holosuit User
 
wvxvw's Avatar
 
Join Date: Oct 2006
Location: Tel Aviv
Posts: 3,240
Send a message via ICQ to wvxvw
Default

Sure . Create a new AS class file and do there whatever you want.
But mind it, there's no coding outside the function definitition, and, nope, no language allows coding outside the functions, except, maybe Assembler not those you mentioned, that's for certain.
__________________
The .NET open source editor for Flash and web developers
*This would be my contribution to the project*
couchsurfing if you need it
wvxvw is offline   Reply With Quote
Old 11-03-2009, 08:27 PM   #12
Aphalin
Registered User
 
Join Date: Oct 2009
Posts: 16
Default

Ummm sorry - did not get it - so you are saying there is absolutly no way, not is actionscript 2 not in actionscript 3 not using Flash CS 2/3/4 not using Flex IDE, not using externale .as files to run code outside of a function?

P.S. >no language allows coding outside the functions, except, maybe Assembler not those you mentioned

ehhh in C# or javascript
var i=5;
i=4;
outside of a function is perfectly legal and works... and always worked...

Last edited by Aphalin; 11-03-2009 at 08:30 PM..
Aphalin is offline   Reply With Quote
Old 11-03-2009, 09:26 PM   #13
wvxvw
Holosuit User
 
wvxvw's Avatar
 
Join Date: Oct 2006
Location: Tel Aviv
Posts: 3,240
Send a message via ICQ to wvxvw
Default

Just for the general info:
that code will work in JS because all the JS code is called from an eval() function which is in it's turn called from some browser onLoad function, which is called by some other function etc. You may not see it right away, but, that doesn't mean it doesn't exist.
Similarly, C#, launches the main thread, which in it's turn launches other threads, which are basically functions etc, etc.
Well, if you don't like the "function" keyword, then, you know, you can just put more line breaks after it and before the next function, so you won't see them in the code editor, that will basically have the same effect...
__________________
The .NET open source editor for Flash and web developers
*This would be my contribution to the project*
couchsurfing if you need it

Last edited by wvxvw; 11-03-2009 at 09:31 PM..
wvxvw is offline   Reply With Quote
Old 11-03-2009, 10:02 PM   #14
Aphalin
Registered User
 
Join Date: Oct 2009
Posts: 16
Default

This is very well known (i think everythink but bios is then a function). My point was only that all languages by "their" standart allow outfunction scripting (since Flash action script has even loger stack then javascript, when is played in browser - and same length with C# that uses silverlight). And that is extremely weird for me, since in no tutorial it is mentioned, not many people seems to know about it (how come???), and ECMA standarts allow outfunction scripting (not sure about new 2007 ECMA standarts but actionscript 2 is older i think)
But what to do... i guess i ll have to go through all of my 50k of code lines by hands (((

>"if you don't like the "function" keyword
If only the problem was that i do not like functions keyword so much...

> line breaks after it and before the next function
Won't work all variables will be gone after the execution.

Thank you for the reply.

Last edited by Aphalin; 11-03-2009 at 10:14 PM..
Aphalin is offline   Reply With Quote
Old 11-04-2009, 12:01 AM   #15
wvxvw
Holosuit User
 
wvxvw's Avatar
 
Join Date: Oct 2006
Location: Tel Aviv
Posts: 3,240
Send a message via ICQ to wvxvw
Default

Well, you see... MXML isn't really a proper place for putting scripts... it's for layout, that is to call the methods of the class, for which it is a visual representation. MXML language is in no way an ECMAScript language... well, I think, you would've notice, it is basically an XML variant... it is a template for generating AS3 files, which, in their turn are more ES-like... But, to be honest, ES and AS aren't best friends... ES made much more sense in earlier editions of AS, when it was pure scripting language... This isn't entirely true any more...

Besides,
Quote:
Won't work all variables will be gone after the execution.
Is just wrong. If you declare a variable in the class, than, as long as an instance of that class lives, the variable lives with it. If you declare a variable in the package, the variable lives until the SWF containing that package isn't unloaded, but if you declare a variable in the default (top-level) package, then the variable exists until you don't navigate to a different HTML page.
But, the rules of the language are so that you cannot perform operations on variables at the same place you define them, and, no modern language will allow you to do such thing, neither C#, nor Java, not even PHP.

What you tried to do, would be in PHP:
PHP Code:
<?php
class Foo
{
    public 
$bar 1;
    
$bar 2;
    public function 
Foo(){}
}
?>
Quote:
Parse error: syntax error, unexpected T_VARIABLE, expecting T_FUNCTION in C:\xampp\xampp\htdocs\foo.php on line 5
Or, in C#
ActionScript Code:
namespace Foo {     public class Bar     {         private String foo = "";         foo = "bar";     } }
Quote:
Invalid token '=' in class, struct or interface member declaration
And I'm just to lazy to open Netbeans and see what the error would look like in there
__________________
The .NET open source editor for Flash and web developers
*This would be my contribution to the project*
couchsurfing if you need it
wvxvw is offline   Reply With Quote
Old 11-04-2009, 02:35 AM   #16
DocWatson
Registered User
 
Join Date: Jan 2008
Posts: 43
Default

You're going about using Flex the wrong way, I think. Flex is essentially a markup language for generating Actionscript. The tags are basically a way to shorten/simplify Actionscript syntax at write-time, which then get expanded into actual Actionscript at compile-time. That's why you can't do what it is you're doing in the OP.

I don't have Flex Builder installed on this machine (I have it at work), but have you tried <mx:Number /> tags, if they exist? e.g. <mx:Number id="i" value="2" /> or something along those lines?

/edit: WVXVW beat me to it

Last edited by DocWatson; 11-04-2009 at 02:35 AM.. Reason: Beaten to the punch
DocWatson is offline   Reply With Quote
Old 11-04-2009, 08:04 AM   #17
Aphalin
Registered User
 
Join Date: Oct 2009
Posts: 16
Default

wvxvw
Ehhh well... you know these long nights after days of sleep deprivation? That was the one for me Right - no scripting outside of functions (god damn 5 years of .Net were obviously a waste for me ) Thanks

>Won't work all variables will be gone after the execution.
>>Is just wrong. If you declare a variable in the class, than, as long as an instance of that class lives, the variable lives with it.
- That was a reply to your suggestion to make a gigantic function with all other functions and variables declared in it which whould allow "global" scripting compare to functions in a function - but even if it is done in class instance, variables will still be collected once function is over, as they are local for the instance. (or did i understand you wrong first/second time?)

omega_platypus
>I think. Flex is essentially a markup language for generating Actionscript
I personally think so too =) but too newb in ac to make public anouncment.

In any case thank you all, in just 10 hours i cleared my code
Aphalin is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 11:39 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2009 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.