Hi,
I’ve been working with ActionScript for the first time and created a really simple class with a couple of getters and setters and wanted to instantiate the class and use a few setters.
So the original class was:
package MyPackage
{
import mx.core.UIComponent;
public class AClass extends UIComponent
{
public function AClass()
{
super();
}
public function get AValue():Number
{
return _aValue;
}
public function set AValue(_newAValue:Number):void
{
_aValue = _newAValue;
}
private var _aValue:Number;
}
}
That looks fine right?
So in my class I call
import MyPackage.AClass at the top of the file.
Next in another class I called
var myClass:AClass = new AClass();
myClass.AValue(20.0);
I figured that this looked fine, you want to call the function AValue with the value 20.0 passed in. However I was getting the cryptic error:
1195: Attempted access of inaccessible method AValue through a reference with static type MyPackage:AClass
Took me a while to figure this one out I thought I had defined the functions incorrectly or wasn’t importing the class right. However the solution is a simple one. When you use get and set you are essentially saying that you can use the assignment operator but for some weird reason you can’t call the functions directly.
So the solution was to do:
var myClass:AClass = new AClass();
myClass.AValue = 20.0;
Use the assignment operator instead of calling the set function directly.
admin Flex
Hi again,
Yesterday I had some fun trying to use Flex to call an upload.cfm page but as the CF page was behind a secured system(i.e. need to be logged in to call a page) the system was looking for the Flex app to login again. I only found this out by running Charles Web Debugging app which showed the request and response http data. I saw that response was source for a login page, strangely though the flex app told me the upload was called successfully and the file was uploaded successfully.
Also looking at the HTTP data I saw that the jsessionid wasn’t being passed in alongside the Flex request so I needed to pass the session variable into the Flex app from ColdFusion. The CF was determining that the session was over so it was looking for a login. After looking around a bit I saw that it wasn’t possible to just get the Session variable from the swf directly you have to request it from ColdFusion as it is stored server side(I think).
So I made a function in a CFC to get the session variable:
[code lang="xml"]
[/code]
I call this from the Flex app using a Flex WebService and then when I’m doing a URL request I pass the jsessionid alongside the request like so:
[code lang="actionscript"]
var uploadDestination:String = myModel.CFLocation + model.AssetModel.getInstance().UPLOAD_CFM_NAME + ';jsessionid=' + myModel.sessionID;
[/code]
The session id is stored alongside the model as a variable. This essentially calls ‘upload.cfm;jsessionid=xyz’
This fixed my problem and the app works fine now.
edlong Archive Post, ColdFusion, Flex
Yesterday I was working with Flex again and made a drag and drop application that contained a tile list of images that can be dragged into a text-area which then becomes populated with the url of the image. The problem I was having was that when I dragged in a TileList in Flex off the TileList the scroller went crazy and flew either up or down depending on which way I was dragging the image. The solution I found to this problem was to disable the TileList whenever I clicked on the image. It was actually very very simple, after asking Mark of course.
I had a variable in my Cairngorm model called dragging which is true if we’re dragging an image and false if not. I just bound this dragging boolean to the enabled attribute of the TileList. So it became:
[code lang="xml"]
[/code]
This fixed the TileList going crazy whenever dragging and scrolling up or down really fast as the TileList just disabled itself(greyed out the scroller bar on the right) whenever a dragging operation is performed.
I was also getting a nasty looking cursor when dragging across the tilelist, it had a red circle with a white X within it. I didn’t want that so I just overwrote the default CSS style
[code lang="actionscript"]
DragManager
{ rejectCursor: Embed(source="assets/copyCursor.png");
}
[/code]
I included the main style within the Application
[code lang="xml"]
[/code]
I was playing around with Voxy today, its an open source VoiceXML plugin for Asterisk. Problem with it is that it doesn’t include ANY TTS or audio playback so if you have a VoiceXML document it will go off and parse it fine but do nothing with it! So its pretty useless as it stands as to alter it you have to go and mess around with the C source and recompile which isn’t too appealing. The mayhem of VoiceXML and Asterisk goes on. Will try VXIAsterisk again tomorrow(don’t have much hope though given their pathetic record in the past every time I’ve tried to compile/install it for use alongside Asterisk)
edlong Archive Post, Flex