Wrox Programmer Forums
|
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Flash (all versions) section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 29th, 2007, 03:08 PM
Registered User
 
Join Date: Aug 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Adobe Flex Variables

I hope I'm in the right section for posting this. I am trying to learn Adobe Flex and I am having trouble with variables. I resorted to using the example Hello World program on Adobe's page and had it working fine. The instant I try to add a variable, I get an error, even if I copy a variable declaration straight from the help file, can someone please help me by showing me how to declare a variable (such as hiWorld = "Hello World") and then display it where it currently has the string "Hello World"?


Code:
<?xml version="1.0" encoding="utf-8"?>

<mx:Application 
    xmlns:mx="http://www.adobe.com/2006/mxml" 
    viewSourceURL="src/HelloWorld/index.html"
    horizontalAlign="center" verticalAlign="middle" 
    width="300" height="160"
>
    <mx:Panel 
        paddingTop="10" paddingBottom="10" paddingLeft="10" paddingRight="10"
        title="My Application"  
    >

        <mx:Label text="Hello World!" fontWeight="bold" fontSize="24"/>
    </mx:Panel>
</mx:Application>
 
Old August 29th, 2007, 03:38 PM
Friend of Wrox
 
Join Date: Jun 2007
Posts: 477
Thanks: 10
Thanked 19 Times in 18 Posts
Default

I'm not familiar with Flex, but have heard it's a little bit friendlier way of interfacing with Flash elements. Is it using Actionscript? In Actionscript 2 & 3 you declare variables in the following form...

var name:String = "Me";
var age:Number = 1;
var isMe:Boolean = true;


-------------------------

Whatever you can do or dream you can, begin it. Boldness has genius, power and magic in it. Begin it now.
-Johann von Goethe

When Two Hearts Race... Both Win.
-Dove Chocolate Wrapper

Chroniclemaster1, Founder of www.EarthChronicle.com
A Growing History of our Planet, by our Planet, for our Planet.
 
Old August 29th, 2007, 03:58 PM
Registered User
 
Join Date: Aug 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yes, I believe it's ActionScript

I've tried the following (among many other things) with no luck.

Code:
<?xml version="1.0" encoding="utf-8"?>

<mx:Application 
    xmlns:mx="http://www.adobe.com/2006/mxml" 
    viewSourceURL="src/HelloWorld/index.html"
    horizontalAlign="center" verticalAlign="middle" 
    width="300" height="160"
>
    <mx:Panel 
        paddingTop="10" paddingBottom="10" paddingLeft="10" paddingRight="10"
        title="My Application"  
    >
var hiWorld:String = "Hello World!";

        <mx:Label text="{hiWorld}" fontWeight="bold" fontSize="24"/>
    </mx:Panel>
</mx:Application>
 
Old August 30th, 2007, 11:48 AM
Friend of Wrox
 
Join Date: Jun 2007
Posts: 477
Thanks: 10
Thanked 19 Times in 18 Posts
Default

:( Lame, then this is probably an interface issue. It does look like you're declaring them properly. The closest thing I can think of is a situation like learning Dreamweaver. Dreamweaver is simply constructing HTML documents for you in a more visually intuitive manner. However, because your problems in Dreamweaver are typically about which button to push or which panel to pull up, an HTML guru is typically not very helpful. This may be something similar, where we won't be much help. I hope there's someone lurking who knows some basic Flex. I don't think this should be hard.

I feel confident saying that your variable declaration looks great. That's not your problem. It does look a little out of place in your XML. I've NO idea how this works in Flex, one of the nasty things about XML languages is that you can customize them any way you want. From my work in HTML, though you can't embed scripting code "naked" like this. In HTML if you wanted to include script you'd need script tags, literally

Code:
<REALLY LONG HTML DOCTYPE>
   .
   .
   .
XML looking stuff
   .
   .
   .
<script>
All the script goes in here
</script>
   .
   .
   .
XML stuff to the end
I don't know if this will help. It may be totally wrong for Flex, but that's an XML based guess.

-------------------------

Whatever you can do or dream you can, begin it. Boldness has genius, power and magic in it. Begin it now.
-Johann von Goethe

When Two Hearts Race... Both Win.
-Dove Chocolate Wrapper

Chroniclemaster1, Founder of www.EarthChronicle.com
A Growing History of our Planet, by our Planet, for our Planet.
 
Old August 30th, 2007, 03:39 PM
Registered User
 
Join Date: Aug 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks, chroniclemaster1, you were right.

All I needed to do was

<mx:Script>
var hiWorld:String = "Hello World!";
</mx:Script>

Works great.

 
Old August 30th, 2007, 06:00 PM
Friend of Wrox
 
Join Date: Jun 2007
Posts: 477
Thanks: 10
Thanked 19 Times in 18 Posts
Default

Hey! Bravado and dumb luck triumph again!

I'm really glad that I could help you tech out the problem. Nice work!

-------------------------

Whatever you can do or dream you can, begin it. Boldness has genius, power and magic in it. Begin it now.
-Johann von Goethe

When Two Hearts Race... Both Win.
-Dove Chocolate Wrapper

Chroniclemaster1, Founder of www.EarthChronicle.com
A Growing History of our Planet, by our Planet, for our Planet.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Detection of Adobe Acrobat Professional subhasps8 ASP.NET 2.0 Professional 0 February 26th, 2008 09:26 AM
Adobe illustrator file in asp.net nshankar ASP.NET 1.0 and 1.1 Basics 0 August 1st, 2007 04:30 AM
Where does Adobe Pro need to be installed? LenexaKS Reporting Services 0 July 25th, 2007 08:46 AM
Compatibility CR 9.0 and Adobe Acrobat 4.0 pjhanse Crystal Reports 0 May 9th, 2007 06:01 AM
VB Net and Adobe GoLive dany.lessard VB.NET 0 August 1st, 2004 05:06 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.