Search Results

Search found 10 results on 1 pages for 'toub'.

Page 1/1 | 1 

  • actionscript flex, how to send browser width to the swf itself

    - by touB
    I'm working with flex, but actionscript ideas are just as good. The flex <s:Application> tag has height="100%" width="100%" so the swf fits the browser as the browser gets resized. My problem is that I have a <s:Label> that I need to position based on the real/current size of the browser. <s:Application height="100%" width="100%"> ..... <s:Label text="hello" x="?" y=">" /> </s:Application> I heard it's possible to use Application.application.width; but I get a compile error, that it doesn't know what that is. Any ideas how to do this. I'm trying to get the current size of the swf in the browser, as the browser resizes.

    Read the article

  • does actionscript addChild require a display object first

    - by touB
    I'm trying to move away from mxml to actionsctipt. I have a <s:Rect> that I've created and set its properties, but having trouble adding it. var aRect:Rect = new Rect(); //set properties like aRect.x, aRect.y, aRect.width, aRect.height //tried adding it various ways addChild(aRect); Application.addChild(aRect); Application.application.addChild(aRect); stage.addChild(aRect); But I keep getting the error 1067: Implicit coercion of a value of type spark.primitives:Rect to an unrelated type flash.display:DisplayObject Originally in the mxml, it was right inside <s:Application> not nested inside anything <s:Application> <s:Rect id="aRect" x="10" y="10" width="15%" height="15%"> //then fill code here, removed for readability </s:Rect> </s:Application> What's the deal, I thought actionscript would be nicer than mxml.

    Read the article

  • Flex, can't custom style the tooltip

    - by touB
    I'm having trouble changing the font size of my TextInput tooltip. The text input looks like this: <s:TextInput id="first" toolTip="Hello"/> then I create a style like this: <fx:Style> @namespace s "library://ns.adobe.com/flex/spark"; @namespace mx "library://ns.adobe.com/flex/halo"; mx|ToolTip { fontSize: 24; } </fx:Style> but absolutely nothing happens. Any idea what I may be doing wrong?

    Read the article

  • Converting mxml Rect & SolidColor to actionscript

    - by touB
    I'm trying to learn how to use actionscript over mxml for flexibility. I have this simple block of mxml that I'm trying to convert to actionscript, but I'm stuck half way though <s:Rect id="theRect" x="0" y="50" width="15%" height="15%"> <s:fill> <s:SolidColor color="black" alpha="0.9" /> </s:fill> </s:Rect> I can convert the Rect no problem to private var theRect:Rect = new Rect(); theRect.x = 0; theRect.y = 50; theRect.width = "15%"; theRect.height = "15%"; then I'm stuck on the fill. What's the most efficient way to add the SolidColor in as few lines of code as possible.

    Read the article

  • the correct actionscript to find if object already exists

    - by touB
    I have a Rect object that I'd like to create and set its properties only once. After that, I want to just modify its properties since it already exists. This is my general idea if(theRect == undefined){ Alert.show("creating"); var theRect:Rect = new Rect(); //then set properties addElement(theRect); //then add it using addElement because addChild() does not work } else { Alert.show("updating"); //no need to create it since it's already been created //just access and change the properties } I tried several ways and combinations for the if conditional check: if(theRect == undefined){ if(theRect == null){ declaring and not declaring `var theRect:Rect;` before the if check declaring and instantiating to null before the if check `var theRect:Rect = null;` but can't get the desired effect. Everytime this code block runs, and depending on which version I've used, it either gives me a "can't access null object" error or the if statement always evaluates to true and creates a new Rect object and I get the "creating" Alert. What's the right way of creating that Rect but only if doesn't exist?

    Read the article

  • trouble adding a rectange in actionscript

    - by touB
    I have a rectange that I've created and set its individual properties like so var aRect:Rect = new Rect(); aRect.x = 10; aRect.y = 10; aRect.width = "15%"; aRect.height = "15%"; addChild(aRect); I have 2 problems that the compiler seems to be choking on. The first is that the compiler chokes on 15% and "15%", with or without the quotes, neither works. The second is that adding the rectangle doesn't work. I tried all the following, but nothing works. addChild(aRect); Application.addChild(aRect); Application.application.addChild(aRect); stage.addChild(aRect); What's the deal, I thought actionscript would be nicer than mxml.

    Read the article

  • ConcurrentDictionary<TKey,TValue> used with Lazy<T>

    - by Reed
    In a recent thread on the MSDN forum for the TPL, Stephen Toub suggested mixing ConcurrentDictionary<T,U> with Lazy<T>.  This provides a fantastic model for creating a thread safe dictionary of values where the construction of the value type is expensive.  This is an incredibly useful pattern for many operations, such as value caches. The ConcurrentDictionary<TKey, TValue> class was added in .NET 4, and provides a thread-safe, lock free collection of key value pairs.  While this is a fantastic replacement for Dictionary<TKey, TValue>, it has a potential flaw when used with values where construction of the value class is expensive. The typical way this is used is to call a method such as GetOrAdd to fetch or add a value to the dictionary.  It handles all of the thread safety for you, but as a result, if two threads call this simultaneously, two instances of TValue can easily be constructed. If TValue is very expensive to construct, or worse, has side effects if constructed too often, this is less than desirable.  While you can easily work around this with locking, Stephen Toub provided a very clever alternative – using Lazy<TValue> as the value in the dictionary instead. This looks like the following.  Instead of calling: MyValue value = dictionary.GetOrAdd( key, () => new MyValue(key)); .csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; } We would instead use a ConcurrentDictionary<TKey, Lazy<TValue>>, and write: MyValue value = dictionary.GetOrAdd( key, () => new Lazy<MyValue>( () => new MyValue(key))) .Value; This simple change dramatically changes how the operation works.  Now, if two threads call this simultaneously, instead of constructing two MyValue instances, we construct two Lazy<MyValue> instances. However, the Lazy<T> class is very cheap to construct.  Unlike “MyValue”, we can safely afford to construct this twice and “throw away” one of the instances. We then call Lazy<T>.Value at the end to fetch our “MyValue” instance.  At this point, GetOrAdd will always return the same instance of Lazy<MyValue>.  Since Lazy<T> doesn’t construct the MyValue instance until requested, the actual MyClass instance returned is only constructed once.

    Read the article

  • PPL and TPL sessions on channel9

    - by Daniel Moth
    Back in June there was an internal conference in Redmond ("Engineering Forum") aimed at Microsoft engineers, and delivered by Microsoft engineers. I was asked to put together a track on Multi-Core development, so I picked 6 parallelism experts and we created 6 awesome sessions (we won the top spot in the Top 10 :-)). Two of the speakers kept the content fairly external-friendly, so we received permission to publish their recordings publicly. Enjoy (best to download the High Quality WMV): Don McCrady - Parallelism in C++ Using the Concurrency Runtime Stephen Toub - Implementing Parallel Patterns using .NET 4 To get notified on future videos on parallelism (or to browse the archive) stay tuned on this channel9 parallel computing feed. Comments about this post welcome at the original blog.

    Read the article

  • DDD East Anglia, 29th June 2013 - Async Patterns presentation and source code

    - by Liam Westley
    Originally posted on: http://geekswithblogs.net/twickers/archive/2013/07/01/ddd-east-anglia-29th-june-2013---async-patterns-presentation.aspxMany thanks to the team in Cambridge for an awesome first conference DDD East Anglia.  I definitely appreciate how each of the different areas have their own distinctive atmosphere and feel.  Thanks to some great sponsors we enjoyed a great venue and some excellent nibbles. For those who attended my Async my source code and presentation are available on GitHub, https://github.com/westleyl/DDDEastAnglia2013-Async.git If you are new to Git then the easiest client to install is GitHub for Windows, a graphical UI for accessing GitHub. Personally, I also have Git Extensions and Tortoise Git installed. Tortoise Git is the file explorer add-in that works in a familiar manner to TortoiseSVN. As I mentioned during the presentation I have not included the sample data, the music files, in the source code placed on GitHub but I have included instructions on how to download them from http://silents.bandcamp.comand place them in the correct folders. Also, Windows Media Player, by default, does not play Ogg Vorbis and Flac music files, however you can download the codec installer for these, for free, from http://xiph.org/dshow. I have included the .Net 4.0 version of the source code that uses the Microsoft.Bcl.Async NuGet package - once you have got the project from GitHub you will need to install this NuGet package for the code to compile. Load Project into Visual Studio 2012 Access the NuGet package manager (Tools -> Library Package Manager -> Manage NuGet Packages For Solution) Highlight Online and then Search Online for microsoft.bcl.async Click on Install button Resources : You can download the Task-based Asynchronous Pattern white paper by Stephen Toub, which was the inspiration for this presentation from here - http://www.microsoft.com/en-us/download/details.aspx?id=19957 Presentation : If you just want the presentation and don’t want to bother with a GitHub login you can download the PowerPoint presentation from here.

    Read the article

  • asynchrony is viral

    - by Daniel Moth
    It is becoming hard to write code today without introducing some form of asynchrony and, if you are using .NET (e.g. for Windows Phone 8 or Windows Store apps), that means sooner or later you have to await something and mark your method as async. My most recent examples included introducing speech recognition in my Translator By Moth phone app where I had to await mySpeechRecognizerUI.RecognizeWithUIAsync() and when moving that code base to a Windows Store project just to show a MessageBox I had to await myMessageDialog.ShowAsync(). Any time you need to invoke an asynchronous method in your code, you have a choice to make: kick off the operation but don’t wait for it to complete (otherwise known as fire-and-forget), synchronously wait for it to complete (which will entail blocking, which can be bad, especially on a UI thread), or asynchronously wait for it to complete before continuing on with the rest of the method’s work. In most cases, you want the latter, and the await keyword makes that trivial to implement.  When you use the magical await keyword in front of an API call, then you typically have to make additional changes to your code: This await usage is within a method of course, and now you have to annotate that method with async. Furthermore, you have to change the return type of the method you just annotated so it returns a Task (if it previously returned void), or Task<myOldReturnType> (if it previously returned myOldReturnType). Note that if it returns void, in some cases you could cheat and stop there. Furthermore, any method that called this method you just annotated with async will now also be invoking an asynchronous operation, so you have to make that change in the body of the caller method to introduce the await keyword before the call to the method. …you guessed it, you now have to change this caller method to be annotated with async and have its return types tweaked... …and it goes on virally… At some point you reach the root of your user code, e.g. a GUI event handler, and whoever calls that void method can already deal with the fact that you marked it as async and the viral introduction of the keywords stops there… This is all wonderful progress and a very powerful mechanism, and I just wish someone had written a refactoring tool to take care of this… anyone? I mentioned earlier that you have a choice when invoking an asynchronous operation. If the first time you encounter this you wish to localize the impact of all these changes and essentially try to turn the asynchronous behavior into synchronous by blocking - don't! For reasons why you don't want to do that, read Toub's excellent blog post (and check out the rest of his blog with gems on async programming starting with the Async FAQ). Just embrace the pattern knowing that when you use one instance of an await, you'll propagate the change all the way to the root user code method, e.g. typically an event handler. Related aside: I just finished re-writing my MessageBox wrapper class for Phone projects, including making it work in Windows Store projects, and it does expect you to use it with an await :-). I'll share that in an upcoming post for those of you that have the same need… Comments about this post by Daniel Moth welcome at the original blog.

    Read the article

1