[flexcoders] Re: FileStream.truncate() doesnt work after calling FileStream.readUTFBytes()
Anyone got any ideas? The only thing I can think of currently is opening the file for read, then closing the file, then re-opening for write. It's horrible and hacky, but right now I'm out of suggestions. Mark --- In flexcoders@yahoogroups.com, skuteboarding m...@... wrote: Hi, I'm trying to read an xml file into memory, add a node, then write over the original file. The following code works just fine (it clears the file, then writes the new bytes over the top): var stream:FileStream = new FileStream(); stream.open(file, FileMode.UPDATE); stream.position = 0; stream.truncate(); stream.writeUTFBytes(?xml version=\1.0\ encoding=\UTF-8\?); stream.writeUTFBytes(File.lineEnding); stream.writeUTFBytes(xml.toXMLString()); stream.close(); However, if I attempt to perform a read after the file has opened, the position / truncate calls don't work: var stream:FileStream = new FileStream(); stream.open(file, FileMode.UPDATE); var xml:XML = XML(stream.readUTFBytes(stream.bytesAvailable)); // Modify xml here stream.position = 0; stream.truncate(); stream.writeUTFBytes(?xml version=\1.0\ encoding=\UTF-8\?); stream.writeUTFBytes(File.lineEnding); stream.writeUTFBytes(xml.toXMLString()); stream.close(); Does anyone have any ideas why this doesn't work? If you examine the stream, in the first code, after the call to truncate(), the bytesAvailable property will read 0. But in the second code, the bytesAvailable won't change (it will show the current file size). Any ideas? Mark
[flexcoders] FileStream.truncate() doesnt work after calling FileStream.readUTFBytes()
Hi, I'm trying to read an xml file into memory, add a node, then write over the original file. The following code works just fine (it clears the file, then writes the new bytes over the top): var stream:FileStream = new FileStream(); stream.open(file, FileMode.UPDATE); stream.position = 0; stream.truncate(); stream.writeUTFBytes(?xml version=\1.0\ encoding=\UTF-8\?); stream.writeUTFBytes(File.lineEnding); stream.writeUTFBytes(xml.toXMLString()); stream.close(); However, if I attempt to perform a read after the file has opened, the position / truncate calls don't work: var stream:FileStream = new FileStream(); stream.open(file, FileMode.UPDATE); var xml:XML = XML(stream.readUTFBytes(stream.bytesAvailable)); // Modify xml here stream.position = 0; stream.truncate(); stream.writeUTFBytes(?xml version=\1.0\ encoding=\UTF-8\?); stream.writeUTFBytes(File.lineEnding); stream.writeUTFBytes(xml.toXMLString()); stream.close(); Does anyone have any ideas why this doesn't work? If you examine the stream, in the first code, after the call to truncate(), the bytesAvailable property will read 0. But in the second code, the bytesAvailable won't change (it will show the current file size). Any ideas? Mark
[flexcoders] FileStream.truncate() doesnt work after calling FileStream.readUTFBytes()
Hi, I'm trying to read an xml file into memory, add a node, then write over the original file. The following code works just fine (it clears the file, then writes the new bytes over the top): var stream:FileStream = new FileStream(); stream.open(file, FileMode.UPDATE); stream.position = 0; stream.truncate(); stream.writeUTFBytes(?xml version=\1.0\ encoding=\UTF-8\?); stream.writeUTFBytes(File.lineEnding); stream.writeUTFBytes(xml.toXMLString()); stream.close(); However, if I attempt to perform a read after the file has opened, the position / truncate calls don't work: var stream:FileStream = new FileStream(); stream.open(file, FileMode.UPDATE); var xml:XML = XML(stream.readUTFBytes(stream.bytesAvailable)); // Modify xml here stream.position = 0; stream.truncate(); stream.writeUTFBytes(?xml version=\1.0\ encoding=\UTF-8\?); stream.writeUTFBytes(File.lineEnding); stream.writeUTFBytes(xml.toXMLString()); stream.close(); Does anyone have any ideas why this doesn't work? If you examine the stream, in the first code, after the call to truncate(), the bytesAvailable property will read 0. But in the second code, the bytesAvailable won't change (it will show the current file size). Any ideas? Mark
[flexcoders] Re: How to create your own IFlexModuleFactory?
Yes, I think IFlexModuleFactory possibly isn't what I'm after. I was basically looking for ways to initialise custom modules (plugins) in a correct order with specific values. I've since abandoned that idea and had my main plugin object initialised in the constructor of each module. Thanks, --- In flexcoders@yahoogroups.com, Alex Harui aha...@... wrote: Check out Module.as. There should be [Frame] metadata that specifies the class that implements IFlexModuleFactory that will be used as the root of the module SWF. AFAIK, nobody has ever gone down this road before. There's a 90% chance that there's some other way to do what you want without going down this road. Describe your goals with a bit more detail and we'll see if there's some easier way. Alex Harui Flex SDK Developer Adobe Systems Inc.http://www.adobe.com/ Blog: http://blogs.adobe.com/aharui From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On Behalf Of skuteboarding Sent: Saturday, April 04, 2009 12:45 AM To: flexcoders@yahoogroups.com Subject: [flexcoders] How to create your own IFlexModuleFactory? Hi,I'm interested in implementing the IFlexModuleFactory interface in my modules - mainly so I can manually control the creation of my objects. What do I need to implement this in my module?
[flexcoders] How to create your own IFlexModuleFactory?
Hi,I'm interested in implementing the IFlexModuleFactory interface in my modules - mainly so I can manually control the creation of my objects. What do I need to implement this in my module?
[flexcoders] Re: Why does percentWidth / percentHeight not work with popups?
Thanks Alex --- In flexcoders@yahoogroups.com, Alex Harui aha...@... wrote: Basically yes. Parents size their children in Flex and popups don't have a parent. (actually they do because they are parented by SystemManager, but SystemManager doesn't layout its children. Alex Harui Flex SDK Developer Adobe Systems Inc.http://www.adobe.com/ Blog: http://blogs.adobe.com/aharui
[flexcoders] Re: Why does percentWidth / percentHeight not work with popups?
Hi Tracy, I originally tried that, but if you are using a transition (say, to resize over 500ms) it breaks the transition (it just instantly resizes). Mark --- In flexcoders@yahoogroups.com, Tracy Spratt tspr...@... wrote: Suppose on resize you call PopUpmanager.centerPopUp()/ Tracy Spratt, Lariat Services, development services available _ From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On Behalf Of skuteboarding Sent: Thursday, April 02, 2009 5:36 PM To: flexcoders@yahoogroups.com Subject: [flexcoders] Why does percentWidth / percentHeight not work with popups? I'm trying to create a popup at 100% of the width / height of the application. But it just ignores these values. I've had to work around the problem by doing: BindingUtils.bindProperty(popup, width, this, width); BindingUtils.bindProperty(popup, height, this, height); (Where 'this' is the application). The reason I'm trying to do this is I've got a popup that I want centred in the view, but it has different states which change the size of the popup. Mark
[flexcoders] Why does percentWidth / percentHeight not work with popups?
I'm trying to create a popup at 100% of the width / height of the application. But it just ignores these values. I've had to work around the problem by doing: BindingUtils.bindProperty(popup, width, this, width); BindingUtils.bindProperty(popup, height, this, height); (Where 'this' is the application). The reason I'm trying to do this is I've got a popup that I want centred in the view, but it has different states which change the size of the popup. Mark
[flexcoders] Why does percentWidth / percentHeight not work with popups?
I'm trying to create a popup at 100% of the width / height of the application. But it just ignores these values. I've had to work around the problem by doing: BindingUtils.bindProperty(popup, width, this, width); BindingUtils.bindProperty(popup, height, this, height); (Where 'this' is the application). The reason I'm trying to do this is I've got a popup that I want centred in the view, but it has different states which change the size of the popup. Mark
[flexcoders] Why does percentWidth / percentHeight not work with popups?
I'm trying to create a popup at 100% of the width / height of the application. But it just ignores these values. I've had to work around the problem by doing: BindingUtils.bindProperty(popup, width, this, width); BindingUtils.bindProperty(popup, height, this, height); (Where 'this' is the application). The reason I'm trying to do this is I've got a popup that I want centred in the view, but it has different states which change the size of the popup. Mark
[flexcoders] Loading modules from within AIR
Hi, I'm currently converting a Flex app to AIR and I've hit a stumbling block right at the start. When I try to load a module from disk I get the following error: SWF is not a loadable module Which after reading a couple of links I discover is a security message (normally in Flex it means you're trying to load something on a different server). In AIR how do I load a module from disk? A code example would be great. This is what I'm using currently: m_moduleInfo = ModuleManager.getModule(url); Where url is a File.url property.
[flexcoders] Re: Loading modules from within AIR
Hi, I thought they could be in subdirectories as well? They were in a plugins subdirectory. I've just moved them into the same folder as the app and it still doesn't work. I missed a line of code from original post: m_moduleInfo = ModuleManager.getModule(url); m_moduleInfo.load(ApplicationDomain.currentDomain); --- In flexcoders@yahoogroups.com, Alex Harui aha...@... wrote: Module must be in same dir as main SWF Alex Harui Flex SDK Developer Adobe Systems Inc.http://www.adobe.com/ Blog: http://blogs.adobe.com/aharui From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On Behalf Of skuteboarding Sent: Thursday, February 19, 2009 12:47 PM To: flexcoders@yahoogroups.com Subject: [flexcoders] Loading modules from within AIR Hi, I'm currently converting a Flex app to AIR and I've hit a stumbling block right at the start. When I try to load a module from disk I get the following error: SWF is not a loadable module Which after reading a couple of links I discover is a security message (normally in Flex it means you're trying to load something on a different server). In AIR how do I load a module from disk? A code example would be great. This is what I'm using currently: m_moduleInfo = ModuleManager.getModule(url); Where url is a File.url property.
[flexcoders] Re: Loading modules from within AIR
Hi, I've managed to find the problem. I was using the File.url and the File.nativePath properties to try to load module. If you change it to using just a relative path, i.e. plugins\\myplugin.swf it works just fine. Looks like it doesn't like paths like C:\... and file:///C:/... Cheers, Mark --- In flexcoders@yahoogroups.com, Alex Harui aha...@... wrote: Module must be in same dir as main SWF Alex Harui Flex SDK Developer Adobe Systems Inc.http://www.adobe.com/ Blog: http://blogs.adobe.com/aharui From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On Behalf Of skuteboarding Sent: Thursday, February 19, 2009 12:47 PM To: flexcoders@yahoogroups.com Subject: [flexcoders] Loading modules from within AIR Hi, I'm currently converting a Flex app to AIR and I've hit a stumbling block right at the start. When I try to load a module from disk I get the following error: SWF is not a loadable module Which after reading a couple of links I discover is a security message (normally in Flex it means you're trying to load something on a different server). In AIR how do I load a module from disk? A code example would be great. This is what I'm using currently: m_moduleInfo = ModuleManager.getModule(url); Where url is a File.url property.
[flexcoders] Re: Can't use ImageSnapshot.captureBitmapData with a rotation matrix
Hi, thanks for the response, but that didn't work. I managed to get a solution via here: http://stackoverflow.com/questions/526119/cant-use-imagesnapshot-capturebitmapdata-with-a-rotation-matrix --- In flexcoders@yahoogroups.com, Amy amyblankens...@... wrote: Try just setting the blendMode on the textArea to layer, and see if that will let you rotate it without embedding. I found that ImageSnapshot sometimes didn't work with fonts that were not embedded. HTH; Amy
[flexcoders] Can't use ImageSnapshot.captureBitmapData with a rotation matrix
Hi, does anyone have an example of using the ImageSnapshot.captureBitmapData function with a rotation matrix? This is the code I'm using: var matrix:Matrix = new Matrix(); matrix.rotate(degreesToRadians(90)); var bitmapData:BitmapData = ImageSnapshot.captureBitmapData(textInput, matrix); But unfortunately this throws an error on the following line in ImageSnapshot.as: data = new BitmapData(scaledWidth, scaledHeight, true, 0x); // -- THROWS ERROR HERE AS scaledWidth / scaledHeight are extremely small numbers (-1-e16 etc) data.draw(source, matrix, colorTransform, blendMode, clipRect, smoothing); } finally { if (source is IUIComponent) finishPrintObject(IUIComponent(source), normalState); // -- ERROR THROWN HERE, BUT CAUSE OF ERROR IS ABOVE } What I'm trying to achieve is a rotated bitmap of a text input control (I'm trying to avoid embedding a font in the application). This code works just fine when I don't rotate the bitmap, but the minute I rotate it, it breaks. Any help much appreciated. Mark
[flexcoders] Re: Can an embedded image in a module be used by the main application?
I used style.getStyle(icon) to look at the object, and it was just the string representation from the stylesheet (@Embed(...)). Obviously when the button style was set with this value from the module, it's not going to find the image. I've ditched the idea of using a stylesheet file and have defined all the styles manually in actionscript. That way it works when embedding images. Thanks, Mark --- In flexcoders@yahoogroups.com, Alex Harui [EMAIL PROTECTED] wrote: It might just be that the module doesn't get loaded until after the button sets up its styles. I don't know if it will pick up the fact that the styles showed up later. From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of skuteboarding Sent: Sunday, November 23, 2008 6:07 AM To: flexcoders@yahoogroups.com Subject: [flexcoders] Can an embedded image in a module be used by the main application? I'm trying to load an image from a stylesheet in a module, then use that style declaration in the main application. It doesn't seem to work, but wondered if there is something special I need to do to get it to work? I have the following in my stylesheet in my module: .sun { icon: @Embed(source='../assets/Background/Sun.png'); } Then in my module I have a function like: public function getSunStyle():CSSStyleDeclaration { return StyleManager.getStyleDeclaration(.sun); } I've checked the return value here and it does exist (I've also checked it with simple things like background colours etc). Now, in my main application, I take that return value and do this: var sun:CSSStyleDeclaration = module.getSunStyle; if (gui.controlPanelBackgroundStyle != null) { StyleManager.setStyleDeclaration(.sun, sun, true); } And I have a button (in the main app) defined as: mx:Button x=10 y=10 label=Button styleName=.sun/ Is it possible to achieve what I'm trying to do?
[flexcoders] Can you embed a stylesheet in an actionscript project or actionscript module?
Hi, I've got a module which is written mainly in actionscript. The module can contain some css style declarations for changing the appearance of the main app. My question is, can I embed a stylesheet within the module using actionscript, similar to the following mxml code: mx:Style source=..\stylesheets\default.css/ I can get the style declarations out at runtime easily, if I use the mxml tag, but I don't want to rely on mxml in my module. Is there any way to achieve this in pure actionscript? Thanks, Mark Ingram
[flexcoders] Can an embedded image in a module be used by the main application?
I'm trying to load an image from a stylesheet in a module, then use that style declaration in the main application. It doesn't seem to work, but wondered if there is something special I need to do to get it to work? I have the following in my stylesheet in my module: .sun { icon: @Embed(source='../assets/Background/Sun.png'); } Then in my module I have a function like: public function getSunStyle():CSSStyleDeclaration { return StyleManager.getStyleDeclaration(.sun); } I've checked the return value here and it does exist (I've also checked it with simple things like background colours etc). Now, in my main application, I take that return value and do this: var sun:CSSStyleDeclaration = module.getSunStyle; if (gui.controlPanelBackgroundStyle != null) { StyleManager.setStyleDeclaration(.sun, sun, true); } And I have a button (in the main app) defined as: mx:Button x=10 y=10 label=Button styleName=.sun/ Is it possible to achieve what I'm trying to do?
[flexcoders] Re: Modules don't display radio buttons/ check box etc unless referenced in main app
~Sorry if this is a re-post, the earlier post didn't seem to appear~ Hi, thanks for the responses. I've tried loading the module with the following line: moduleInfo.load(ApplicationDomain.currentDomain, SecurityDomain.currentDomain); However, it still doesn't fix the issue (check box / radio button still appear as a regular button). What else do I need to do? Mark --- In flexcoders@yahoogroups.com, Alex Harui [EMAIL PROTECTED] wrote: See modules presentation on my blog and shared code modules examples From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Maciek Sakrejda Sent: Wednesday, November 12, 2008 4:00 PM To: flexcoders@yahoogroups.com Subject: Re: [flexcoders] Modules don't display radio buttons/ check box etc unless referenced in main app Excerpt from the Adobe docs follows, but basically, that's how it works. If you want to avoid CheckBox references in the main app, you can load the modules into the main app's application domain, but make sure you trust the modules if you do that. --- Adobe docs on modules: By default, a module is loaded into a child domain of the current application domain. You can specify a different application domain by using the applicationDomain property of the ModuleLoader class. Because a module is loaded into a child domain, it owns class definitions that are not in the main application's domain. For example, the first module to load the PopUpManager class becomes the owner of the PopUpManager class for the entire application because it registers the manager with the SingletonManager. If another module later tries to use the PopUpManager, Adobe ® Flash® Player throws an exception. The solution is to ensure that managers such as PopUpManager and DragManager and any other shared services are defined by the main application (or loaded late into the shell's application domain). When you promote one of those classes to the shell, the class can then be used by all modules. Typically, this is done by adding the following to a script block: import mx.managers.PopUpManager; import mx.managers.DragManager; private var popUpManager:PopUpManager; private var dragManager:DragManager; This technique also applies to components. The module that first uses the component owns that component's class definition in its domain. As a result, if another module tries to use a component that has already been used by another module, its definition will not match the existing definition. To avoid a mismatch of component definitions, create an instance of the component in the main application. The result is that the definition of the component is owned by the main application and can be used by modules in any child domain. -Original Message- From: skuteboarding [EMAIL PROTECTED]mailto:mingram%40softease.com Reply-To: flexcoders@yahoogroups.commailto:flexcoders%40yahoogroups.com To: flexcoders@yahoogroups.commailto:flexcoders%40yahoogroups.com Subject: [flexcoders] Modules don't display radio buttons/ check box etc unless referenced in main app Date: Wed, 12 Nov 2008 22:30:45 - Hi, I've got a problem using modules and user interface components. I have a module with a canvas on it and some buttons / radio buttons / check boxes. In the main app I download the module, then add the canvas to a container. The buttons don't show properly (they all look like regular buttons, but act like a radio button / check box). The only way to fix it is to add a radio button / check box to the main app. Adding the reference to a button in the main app makes it work from the module. I hope this makes sense. Does anyone know how to make radio buttons / check boxes work without having to add a radio button / check box somewhere in the main app?
[flexcoders] Re: Modules don't display radio buttons/ check box etc unless referenced in main app
NB: I also tried it without the security domain parameter and it didn't work then either. --- In flexcoders@yahoogroups.com, skuteboarding [EMAIL PROTECTED] wrote: ~Sorry if this is a re-post, the earlier post didn't seem to appear~ Hi, thanks for the responses. I've tried loading the module with the following line: moduleInfo.load(ApplicationDomain.currentDomain, SecurityDomain.currentDomain); However, it still doesn't fix the issue (check box / radio button still appear as a regular button). What else do I need to do? Mark --- In flexcoders@yahoogroups.com, Alex Harui aharui@ wrote: See modules presentation on my blog and shared code modules examples From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Maciek Sakrejda Sent: Wednesday, November 12, 2008 4:00 PM To: flexcoders@yahoogroups.com Subject: Re: [flexcoders] Modules don't display radio buttons/ check box etc unless referenced in main app Excerpt from the Adobe docs follows, but basically, that's how it works. If you want to avoid CheckBox references in the main app, you can load the modules into the main app's application domain, but make sure you trust the modules if you do that. --- Adobe docs on modules: By default, a module is loaded into a child domain of the current application domain. You can specify a different application domain by using the applicationDomain property of the ModuleLoader class. Because a module is loaded into a child domain, it owns class definitions that are not in the main application's domain. For example, the first module to load the PopUpManager class becomes the owner of the PopUpManager class for the entire application because it registers the manager with the SingletonManager. If another module later tries to use the PopUpManager, Adobe ® Flash® Player throws an exception. The solution is to ensure that managers such as PopUpManager and DragManager and any other shared services are defined by the main application (or loaded late into the shell's application domain). When you promote one of those classes to the shell, the class can then be used by all modules. Typically, this is done by adding the following to a script block: import mx.managers.PopUpManager; import mx.managers.DragManager; private var popUpManager:PopUpManager; private var dragManager:DragManager; This technique also applies to components. The module that first uses the component owns that component's class definition in its domain. As a result, if another module tries to use a component that has already been used by another module, its definition will not match the existing definition. To avoid a mismatch of component definitions, create an instance of the component in the main application. The result is that the definition of the component is owned by the main application and can be used by modules in any child domain. -Original Message- From: skuteboarding mingram@mailto:mingram%40softease.com Reply-To: flexcoders@yahoogroups.commailto:flexcoders%40yahoogroups.com To: flexcoders@yahoogroups.commailto:flexcoders%40yahoogroups.com Subject: [flexcoders] Modules don't display radio buttons/ check box etc unless referenced in main app Date: Wed, 12 Nov 2008 22:30:45 - Hi, I've got a problem using modules and user interface components. I have a module with a canvas on it and some buttons / radio buttons / check boxes. In the main app I download the module, then add the canvas to a container. The buttons don't show properly (they all look like regular buttons, but act like a radio button / check box). The only way to fix it is to add a radio button / check box to the main app. Adding the reference to a button in the main app makes it work from the module. I hope this makes sense. Does anyone know how to make radio buttons / check boxes work without having to add a radio button / check box somewhere in the main app?
[flexcoders] Modules don't display radio buttons/ check box etc unless referenced in main app
Hi, I've got a problem using modules and user interface components. I have a module with a canvas on it and some buttons / radio buttons / check boxes. In the main app I download the module, then add the canvas to a container. The buttons don't show properly (they all look like regular buttons, but act like a radio button / check box). The only way to fix it is to add a radio button / check box to the main app. Adding the reference to a button in the main app makes it work from the module. I hope this makes sense. Does anyone know how to make radio buttons / check boxes work without having to add a radio button / check box somewhere in the main app?