View Full Version : Using vectors (typed arrays) with Flex 3?
somerandomdude
October 31st, 2008, 03:03 PM
I've downloaded Flex 3 and got it working, and I'm trying to create a vector array of integers using the line of code below, but when i compile I get an error highlighting "Vector" and saying it's not a compile time constant. I'm a total newb to Flex (i only got it working thanks to senoculars tutorial), so I'm wondering if there's some extra thing i have to download to use Flash Player 10 stuff like vectors? Or is there something else I'm doing wrong? I downloaded Flex 3 from adobe's website fairly recently...
var thing:Vector.<int>=new Vector.<int>;
EDIT: Btw, i'm using the Flex SDK, NOT Flex Builder
theCodeBot
October 31st, 2008, 03:48 PM
It isn't Vector.
Look up Sprite.graphics, it has tools to draw lines, circles, gradients, rectangles, and pretty much everything you have in the Flash Drawing IDE, except turned into code.
If you want to load up images you created externally via flex rather than loading up library assets in flash, create something in Photoshop and load it up using the <mx:Image/> component, a lot easier than trying to manually code vectors.
somerandomdude
October 31st, 2008, 04:01 PM
It isn't Vector.
Look up Sprite.graphics, it has tools to draw lines, circles, gradients, rectangles, and pretty much everything you have in the Flash Drawing IDE, except turned into code.
If you want to load up images you created externally via flex rather than loading up library assets in flash, create something in Photoshop and load it up using the <mx:Image/> component, a lot easier than trying to manually code vectors.
Hehe I'm talking about the Vector class, which allows the user to use typed arrays (arrays of ints, strings, sprites, etc) , not drawing with vector graphics. But thanks for the reply :) I wish they didn't name the damn thing "vector"; i've been doing searches online and it's a pain in the *** sorting through all the results for vector graphics
wvxvw
October 31st, 2008, 04:14 PM
http://www.mikechambers.com/blog/2008/08/19/using-vectors-in-actionscript-3-and-flash-player-10/
http://livedocs.adobe.com/flex/gumbo/langref/package.html#Vector()
http://livedocs.adobe.com/flex/gumbo/langref/Vector.html
This should help.
But, as far as I can tell you're not using Flex SDK 4 (Vector support starts with SDK 4, though you can use FB3 with this SDK).
See this page for instruction on setting your FB to use with FP10 (SDK 4)
http://opensource.adobe.com/wiki/display/flexsdk/Targeting+Flash+Player+10+Beta
somerandomdude
October 31st, 2008, 04:47 PM
http://www.mikechambers.com/blog/2008/08/19/using-vectors-in-actionscript-3-and-flash-player-10/
http://livedocs.adobe.com/flex/gumbo/langref/package.html#Vector()
http://livedocs.adobe.com/flex/gumbo/langref/Vector.html
This should help.
But, as far as I can tell you're not using Flex SDK 4 (Vector support starts with SDK 4, though you can use FB3 with this SDK).
See this page for instruction on setting your FB to use with FP10 (SDK 4)
http://opensource.adobe.com/wiki/display/flexsdk/Targeting+Flash+Player+10+Beta
Oooh you're right; I'm using SDK 3 not 4. Thanks! I see they only have "nightly builds" available, do you know if any one of those are more stable than any of the others?
wvxvw
October 31st, 2008, 05:11 PM
I'd go for the last one :) Being honest I'm surprised it's already considered a "release" version... thought it's still in beta... but, apparently it's not, as long as there's Flash CS4... but that's just me being not updated :) I'd say that, if you're planning on releasing whatever you develop for FP10 in less than, ughm... maybe half a year, this would be considered "experimental", and you may have problems explaining to the customers they have to update the player =)
somerandomdude
October 31st, 2008, 05:20 PM
I downloaded the latest one, but it still doesn't recognize the Vector class :( I configured it to target Flash Player 10, so I don't know what the problem is
wvxvw
October 31st, 2008, 06:02 PM
Does it recognize it at least? meaning, does it highlight the word Vector / offers autocomplete options while you type it? And, BTW, usually you want to call constructors with (), so, your code should be:
var thing:Vector.<int> = new Vector.<int>();
even though, it's not mandatory, it's better to write it that way.
Another question: can you compile your project not from the IDE (just by running [your path to SDK]Flex_4_SDK\bin\mxmlc.exe) ?
Can you post your build file, if not?
theCodeBot
October 31st, 2008, 07:36 PM
Checking if it highlights isn't necessarily going to tell you if it supports it, setTimeout is supported and yet doesn't highlight and doesn't have code hints (In the Flash IDE anyways. I've only used it once since I started AS3, haven't tried in FB3 for Linux :P )
Stupid question, but I do this relatively often: Did you check if you're importing it? (Haven't played with this new Vecotr Class, I somehow didn't even know SDK 4 was available... is it out for Linux yet?) I know FlexBuilder automatically places import statements for most common classes like URLLoader, Rectangle, Bitmap... I doubt Vector would be there yet (flash.display.Vector, would it be?)
wvxvw
October 31st, 2008, 07:47 PM
Vector is a core class, so, you don't need to import it...
SDK 4 should be available for Linux... but you don't really need the whole SDK to compile FP10 content. What you need is a new playerglobal.swc and to set the compiler to -target-player=10.0.0. There're few more changes in the build file, like adding new intrinsic classes and new locale library.
And... to be honest I don't know if there actually is code hinting for Vector class in FB, but the help page says it should be... I'm using FD, and, they ware the first to support Vector syntax =)
theCodeBot
October 31st, 2008, 08:04 PM
Vector is a core class, so, you don't need to import it...
SDK 4 should be available for Linux... but you don't really need the whole SDK to compile FP10 content. What you need is a new playerglobal.swc and to set the compiler to -target-player=10.0.0. There're few more changes in the build file, like adding new intrinsic classes and new locale library.
And... to be honest I don't know if there actually is code hinting for Vector class in FB, but the help page says it should be... I'm using FD, and, they ware the first to support Vector syntax =)
Flex for Linux is actually just the mxmlc and a plug-in for eclipse. Installing was as easy as downloading the SDK and running the installer to unzip it to the right eclipse folders :)
So I just DL the FP10 Debugger, modify playerglobal.swc and update compiler directives? Sounds easy to me!
*Backs up everything and gets ready to try it*
Wait... so what other than a new Vector class is in store if I DL the update?
wvxvw
October 31st, 2008, 08:19 PM
__AS3__.vec:Vector
__AS3__.vec:Vector$double
__AS3__.vec:Vector$int
__AS3__.vec:Vector$object
__AS3__.vec:Vector$uint
adobe.utils:MMEndCommand
flash.desktop:ClipboardFormats
flash.desktop:ClipboardTransferMode
flash.display:GraphicsBitmapFill
flash.display:GraphicsEndFill
flash.display:GraphicsGradientFill
flash.display:GraphicsPath
flash.display:GraphicsPathCommand
flash.display:GraphicsPathWinding
flash.display:GraphicsShaderFill
flash.display:GraphicsSolidFill
flash.display:GraphicsStroke
flash.display:GraphicsTrianglePath
flash.display:IGraphicsData
flash.display:IGraphicsFill
flash.display:IGraphicsPath
flash.display:IGraphicsStroke
flash.display:ShaderData
flash.display:ShaderInput
flash.display:ShaderJob
flash.display:ShaderParameter
flash.display:ShaderParameterType
flash.display:ShaderPrecision
flash.display:TriangleCulling
flash.events:SamplesCallbackEvent
flash.events:ShaderEvent
flash.filters:ShaderFilter
flash.geom:Matrix3D
flash.geom:Orientation3D
flash.geom:PerspectiveProjection
flash.geom:Utils3D
flash.geom:Vector3D
flash.media:SoundCodec
flash.net:NetStreamInfo
flash.net:NetStreamPlayOptions
flash.net:NetStreamPlayTransitions
flash.system:JPEGLoaderContext
flash.text.engine:BreakOpportunity
flash.text.engine:ContentElement
flash.text.engine:DigitCase
flash.text.engine:DigitWidth
flash.text.engine:EastAsianJustifier
flash.text.engine:ElementFormat
flash.text.engine:FontDescription
flash.text.engine:FontLookup
flash.text.engine:FontMetrics
flash.text.engine:FontPosture
flash.text.engine:FontWeight
flash.text.engine:GlyphRotation
flash.text.engine:GraphicElement
flash.text.engine:GroupElement
flash.text.engine:JustificationStyle
flash.text.engine:Kerning
flash.text.engine:LigatureLevel
flash.text.engine:LineJustification
flash.text.engine:SpaceJustifier
flash.text.engine:TabAlignment
flash.text.engine:TabStop
flash.text.engine:TextBaseline
flash.text.engine:TextBlock
flash.text.engine:TextElement
flash.text.engine:TextJustifier
flash.text.engine:TextLineCreationResult
flash.text.engine:TextLineMirrorRegion
flash.text.engine:TextLineValidity
flash.text.engine:TextRotation
flash.text.engine:TypographicCase
flash.ui:ContextMenuClipboardItems
flash.ui:MouseCursor
Not sure if this list reflects the last name changes, but should be close...
Ah, and there're new props of DO, like "z" or "rotationZ".
theCodeBot
October 31st, 2008, 08:42 PM
MouseCursor and the 3d utils interest me.
Could you please point me to the exact steps I need? Update compiler directives, do what to playerglobal.swc, and then just install FP10 debugger right?
I'm bringing this so far off topic :P
I haven't touched the new Vector class, if I had I'd post some wise comment about a solution, then someone else would come along and immediately optimize my code and make a mockery of me :)
wvxvw
October 31st, 2008, 09:05 PM
http://opensource.adobe.com/wiki/display/flexsdk/Targeting+Flash+Player+10+Beta
here it explains how to configure FB to compile for FP10.
But what I've been doing and it worked so far: downloaded the SDK4, extracted it to some folder, say C:\Flex_4_SDK. Then written this BAT file:
set sdk=C:\Flex_4_SDK\bin\mxmlc.exe
set buildfile=config.xml
set outputfile=D:\projectsFP10\bin\testFP10.swf
set exec=%sdk% -load-config+=%buildfile% -debug=true -incremental=true -benchmark=false -output=%outputfile%
call %exec%
pause
to compile a project from this kind of build file (config.xml in the same folder where the BAT file is):
<?xml version="1.0" encoding="utf-8"?>
<flex-config>
<compiler>
<source-path append="true">
<path-element>d:\projectsFP10\src</path-element>
<path-element>C:\Program Files\FlashDevelop\Library\AS3\classes</path-element>
</source-path>
</compiler>
<file-specs>
<path-element>d:\projectsFP10\src\Main.mxml</path-element>
</file-specs>
<default-background-color>#FFFFFF</default-background-color>
<default-frame-rate>30</default-frame-rate>
<default-size>
<width>200</width>
<height>200</height>
</default-size>
</flex-config> because all other settings related to the compiler version and new classes are already made to this flex-config file
C:\Flex_4_SDK\frameworks\flex-config.xml
(this particular example will compile d:\projectsFP10\src\Main.mxml as the document class of the D:\projectsFP10\bin\testFP10.swf.
I believe that there will be not much difference on Linux, except for backslashes and such.
What I haven't managed is to redirect output to the FD console (and I don't really know how to redirect it to the Eclipse console), so, I use it with Flash Tracer plugin in FF (it reads trace messages from the log file created by the player), but maybe there's a better way to do it, just haven't investigated it enough...
* you don't need this line:
<path-element>C:\Program Files\FlashDevelop\Library\AS3\classes</path-element>
It's the FD tracing utility, but, as I say, I haven't managed to stick it to the player =)
theCodeBot
October 31st, 2008, 09:29 PM
All my trace operations go to the eclipse console. I just installed FP9 debugger when I installed the Flex plugin for eclipse and voila, traces to the console panel right next to where I code the files and hit F11 to debug (So used to ctrl-enter though...)
I don't need to use the bat file (which is easier in a linux shell to code, by the way), since F11 in Eclipse runs the compiler with the set directives that I specify in my preferences :) Config.xml is auto-generated for me and I can modify it.
All I have to do if this is as you say is install the SDK4 to a directory I already have and update my preferences. I love Linux :D
YAOMK
December 19th, 2008, 05:46 PM
I know this thread is somewhat old. But adding support for gumbo in Flex Builder is as easy as these steps:
1- Download the sdk from http://opensource.adobe.com/wiki/display/flexsdk/Download+Flex+4 and unzip to where Flex pluging directories (under vista C:\Program Files\Adobe\Flex Builder 3 Plug-in\sdks)
2- Open Flex: Window > Preferences > Flex > Install Flex SDKs > Add (navigate to directory containing sdk).
3- Open your project and select: Project > Properties > Flex Compiler > Use specific SDK (select 4.0)
4- Use Flash Player > 10.0.0
5- Set <application xmlns="http://ns.adobe.com/air/application/1.0"> to 1.5
This sdk supports code hinting of vectors to an extent, it does import the vector's package, but it does not hint to the <> tags or its construstor parameters (new Vector.<int>(size).
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.