Flash Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsWeb DesignFlash Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old June 17th, 2012, 06:11 AM
rePete rePete is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Sep 2006
Posts: 658 rePete User rank is Sergeant Major (2000 - 5000 Reputation Level)rePete User rank is Sergeant Major (2000 - 5000 Reputation Level)rePete User rank is Sergeant Major (2000 - 5000 Reputation Level)rePete User rank is Sergeant Major (2000 - 5000 Reputation Level)rePete User rank is Sergeant Major (2000 - 5000 Reputation Level)rePete User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 1 Day 3 h 47 m 13 sec
Reputation Power: 30
ActionScript 3 - Retrieving xml data and matching extension to execute a particular function?

I have an XML file that has location pathways of files to load. eg.
<sample>
<file>audio/sample.mp3</file> or
</sample>
<sample>
<file>slideshow1.swf</file>
</sample>

In my movie, if you click a button, it will load file [0] or [1] using the XML file to provide the pathway. I am trying to create a script that will look at the extension .mp3 or .swf and depending on the extension, will execute a certain function.

How do I make my movie only look at the last 3 letters of the file text in the XML file??

Thanks

Reply With Quote
  #2  
Old June 18th, 2012, 08:57 AM
Tann San Tann San is offline
Gotta get to the next screen..
Dev Shed God 4th Plane (6500 - 6999 posts)
 
Join Date: Nov 2003
Location: Legion of Dynamic Discord
Posts: 6,663 Tann San User rank is General 33rd Grade (Above 100000 Reputation Level)Tann San User rank is General 33rd Grade (Above 100000 Reputation Level)Tann San User rank is General 33rd Grade (Above 100000 Reputation Level)Tann San User rank is General 33rd Grade (Above 100000 Reputation Level)Tann San User rank is General 33rd Grade (Above 100000 Reputation Level)Tann San User rank is General 33rd Grade (Above 100000 Reputation Level)Tann San User rank is General 33rd Grade (Above 100000 Reputation Level)Tann San User rank is General 33rd Grade (Above 100000 Reputation Level)Tann San User rank is General 33rd Grade (Above 100000 Reputation Level)Tann San User rank is General 33rd Grade (Above 100000 Reputation Level)Tann San User rank is General 33rd Grade (Above 100000 Reputation Level)Tann San User rank is General 33rd Grade (Above 100000 Reputation Level)Tann San User rank is General 33rd Grade (Above 100000 Reputation Level)Tann San User rank is General 33rd Grade (Above 100000 Reputation Level)Tann San User rank is General 33rd Grade (Above 100000 Reputation Level)Tann San User rank is General 33rd Grade (Above 100000 Reputation Level)  Folding Points: 14767 Folding Title: Novice Folder
Time spent in forums: 1 Month 1 Week 3 Days 20 h 11 m 52 sec
Reputation Power: 3163
Facebook MySpace
You can use substr on the "file" XML node and check what it returns, in this case the last 4 characters:
Code:
var test_filenames:Vector.<String> = new <String>["dog.exe", "cat.exe", "elephant.php", "bird.gif"];

// .exe
trace(test_filenames[0].substr(-4));

// .php
trace(test_filenames[2].substr(-4));

// Execultable
switch (test_filenames[1].substr(-4))
   {
      case ".exe" :
         trace("Execultable");
         break;
      case ".php" :
         trace("PHP file");
         break;
      case ".gif" :
         trace("Image file");
         break;
   }
__________________
Quis custodiet ipsos custodes?

Reply With Quote
  #3  
Old June 18th, 2012, 08:18 PM
rePete rePete is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Sep 2006
Posts: 658 rePete User rank is Sergeant Major (2000 - 5000 Reputation Level)rePete User rank is Sergeant Major (2000 - 5000 Reputation Level)rePete User rank is Sergeant Major (2000 - 5000 Reputation Level)rePete User rank is Sergeant Major (2000 - 5000 Reputation Level)rePete User rank is Sergeant Major (2000 - 5000 Reputation Level)rePete User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 1 Day 3 h 47 m 13 sec
Reputation Power: 30
Hi Tann, great to read from you!

Thanks for your always helpful replies : )
Quote:
Originally Posted by Tann San
You can use substr on the "file" XML node and check what it returns, in this case the last 4 characters:
Code:
var test_filenames:Vector.<String> = new <String>["dog.exe", "cat.exe", "elephant.php", "bird.gif"];

// .exe
trace(test_filenames[0].substr(-4));

// .php
trace(test_filenames[2].substr(-4));

// Execultable
switch (test_filenames[1].substr(-4))
   {
      case ".exe" :
         trace("Execultable");
         break;
      case ".php" :
         trace("PHP file");
         break;
      case ".gif" :
         trace("Image file");
         break;
   }

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignFlash Help > ActionScript 3 - Retrieving xml data and matching extension to execute a particular function?

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap