Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 08-30-2009, 02:45 PM   #1
eddjc
Registered User
 
Join Date: Aug 2009
Posts: 16
Default simple variable scope

Hey all,

Just trying to do something that seems like it should be simple-

ActionScript Code:
<mx:Script>         <![CDATA[ [Bindable] private var low:String = application.parameters.low; /* (left out for debugging) [Bindable] private var high:String = application.parameters.high; */ ExternalInterface.call("console.log", low);             ]]> </mx:Script>

That's just in the base Application element. for some reason, I get the error:

1120:Access of undefined property low

Any ideas why? I've tried removing the [Bindable], changing it to the public variable, getting rid of the word private, everything! Something I'm just not seeing?

Many thanks
Edd
eddjc is offline   Reply With Quote
Old 08-30-2009, 06:07 PM   #2
wvxvw
Holosuit User
 
wvxvw's Avatar
 
Join Date: Oct 2006
Location: Tel Aviv
Posts: 4,301
Send a message via ICQ to wvxvw
Default

<mx:Script/> is the place where you put declarations, you shouldn't execute code there, it's the same as if you did something like this in AS:
ActionScript Code:
package { ... public class Foo { ... ExternalInterface.call("console.log", low); ... public function Foo() { }}}
__________________
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 08-30-2009, 06:35 PM   #3
eddjc
Registered User
 
Join Date: Aug 2009
Posts: 16
Default

I'm not sure I follow you - although have worked out that the ExternalInterface command doesn't work from within a class definition (not sure why!) I did however manage to get this particular script working - the problem was that until the application os loaded, the parameters aren't available -

ActionScript Code:
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:controls="com.fxcomponents.controls.*"     backgroundColor="#444444" themeColor="#628CAF" backgroundGradientAlphas="{[0, 0]}"     paddingTop="0"     paddingLeft="0"     paddingRight="0"     paddingBottom="20"     creationComplete="initVars()">     <mx:Script>         <![CDATA[                         [Bindable]             private var appSource:String = "YDA medium.flv";                                     [Bindable]             private var low:String;                         [Bindable]             private var high:String;                                     function initVars():void {                                 low = Application.application.parameters.low;                 high = Application.application.parameters.high;                                 ExternalInterface.call("console.log", high);                 fxVid.source = low;                                 fxVid.low = low;                 fxVid.high = high;                                             }                         ]]>     </mx:Script>

but then you may be right - that might just work because it's inside a function! So in the MXML file code should be restricted to variable declaration, like an interface?

Many thanks
Edd
eddjc is offline   Reply With Quote
Old 08-30-2009, 07:22 PM   #4
wvxvw
Holosuit User
 
wvxvw's Avatar
 
Join Date: Oct 2006
Location: Tel Aviv
Posts: 4,301
Send a message via ICQ to wvxvw
Default

>> So in the MXML file code should be restricted to variable declaration, like an interface?
Yes, this is close, but not exact.
Try adding -keep optional compiler argument to see what comes out of your MXML files, this would explain it better.
__________________
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 08-30-2009, 10:21 PM   #5
eddjc
Registered User
 
Join Date: Aug 2009
Posts: 16
Default

er... how do I do that from Flex builder?

Many thanks
Edd
eddjc is offline   Reply With Quote
Old 08-30-2009, 11:04 PM   #6
wvxvw
Holosuit User
 
wvxvw's Avatar
 
Join Date: Oct 2006
Location: Tel Aviv
Posts: 4,301
Send a message via ICQ to wvxvw
Default

See the picture:
Attached Thumbnails
Click image for larger version

Name:	flex-compiler-arguments.gif
Views:	73
Size:	28.9 KB
ID:	32145  
__________________
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 08-31-2009, 08:18 AM   #7
eddjc
Registered User
 
Join Date: Aug 2009
Posts: 16
Default

ah! Fascinating!

Many thanks
Edd
eddjc 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 07:46 AM.

///
Follow actionscriptorg on Twitter

 


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